[PATCH] s3: Allow stat call with capability in vfs_gpfs

Christof Schmitt cs at samba.org
Fri Nov 8 14:13:34 MST 2013


From: Abhidnya Joshi <achirmul at in.ibm.com>

stat call will not succeed if READ_ATTR (nfsv4 perm) is not allowed in
GPFS but will succeed in NTFS.

Reviewed-by: Christof Schmitt <cs at samba.org>
---
 source3/include/smb.h      |    3 ++-
 source3/lib/system.c       |    5 +++++
 source3/modules/vfs_gpfs.c |   12 ++++++++++++
 3 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/source3/include/smb.h b/source3/include/smb.h
index 52e1d7d..b9221f9 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 8252e4f..9ba7dfc 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -785,6 +785,11 @@ 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
+			break;
 	}
 
 	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..2f51198 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -1425,6 +1425,12 @@ static int vfs_gpfs_stat(struct vfs_handle_struct *handle,
 				return -1);
 
 	ret = SMB_VFS_NEXT_STAT(handle, smb_fname);
+	if (ret == -1 && errno == EACCES) {
+		set_effective_capability(DAC_OVERRIDE_CAPABILITY);
+		DEBUG(10,("Trying stat with capability\n"));
+		ret = SMB_VFS_NEXT_STAT(handle, smb_fname);
+		drop_effective_capability(DAC_OVERRIDE_CAPABILITY);
+	}
 	if (ret == -1) {
 		return -1;
 	}
@@ -1494,6 +1500,12 @@ static int vfs_gpfs_lstat(struct vfs_handle_struct *handle,
 				return -1);
 
 	ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname);
+	if (ret == -1 && errno == EACCES) {
+		set_effective_capability(DAC_OVERRIDE_CAPABILITY);
+		DEBUG(10,("Trying lstat with capability\n"));
+		ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname);
+		drop_effective_capability(DAC_OVERRIDE_CAPABILITY);
+	}
 	if (ret == -1) {
 		return -1;
 	}
-- 
1.7.1



More information about the samba-technical mailing list