From: František Dvořák Date: Tue, 15 Oct 2013 11:17:00 +0000 (+0200) Subject: Proper support for IODriver::kInsecure. X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=b305d9f137b3b534711ced3fe3b6e083b6e2b31a;p=dmlite-plugins-vfs.git Proper support for IODriver::kInsecure. --- 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); }