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) */
}
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;
}
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;