fix snapshot content display with hide unreadable
authorChristian Ambach <christian.ambach@de.ibm.com>
Fri, 9 Apr 2010 11:38:28 +0000 (13:38 +0200)
committerVolker Lendecke <vl@samba.org>
Wed, 14 Apr 2010 12:50:52 +0000 (14:50 +0200)
With the hide unreadable option set, snapshots are be displayed
as empty because the shadow_copy2 module did not implement the
fget_nt_acl call that is used by the hide unreadable code and
so the paths were not corrected internally.

To prevent multiple conversions of the paths when the acl call
does a VFS_STAT (like the nfs4acl code does), a check was added
to convert_shadow2_name() so it will not touch paths any more
that look like they have already been converted.

Signed-off-by: Christian Ambach <christian.ambach@de.ibm.com>
source/modules/vfs_shadow_copy2.c

index 1cc7cc49642e316f7dc0e341767f22748cfd5ebb..0720b93009b9bdd86ff4b334b0e838e0c8a244af 100644 (file)
@@ -308,7 +308,7 @@ static char *convert_shadow2_name(vfs_handle_struct *handle, const char *fname,
        TALLOC_CTX *tmp_ctx = talloc_new(handle->data);
        const char *snapdir, *relpath, *baseoffset, *basedir;
        size_t baselen;
-       char *ret;
+       char *ret, *prefix;
 
        snapdir = shadow_copy2_find_snapdir(tmp_ctx, handle);
        if (snapdir == NULL) {
@@ -324,6 +324,13 @@ static char *convert_shadow2_name(vfs_handle_struct *handle, const char *fname,
                return NULL;
        }
 
+       prefix = talloc_asprintf(tmp_ctx, "%s/@GMT-", snapdir);
+       if (strncmp(fname, prefix, strlen(prefix)) == 0) {
+       /* this looks like as we have already normalized it, leave it untouched*/
+               talloc_free(tmp_ctx);
+               return talloc_strdup(handle->data, fname);
+       }
+
        if (strncmp(fname, "@GMT-", 5) != 0) {
                fname = shadow_copy2_normalise_path(tmp_ctx, fname, gmt_path);
                if (fname == NULL) {
@@ -532,6 +539,15 @@ static NTSTATUS shadow_copy2_get_nt_acl(vfs_handle_struct *handle,
         SHADOW2_NTSTATUS_NEXT(GET_NT_ACL, (handle, name, security_info, ppdesc), NT_STATUS_ACCESS_DENIED);
 }
 
+static NTSTATUS shadow_copy2_fget_nt_acl(vfs_handle_struct *handle,
+                               files_struct *fsp, uint32 security_info,
+                               SEC_DESC **ppdesc)
+{
+       char* fname = fsp->fsp_name;
+        SHADOW2_NTSTATUS_NEXT(GET_NT_ACL, (handle, name, security_info, ppdesc), NT_STATUS_ACCESS_DENIED);
+}
+
+
 static NTSTATUS shadow_copy2_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
                             const char *fname, uint32 security_info_sent,
                             struct security_descriptor *psd)
@@ -711,6 +727,7 @@ static vfs_op_tuple shadow_copy2_ops[] = {
 
         /* NT File ACL operations */
         {SMB_VFS_OP(shadow_copy2_get_nt_acl), SMB_VFS_OP_GET_NT_ACL, SMB_VFS_LAYER_TRANSPARENT},
+        {SMB_VFS_OP(shadow_copy2_fget_nt_acl), SMB_VFS_OP_FGET_NT_ACL, SMB_VFS_LAYER_TRANSPARENT},
         {SMB_VFS_OP(shadow_copy2_set_nt_acl), SMB_VFS_OP_SET_NT_ACL, SMB_VFS_LAYER_TRANSPARENT},
 
         /* POSIX ACL operations */