Enable file-level permissions check.
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Thu, 17 Oct 2013 21:18:59 +0000 (23:18 +0200)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Sat, 19 Oct 2013 19:15:58 +0000 (21:15 +0200)
src/VfsNs.cpp
src/VfsNs.h

index 74891d4..b043e08 100644 (file)
@@ -101,6 +101,7 @@ void VfsCatalog::setSecurityContext(const SecurityContext* ctx) throw (DmExcepti
   std::string subj = ctx->credentials.clientName;
   secCtx_ = ctx;
 
+  debug("'%s'", subj.c_str());
   this->clientName = subj;
 
   this->allowCurrent = vfsEvalRegex(this->allowRegex, this->denyRegex, subj.c_str());
@@ -336,6 +337,9 @@ ExtendedStat VfsCatalog::extendedStat(const std::string& path, bool follow) thro
   // use the retrieved xattrs
   vfsUpdateExtendedStat(meta, xattrs);
 
+  if (checkPermissions(this->secCtx_, meta.acl, meta.stat, S_IREAD) != 0)
+    vfsThrow(EACCES, "not enough permissions for '%s' to read '%s'", clientName.c_str(), meta.name.c_str());
+
 #if 0
   // XXX: black magic
   //      dmlite tests require proper count in st_nlink,
@@ -1237,15 +1241,6 @@ int VfsCatalog::vfsCheckPermissions(const std::string& path, mode_t mode) {
 
 
 ///
-/// override all permission checks - no file-level permissions in zero version
-///
-int VfsCatalog::checkPermissions(const SecurityContext *context, const Acl &acl, const struct stat &stat, mode_t mode) {
-  return 0;
-}
-
-
-
-///
 /// Get extended attributes.
 ///
 /// @param path    local disk namespace path
index 9eb5506..5ecfe1d 100644 (file)
@@ -119,8 +119,6 @@ namespace dmlite {
     std::string prefix_;
 
    private:
-    int checkPermissions(const SecurityContext *context, const Acl &acl, const struct stat &stat, mode_t mode);
-
     regex_t *allowRegex, *denyRegex, *allowWriteRegex, *denyWriteRegex;
     bool allowCurrent, allowWriteCurrent;
     std::string clientName;