]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: Change semantics of strict rename to search the file open db.
authorJeremy Allison <jra@samba.org>
Tue, 24 Nov 2015 16:43:14 +0000 (08:43 -0800)
committerKarolin Seeger <kseeger@samba.org>
Wed, 22 Jun 2016 11:11:14 +0000 (13:11 +0200)
Without strict rename just look in local process. POSIX renames are
already dealt with above.

Documentation change to follow.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11065

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
(cherry picked from commit 16f202871ca850bec87e0ec243644b2c20266c44)

source3/smbd/dir.c
source3/smbd/proto.h
source3/smbd/reply.c

index 99bfed3ebe23d6cbf5510dba91f81c0c54bade94..6beb167cb46dd5dab2f925aaeecc58268acfd8b6 100644 (file)
@@ -1965,7 +1965,7 @@ static int have_file_open_below_fn(struct file_id fid,
        return 1;
 }
 
-static bool have_file_open_below(connection_struct *conn,
+bool have_file_open_below(connection_struct *conn,
                                 const struct smb_filename *name)
 {
        struct have_file_open_below_state state = {
index 4f85b0031c4e374de857f64d76551914f475d1ee..84b472d1e0884ca753e58d3910ae54b07d5eb5f1 100644 (file)
@@ -229,6 +229,8 @@ long TellDir(struct smb_Dir *dirp);
 bool SearchDir(struct smb_Dir *dirp, const char *name, long *poffset);
 NTSTATUS can_delete_directory(struct connection_struct *conn,
                                const char *dirname);
+bool have_file_open_below(connection_struct *conn,
+                       const struct smb_filename *name);
 
 /* The following definitions come from smbd/dmapi.c  */
 
index a913511f9f48de508a8430227cf55a84d1c5e013..5206d475391490752ccfb4fbdff07b34b2868c85 100644 (file)
@@ -2676,7 +2676,17 @@ static NTSTATUS can_rename(connection_struct *conn, files_struct *fsp,
                /* If no pathnames are open below this
                   directory, allow the rename. */
 
-               if (file_find_subpath(fsp)) {
+               if (lp_strict_rename(SNUM(conn))) {
+                       /*
+                        * Strict rename, check open file db.
+                        */
+                       if (have_file_open_below(fsp->conn, fsp->fsp_name)) {
+                               return NT_STATUS_ACCESS_DENIED;
+                       }
+               } else if (file_find_subpath(fsp)) {
+                       /*
+                        * No strict rename, just look in local process.
+                        */
                        return NT_STATUS_ACCESS_DENIED;
                }
                return NT_STATUS_OK;