From: Jeremy Allison Date: Tue, 8 Jun 2021 18:03:24 +0000 (-0700) Subject: s3: smbd: In can_delete_file_in_directory(), move a fast-path exit to before any... X-Git-Tag: tevent-0.11.0~533 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7e4a9a1e5f18db2ae77de944de75e3c6c3df9dc8;p=thirdparty%2Fsamba.git s3: smbd: In can_delete_file_in_directory(), move a fast-path exit to before any pathname manipulation. If we're root we always return true on a writable share. Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme --- diff --git a/source3/smbd/file_access.c b/source3/smbd/file_access.c index 59401896d36..ac72460732a 100644 --- a/source3/smbd/file_access.c +++ b/source3/smbd/file_access.c @@ -52,6 +52,11 @@ bool can_delete_file_in_directory(connection_struct *conn, return true; } + if (get_current_uid(conn) == (uid_t)0) { + /* I'm sorry sir, I didn't know you were root... */ + return true; + } + /* Get the parent directory permission mask and owners. */ status = SMB_VFS_PARENT_PATHNAME(conn, ctx, @@ -73,11 +78,6 @@ bool can_delete_file_in_directory(connection_struct *conn, ret = false; goto out; } - if (get_current_uid(conn) == (uid_t)0) { - /* I'm sorry sir, I didn't know you were root... */ - ret = true; - goto out; - } #ifdef S_ISVTX /* sticky bit means delete only by owner of file or by root or