diff options
author | Jeremy Allison <jra@samba.org> | 2011-04-14 12:49:58 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2011-04-14 12:49:58 -0700 |
commit | 9c2ba9436d1abe66c493a512702101f631946cdf (patch) | |
tree | a9c161496b3c208968d916a2a460519a63414a84 /source3 | |
parent | d9c1d1f709ba49e57762456e529e283825a4fd7a (diff) | |
download | samba-9c2ba9436d1abe66c493a512702101f631946cdf.tar.gz samba-9c2ba9436d1abe66c493a512702101f631946cdf.tar.bz2 samba-9c2ba9436d1abe66c493a512702101f631946cdf.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.
Diffstat (limited to 'source3')
-rw-r--r-- | source3/smbd/open.c | 21 |
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); |