From c8ad3dc5ce36444a928f49a8c205083852e5a456 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Thu, 3 Oct 2013 17:49:44 +0200 Subject: [PATCH] Proper support for IODriver::kInsecure. --- src/VfsIO.cpp | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/VfsIO.cpp b/src/VfsIO.cpp index 4648a17..7cbb886 100644 --- a/src/VfsIO.cpp +++ b/src/VfsIO.cpp @@ -52,23 +52,22 @@ IOHandler* VfsIODriver::createIOHandler(const std::string& pfn, mode_t mode) throw (DmException) { if (!(flags & IODriver::kInsecure)) { - if (!extras.hasField("token")) - throw DmException(EACCES, "Missing token"); + if (!extras.hasField("token")) + vfsThrow(EACCES, "Missing token"); + + std::string userId; + if (this->useIp_) + userId = this->secCtx_->credentials.remoteAddress; + else + userId = this->secCtx_->credentials.clientName; + + if (dmlite::validateToken(extras.getString("token"), + userId, + pfn, this->passwd_, + flags != O_RDONLY) != kTokenOK) + vfsThrow(EACCES, "Token does not validate for '%s' (using %s)", userId.c_str(), this->useIp_?"IP":"DN"); } - - std::string userId; - if (this->useIp_) - userId = this->secCtx_->credentials.remoteAddress; - else - userId = this->secCtx_->credentials.clientName; - - if (dmlite::validateToken(extras.getString("token"), - userId, - pfn, this->passwd_, - flags != O_RDONLY) != kTokenOK) - throw DmException(EACCES, "Token does not validate (using %s)", - this->useIp_?"IP":"DN"); - + // Create return new VfsIOHandler(pfn, flags, mode); } -- 1.8.2.3