From: Jeremy Allison Date: Tue, 24 Nov 2015 16:43:14 +0000 (-0800) Subject: s3: smbd: Change semantics of strict rename to search the file open db. X-Git-Tag: samba-4.3.12~127 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=932e8ccf06d7dc56c8390b46bbefa403b776370e;p=thirdparty%2Fsamba.git s3: smbd: Change semantics of strict rename to search the file open db. 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 Reviewed-by: Michael Adam (cherry picked from commit 16f202871ca850bec87e0ec243644b2c20266c44) --- diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c index 99bfed3ebe2..6beb167cb46 100644 --- a/source3/smbd/dir.c +++ b/source3/smbd/dir.c @@ -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 = { diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 4f85b0031c4..84b472d1e08 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -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 */ diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index a913511f9f4..5206d475391 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -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;