summaryrefslogtreecommitdiffstats
path: root/source3/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2011-04-14 12:49:58 -0700
committerKarolin Seeger <kseeger@samba.org>2011-04-26 20:07:28 +0200
commitf5a575620933d912e33ad9b1d67f331428b12912 (patch)
tree3092e77cb1cb0f08c1a4b69a6db060cf26912990 /source3/smbd
parent8a5e6c3d7dc48219a100436419ec4922b1e811b0 (diff)
downloadsamba-f5a575620933d912e33ad9b1d67f331428b12912.tar.gz
samba-f5a575620933d912e33ad9b1d67f331428b12912.tar.xz
samba-f5a575620933d912e33ad9b1d67f331428b12912.zip
Optimization for change_file_owner_to_parent() and change_dir_owner_to_parent()
Don't do the chown if the owner is already correct. (cherry picked from commit 9c2ba9436d1abe66c493a512702101f631946cdf) (cherry picked from commit 232e35b48cce6619e409ed07cd367cedd34624c3)
Diffstat (limited to 'source3/smbd')
-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 5c449fcb86a..db326c5a6da 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);