]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: Change set_unix_posix_default_acl() to return NTSTATUS.
authorJeremy Allison <jra@samba.org>
Tue, 18 Jun 2019 22:14:53 +0000 (15:14 -0700)
committerJeremy Allison <jra@samba.org>
Mon, 24 Jun 2019 18:49:09 +0000 (18:49 +0000)
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/smbd/posix_acls.c
source3/smbd/proto.h
source3/smbd/trans2.c

index b58ef621032ab5a580ad3005d0674807d44cbc4a..4fab04d5cf6219360bc267551db4a509fde56514 100644 (file)
@@ -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;
 }
 
 /****************************************************************************
index 85ba16355d3b6c2302219669c657ad2ae1d2aaaa..2c8e33430c9dd5a96d6bceedb1937326faf55ad9 100644 (file)
@@ -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,
index 9b6606631432b2cf99a072241216426ec286126b..9f2b888889c82c177b47a45386a26c19fa6640de 100644 (file)
@@ -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;
                }
        }