The branch, master has been updated
       via  92257ee s3: Handle stat call with capability in vfs_gpfs
       via  47175f5 s3: Add DAC_OVERRIDE capability support
      from  04297e8 gencache: Fix a type-punned warning

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 92257ee41fd5d47b4248ae582bb48b71a13c7174
Author: Abhidnya Joshi <[email protected]>
Date:   Tue Dec 10 11:01:43 2013 +0100

    s3: Handle stat call with capability in vfs_gpfs
    
    Reviewed-by: Volker Lendecke <[email protected]>
    Reviewed-by: Christof Schmitt <[email protected]>
    
    Autobuild-User(master): Christof Schmitt <[email protected]>
    Autobuild-Date(master): Mon Dec 16 20:05:23 CET 2013 on sn-devel-104

commit 47175f5760f485e447bb24966627a4ab80af30f9
Author: Abhidnya Joshi <[email protected]>
Date:   Tue Dec 10 09:10:21 2013 +0100

    s3: Add DAC_OVERRIDE capability support
    
    Reviewed-by: Volker Lendecke <[email protected]>
    Reviewed-by: Christof Schmitt <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 source3/include/smb.h      |    3 +-
 source3/lib/system.c       |    4 +++
 source3/modules/vfs_gpfs.c |   56 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 62 insertions(+), 1 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/smb.h b/source3/include/smb.h
index 16aef87..9fe0533 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -743,7 +743,8 @@ minimum length == 24.
 enum smbd_capability {
     KERNEL_OPLOCK_CAPABILITY,
     DMAPI_ACCESS_CAPABILITY,
-    LEASE_CAPABILITY
+    LEASE_CAPABILITY,
+    DAC_OVERRIDE_CAPABILITY
 };
 
 /*
diff --git a/source3/lib/system.c b/source3/lib/system.c
index f251290..af72b2a 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -785,6 +785,10 @@ static bool set_process_capability(enum smbd_capability 
capability,
                        cap_vals[num_cap_vals++] = CAP_LEASE;
 #endif
                        break;
+               case DAC_OVERRIDE_CAPABILITY:
+#ifdef CAP_DAC_OVERRIDE
+                       cap_vals[num_cap_vals++] = CAP_DAC_OVERRIDE;
+#endif
        }
 
        SMB_ASSERT(num_cap_vals <= ARRAY_SIZE(cap_vals));
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 4a53bf8..c374957 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -1411,6 +1411,46 @@ static ssize_t gpfs_get_xattr(struct vfs_handle_struct 
*handle,  const char *pat
         return 4;
 }
 
+#if defined(HAVE_FSTATAT)
+static int stat_with_capability(struct vfs_handle_struct *handle,
+                               struct smb_filename *smb_fname, int flag)
+{
+       int fd = -1;
+       bool b;
+       char *dir_name;
+       const char *rel_name = NULL;
+       struct stat st;
+       int ret = -1;
+
+       b = parent_dirname(talloc_tos(), smb_fname->base_name,
+                          &dir_name, &rel_name);
+       if (!b) {
+               errno = ENOMEM;
+               return -1;
+       }
+
+       fd = open(dir_name, O_RDONLY, 0);
+       TALLOC_FREE(dir_name);
+       if (fd == -1) {
+               return -1;
+       }
+
+       set_effective_capability(DAC_OVERRIDE_CAPABILITY);
+       ret = fstatat(fd, rel_name, &st, flag);
+       drop_effective_capability(DAC_OVERRIDE_CAPABILITY);
+
+       close(fd);
+
+       if (ret == 0) {
+               init_stat_ex_from_stat(
+                       &smb_fname->st, &st,
+                       lp_fake_dir_create_times(SNUM(handle->conn)));
+       }
+
+       return ret;
+}
+#endif
+
 static int vfs_gpfs_stat(struct vfs_handle_struct *handle,
                         struct smb_filename *smb_fname)
 {
@@ -1425,6 +1465,13 @@ static int vfs_gpfs_stat(struct vfs_handle_struct 
*handle,
                                return -1);
 
        ret = SMB_VFS_NEXT_STAT(handle, smb_fname);
+#if defined(HAVE_FSTATAT)
+       if (ret == -1 && errno == EACCES) {
+               DEBUG(10, ("Trying stat with capability for %s\n",
+                          smb_fname->base_name));
+               ret = stat_with_capability(handle, smb_fname, 0);
+       }
+#endif
        if (ret == -1) {
                return -1;
        }
@@ -1494,6 +1541,15 @@ static int vfs_gpfs_lstat(struct vfs_handle_struct 
*handle,
                                return -1);
 
        ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname);
+#if defined(HAVE_FSTATAT)
+       if (ret == -1 && errno == EACCES) {
+               DEBUG(10, ("Trying lstat with capability for %s\n",
+                          smb_fname->base_name));
+               ret = stat_with_capability(handle, smb_fname,
+                                          AT_SYMLINK_NOFOLLOW);
+       }
+#endif
+
        if (ret == -1) {
                return -1;
        }


-- 
Samba Shared Repository

Reply via email to