LCGDM-804: Mode parameter added to dmlite_fopen/createIOHandler. Default 660.
authorRicardo Rocha <ricardo.rocha@cern.ch>
Mon, 5 Nov 2012 17:02:51 +0000 (17:02 +0000)
committerRicardo Rocha <ricardo.rocha@cern.ch>
Mon, 5 Nov 2012 17:02:51 +0000 (17:02 +0000)
git-svn-id: https://svn.cern.ch/reps/lcgdm/dmlite-plugins-vfs/trunk@7653 4525493e-7705-40b1-a816-d608a930855b

src/VfsIO.cpp
src/VfsIO.h

index 094225c..b14945a 100644 (file)
@@ -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());
 }
index 928f456..effff34 100644 (file)
@@ -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);