From: Jeremy Allison Date: Tue, 18 Jun 2019 22:14:53 +0000 (-0700) Subject: s3: smbd: Change set_unix_posix_default_acl() to return NTSTATUS. X-Git-Tag: ldb-2.0.5~234 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=681f0f233720b470ad80db80da480237fbc9a665;p=thirdparty%2Fsamba.git s3: smbd: Change set_unix_posix_default_acl() to return NTSTATUS. Signed-off-by: Jeremy Allison Reviewed-by: Volker Lendecke --- diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c index b58ef621032..4fab04d5cf6 100644 --- a/source3/smbd/posix_acls.c +++ b/source3/smbd/posix_acls.c @@ -4350,12 +4350,13 @@ static SMB_ACL_T create_posix_acl_from_wire(connection_struct *conn, on the directory. ****************************************************************************/ -bool set_unix_posix_default_acl(connection_struct *conn, +NTSTATUS set_unix_posix_default_acl(connection_struct *conn, const struct smb_filename *smb_fname, uint16_t num_def_acls, const char *pdata) { SMB_ACL_T def_acl = NULL; + NTSTATUS status; int ret; if (!S_ISDIR(smb_fname->st.st_ex_mode)) { @@ -4363,24 +4364,23 @@ bool set_unix_posix_default_acl(connection_struct *conn, DBG_INFO("Can't set default ACL on non-directory " "file %s\n", smb_fname->base_name); - errno = EISDIR; - return false; - } else { - return true; + return map_nt_error_from_unix(EISDIR); } + return NT_STATUS_OK; } if (!num_def_acls) { /* Remove the default ACL. */ ret = SMB_VFS_SYS_ACL_DELETE_DEF_FILE(conn, smb_fname); if (ret == -1) { + status = map_nt_error_from_unix(errno); DBG_INFO("acl_delete_def_file failed on " "directory %s (%s)\n", smb_fname->base_name, strerror(errno)); - return false; + return status; } - return true; + return NT_STATUS_OK; } def_acl = create_posix_acl_from_wire(conn, @@ -4388,7 +4388,7 @@ bool set_unix_posix_default_acl(connection_struct *conn, pdata, talloc_tos()); if (def_acl == NULL) { - return false; + return map_nt_error_from_unix(errno); } ret = SMB_VFS_SYS_ACL_SET_FILE(conn, @@ -4396,17 +4396,18 @@ bool set_unix_posix_default_acl(connection_struct *conn, SMB_ACL_TYPE_DEFAULT, def_acl); if (ret == -1) { + status = map_nt_error_from_unix(errno); DBG_INFO("acl_set_file failed on directory %s (%s)\n", smb_fname->base_name, strerror(errno)); TALLOC_FREE(def_acl); - return false; + return status; } DBG_DEBUG("set default acl for file %s\n", smb_fname->base_name); TALLOC_FREE(def_acl); - return true; + return NT_STATUS_OK; } /**************************************************************************** diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 85ba16355d3..2c8e33430c9 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -807,7 +807,7 @@ int inherit_access_posix_acl(connection_struct *conn, const char *inherit_from_dir, const struct smb_filename *smb_fname, mode_t mode); -bool set_unix_posix_default_acl(connection_struct *conn, +NTSTATUS set_unix_posix_default_acl(connection_struct *conn, const struct smb_filename *smb_fname, uint16_t num_def_acls, const char *pdata); NTSTATUS set_unix_posix_acl(connection_struct *conn, files_struct *fsp, diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 9b660663143..9f2b888889c 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -7476,12 +7476,11 @@ static NTSTATUS smb_set_posix_acl(connection_struct *conn, pdata += (num_file_acls*SMB_POSIX_ACL_ENTRY_SIZE); if (valid_def_acls) { - bool ok = set_unix_posix_default_acl(conn, + status = set_unix_posix_default_acl(conn, fsp->fsp_name, num_def_acls, pdata); - if (!ok) { - status = map_nt_error_from_unix(errno); + if (!NT_STATUS_IS_OK(status)) { goto out; } }