s3: smbd: Make set_unix_posix_acl() return NTSTATUS.
authorJeremy Allison <jra@samba.org>
Tue, 18 Jun 2019 22:03:28 +0000 (15:03 -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 5cf06a8e2b22cca1d5ffb4a42fb88eac19875c58..b2e40ef3504e9855aeb32016f5bcb580f977f5dc 100644 (file)
@@ -4602,7 +4602,7 @@ static NTSTATUS remove_posix_acl(connection_struct *conn,
  except SMB_ACL_USER_OBJ, SMB_ACL_GROUP_OBJ, SMB_ACL_OTHER.
 ****************************************************************************/
 
-bool set_unix_posix_acl(connection_struct *conn,
+NTSTATUS set_unix_posix_acl(connection_struct *conn,
                        files_struct *fsp,
                        const struct smb_filename *smb_fname,
                        uint16_t num_acls,
@@ -4615,11 +4615,7 @@ bool set_unix_posix_acl(connection_struct *conn,
 
        if (!num_acls) {
                /* Remove the ACL from the file. */
-               status = remove_posix_acl(conn, fsp, smb_fname);
-               if (!NT_STATUS_IS_OK(status)) {
-                       return false;
-               }
-               return true;
+               return remove_posix_acl(conn, fsp, smb_fname);
        }
 
        file_acl = create_posix_acl_from_wire(conn,
@@ -4627,18 +4623,19 @@ bool set_unix_posix_acl(connection_struct *conn,
                                        pdata,
                                        talloc_tos());
        if (file_acl == NULL) {
-               return false;
+               return map_nt_error_from_unix(errno);
        }
 
        if (fsp && fsp->fh->fd != -1) {
                /* The preferred way - use an open fd. */
                ret = SMB_VFS_SYS_ACL_SET_FD(fsp, file_acl);
                if (ret == -1) {
+                       status = map_nt_error_from_unix(errno);
                        DBG_INFO("acl_set_file failed on %s (%s)\n",
                                fname,
                                strerror(errno));
                        TALLOC_FREE(file_acl);
-                       return false;
+                       return status;
                }
        } else {
                ret = SMB_VFS_SYS_ACL_SET_FILE(conn,
@@ -4646,11 +4643,12 @@ bool set_unix_posix_acl(connection_struct *conn,
                                        SMB_ACL_TYPE_ACCESS,
                                        file_acl);
                if (ret == -1) {
+                       status = map_nt_error_from_unix(errno);
                        DBG_INFO("acl_set_file failed on %s (%s)\n",
                                fname,
                                strerror(errno));
                        TALLOC_FREE(file_acl);
-                       return false;
+                       return status;
                }
        }
 
@@ -4658,7 +4656,7 @@ bool set_unix_posix_acl(connection_struct *conn,
                fname);
 
        TALLOC_FREE(file_acl);
-       return true;
+       return NT_STATUS_OK;
 }
 
 /********************************************************************
index 8f9b0fe39279f78378dfcd35786f3dc7c70d2efa..85ba16355d3b6c2302219669c657ad2ae1d2aaaa 100644 (file)
@@ -810,7 +810,7 @@ int inherit_access_posix_acl(connection_struct *conn,
 bool set_unix_posix_default_acl(connection_struct *conn,
                                const struct smb_filename *smb_fname,
                                uint16_t num_def_acls, const char *pdata);
-bool set_unix_posix_acl(connection_struct *conn, files_struct *fsp,
+NTSTATUS set_unix_posix_acl(connection_struct *conn, files_struct *fsp,
                                const struct smb_filename *smb_fname,
                                uint16_t num_acls,
                                const char *pdata);
index 77653530dd2a15e8ca66a9fe90521ec19ed6b974..9b6606631432b2cf99a072241216426ec286126b 100644 (file)
@@ -7462,13 +7462,12 @@ static NTSTATUS smb_set_posix_acl(connection_struct *conn,
        pdata += SMB_POSIX_ACL_HEADER_SIZE;
 
        if (valid_file_acls) {
-               bool ok = set_unix_posix_acl(conn,
+               status = set_unix_posix_acl(conn,
                                        fsp,
                                        fsp->fsp_name,
                                        num_file_acls,
                                        pdata);
-               if (!ok) {
-                       status = map_nt_error_from_unix(errno);
+               if (!NT_STATUS_IS_OK(status)) {
                        goto out;
                }
        }