From: Jeremy Allison Date: Tue, 8 Oct 2019 20:45:45 +0000 (-0700) Subject: s3: smbd: set_nt_acl(). Now we know we always have a valid file handle, always use... X-Git-Tag: talloc-2.3.1~366 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2dbc68e2c0212e3e14f304e359d4d0b1ab514ce2;p=thirdparty%2Fsamba.git s3: smbd: set_nt_acl(). Now we know we always have a valid file handle, always use VFS_FCHOWN. Signed-off-by: Jeremy Allison Reviewed-by: Ralph Böhme --- diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c index e0df84bc3f0..23aa5b575a0 100644 --- a/source3/smbd/posix_acls.c +++ b/source3/smbd/posix_acls.c @@ -3578,15 +3578,16 @@ NTSTATUS posix_get_nt_acl(struct connection_struct *conn, NTSTATUS try_chown(files_struct *fsp, uid_t uid, gid_t gid) { NTSTATUS status; + int ret; if(!CAN_WRITE(fsp->conn)) { return NT_STATUS_MEDIA_WRITE_PROTECTED; } /* Case (1). */ - status = vfs_chown_fsp(fsp, uid, gid); - if (NT_STATUS_IS_OK(status)) { - return status; + ret = SMB_VFS_FCHOWN(fsp, uid, gid); + if (ret == 0) { + return NT_STATUS_OK; } /* Case (2) / (3) */ @@ -3610,8 +3611,12 @@ NTSTATUS try_chown(files_struct *fsp, uid_t uid, gid_t gid) } if (has_take_ownership_priv || has_restore_priv) { + status = NT_STATUS_OK; become_root(); - status = vfs_chown_fsp(fsp, uid, gid); + ret = SMB_VFS_FCHOWN(fsp, uid, gid); + if (ret != 0) { + status = map_nt_error_from_unix(errno); + } unbecome_root(); return status; } @@ -3630,9 +3635,13 @@ NTSTATUS try_chown(files_struct *fsp, uid_t uid, gid_t gid) return NT_STATUS_INVALID_OWNER; } + status = NT_STATUS_OK; become_root(); /* Keep the current file gid the same. */ - status = vfs_chown_fsp(fsp, uid, (gid_t)-1); + ret = SMB_VFS_FCHOWN(fsp, uid, (gid_t)-1); + if (ret != 0) { + status = map_nt_error_from_unix(errno); + } unbecome_root(); return status;