Fix shadow_copy2 for "wide links = yes"
authorVolker Lendecke <vl@samba.org>
Tue, 2 Dec 2008 16:37:42 +0000 (17:37 +0100)
committerMichael Adam <obnox@samba.org>
Wed, 17 Dec 2008 09:41:23 +0000 (10:41 +0100)
Signed-off-by: Michael Adam <obnox@samba.org>
source/modules/vfs_shadow_copy2.c
source/smbd/vfs.c

index ddbc5aab1819a927cadc48201a94a9e9efcf57b2..118981d6bff2318ab30f847e567a6db87954b8ef 100644 (file)
@@ -413,7 +413,27 @@ static int shadow_copy2_mknod(vfs_handle_struct *handle,
 static char *shadow_copy2_realpath(vfs_handle_struct *handle,
                            const char *fname, char *resolved_path)
 {
-        SHADOW2_NEXT(REALPATH, (handle, name, resolved_path), char *, NULL);
+       /*
+        * This one here is a bit subtle. SMB_VFS_REALPATH is used in
+        * smbd in two places: To canonicalize the connection path at
+        * tree connect time, and in the check for wide links.
+        *
+        * When the shadow_copy2 module is active it might happen that
+        * the base directory for the snapshots lies outside the share
+        * path, so the test for wide links fails.
+        *
+        * For this reason, in case we hit a shadow copy name, the
+        * SMB_VFS_REALPATH lies: We just ignore the @GMT- prefix for
+        * the realpath calculation, pretending the path is indeed
+        * inside the share path.
+        *
+        * For the tree connect use of REALPATH this will never match
+        * as here all paths start with "/", not with "@"
+        */
+       if (shadow_copy2_match_name(fname)) {
+               fname += GMT_NAME_LEN+1;
+       }
+       return SMB_VFS_NEXT_REALPATH(handle, fname, resolved_path);
 }
 
 static NTSTATUS shadow_copy2_get_nt_acl(vfs_handle_struct *handle,
index 6cf156cb3907622e407eeb87388749c195b675e3..9c897804ba15575498e05eb652363a562b321e75 100644 (file)
@@ -859,6 +859,15 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
 
        DEBUG(3,("reduce_name [%s] [%s]\n", fname, conn->connectpath));
 
+       /*
+        * Watch out to not actually use the path returned by REALPATH
+        * for anything except the in-share check. The reason is that
+        * the shadow_copy2 module lies about REALNAME for the
+        * shadow-copy style paths. If you want to use "resolved_name"
+        * for statcache-like things, you need to modify the
+        * shadow_copy2 module along with this routine.
+        */
+
 #ifdef REALPATH_TAKES_NULL
        resolved_name = SMB_VFS_REALPATH(conn,fname,NULL);
 #else