From 766a78e6b8141f905d8741d3da2b59cb6f1e771e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 7 Jun 2002 23:18:03 +0000 Subject: Ensure when allowing fchown with write access and dos filemodes that we leave the gid alone. Jeremy. (This used to be commit 3f72910cf954b127c0cc06d6616ca2b8cd0d41ad) --- source3/smbd/posix_acls.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c index fd52c07e86..309dd0e719 100644 --- a/source3/smbd/posix_acls.c +++ b/source3/smbd/posix_acls.c @@ -2046,28 +2046,28 @@ static int try_chown(connection_struct *conn, const char *fname, uid_t uid, gid_ /* try the direct way first */ ret = vfs_chown(conn, fname, uid, gid); - if (ret == 0) return 0; + if (ret == 0) + return 0; if(!CAN_WRITE(conn) || !lp_dos_filemode(SNUM(conn))) return -1; - if (vfs_stat(conn,fname,&st)) { + if (vfs_stat(conn,fname,&st)) return -1; - } fsp = open_file_fchmod(conn,fname,&st); - if (!fsp) { + if (!fsp) 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.uid; - + become_root(); - ret = vfswrap_fchown(fsp, fsp->fd, uid, gid); + /* Keep the current file gid the same. */ + ret = vfswrap_fchown(fsp, fsp->fd, uid, (gid_t)-1); unbecome_root(); close_file_fchmod(fsp); -- cgit