summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2009-01-22 15:57:41 -0800
committerJeremy Allison <jra@samba.org>2009-01-22 15:57:41 -0800
commit634cc6b64ad7e840a26400b0ee9c075176d2db3a (patch)
tree1c857741da669a7e015133bbb6d22ac0455e55e4 /source3/smbd
parent81533e2d39cae11b7ea06f289a7c398ed3c51da9 (diff)
downloadsamba-634cc6b64ad7e840a26400b0ee9c075176d2db3a.tar.gz
samba-634cc6b64ad7e840a26400b0ee9c075176d2db3a.tar.bz2
samba-634cc6b64ad7e840a26400b0ee9c075176d2db3a.zip
Fix logic error in try_chown - we shouldn't arbitrarily chown
to ourselves unless that was passed in. Jeremy.
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/posix_acls.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c
index 627bfb4634..72f5c94bc5 100644
--- a/source3/smbd/posix_acls.c
+++ b/source3/smbd/posix_acls.c
@@ -3187,6 +3187,15 @@ int try_chown(connection_struct *conn, const char *fname, uid_t uid, gid_t gid)
return -1;
}
+ /* only allow chown to the current user. This is more secure,
+ and also copes with the case where the SID in a take ownership ACL is
+ a local SID on the users workstation
+ */
+ if (uid != current_user.ut.uid) {
+ errno = EPERM;
+ return -1;
+ }
+
if (SMB_VFS_STAT(conn,fname,&st)) {
return -1;
}
@@ -3195,12 +3204,6 @@ int try_chown(connection_struct *conn, const char *fname, uid_t uid, gid_t gid)
return -1;
}
- /* only allow chown to the current user. This is more secure,
- and also copes with the case where the SID in a take ownership ACL is
- a local SID on the users workstation
- */
- uid = current_user.ut.uid;
-
become_root();
/* Keep the current file gid the same. */
ret = SMB_VFS_FCHOWN(fsp, uid, (gid_t)-1);