From 97eb326ef4b49ee56d5100cbbb808c9a8eb7658b Mon Sep 17 00:00:00 2001 From: Ricardo Rocha Date: Mon, 5 Nov 2012 17:02:51 +0000 Subject: [PATCH] LCGDM-804: Mode parameter added to dmlite_fopen/createIOHandler. Default 660. git-svn-id: https://svn.cern.ch/reps/lcgdm/dmlite-plugins-vfs/trunk@7653 4525493e-7705-40b1-a816-d608a930855b --- src/VfsIO.cpp | 19 +++++++++++-------- src/VfsIO.h | 6 +++--- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/VfsIO.cpp b/src/VfsIO.cpp index 094225c..b14945a 100644 --- a/src/VfsIO.cpp +++ b/src/VfsIO.cpp @@ -47,11 +47,14 @@ void VfsIODriver::setSecurityContext(const SecurityContext* ctx) throw (DmExcept IOHandler* VfsIODriver::createIOHandler(const std::string& pfn, - int openmode, - const Extensible& extras) throw (DmException) + int flags, + const Extensible& extras, + mode_t mode) throw (DmException) { - if (!extras.hasField("token")) - throw DmException(EACCES, "Missing token"); + if (!(flags & IODriver::kInsecure)) { + if (!extras.hasField("token")) + throw DmException(EACCES, "Missing token"); + } std::string userId; if (this->useIp_) @@ -62,12 +65,12 @@ IOHandler* VfsIODriver::createIOHandler(const std::string& pfn, if (dmlite::validateToken(extras.getString("token"), userId, pfn, this->passwd_, - openmode != O_RDONLY) != kTokenOK) + flags != O_RDONLY) != kTokenOK) throw DmException(EACCES, "Token does not validate (using %s)", this->useIp_?"IP":"DN"); // Create - return new VfsIOHandler(pfn, openmode); + return new VfsIOHandler(pfn, flags, mode); } @@ -81,7 +84,7 @@ void VfsIODriver::doneWriting(const std::string& pfn, VfsIOHandler::VfsIOHandler(const std::string& path, - int openmode) throw (DmException): + int flags, mode_t mode) throw (DmException): eof_(false), pos_(0) { std::string real; @@ -91,7 +94,7 @@ VfsIOHandler::VfsIOHandler(const std::string& path, real = path.substr(4); - this->fd_ = ::open(real.c_str(), openmode, 0644); + this->fd_ = ::open(real.c_str(), flags, mode); if (this->fd_ == -1) throw DmException(errno, "Could not open %s", path.c_str()); } diff --git a/src/VfsIO.h b/src/VfsIO.h index 928f456..effff34 100644 --- a/src/VfsIO.h +++ b/src/VfsIO.h @@ -20,8 +20,8 @@ namespace dmlite { void setStackInstance(StackInstance* si) throw (DmException); void setSecurityContext(const SecurityContext* ctx) throw (DmException); - IOHandler* createIOHandler(const std::string& pfn, int openmode, - const Extensible& extras) throw (DmException); + IOHandler* createIOHandler(const std::string& pfn, int flags, + const Extensible& extras, mode_t mode) throw (DmException); void doneWriting(const std::string& pfn, const Extensible& params) throw (DmException); @@ -37,7 +37,7 @@ namespace dmlite { class VfsIOHandler: public IOHandler { public: VfsIOHandler(const std::string& path, - int openmode) throw (DmException); + int flags, mode_t mode) throw (DmException); ~VfsIOHandler(); void close(void) throw (DmException); -- 1.8.2.3