summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/smbd/open.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 66b14ff076..04353a1d56 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -214,6 +214,17 @@ void change_file_owner_to_parent(connection_struct *conn,
"directory %s. Error was %s\n",
smb_fname_str_dbg(smb_fname_parent),
strerror(errno)));
+ TALLOC_FREE(smb_fname_parent);
+ return;
+ }
+
+ if (smb_fname_parent->st.st_ex_uid == fsp->fsp_name->st.st_ex_uid) {
+ /* Already this uid - no need to change. */
+ DEBUG(10,("change_file_owner_to_parent: file %s "
+ "is already owned by uid %d\n",
+ fsp_str_dbg(fsp),
+ (int)fsp->fsp_name->st.st_ex_uid ));
+ TALLOC_FREE(smb_fname_parent);
return;
}
@@ -314,6 +325,16 @@ NTSTATUS change_dir_owner_to_parent(connection_struct *conn,
goto chdir;
}
+ if (smb_fname_parent->st.st_ex_uid == smb_fname_cwd->st.st_ex_uid) {
+ /* Already this uid - no need to change. */
+ DEBUG(10,("change_dir_owner_to_parent: directory %s "
+ "is already owned by uid %d\n",
+ fname,
+ (int)smb_fname_cwd->st.st_ex_uid ));
+ status = NT_STATUS_OK;
+ goto chdir;
+ }
+
become_root();
ret = SMB_VFS_CHOWN(conn, ".", smb_fname_parent->st.st_ex_uid,
(gid_t)-1);