Make the posix ACL module cope with a NULL incoming DACL and a missing owner/group.
authorJeremy Allison <jra@samba.org>
Sat, 23 Oct 2010 00:07:10 +0000 (17:07 -0700)
committerKarolin Seeger <kseeger@samba.org>
Sat, 5 Mar 2011 13:34:36 +0000 (14:34 +0100)
Jeremy.
(cherry picked from commit 09ee42d774c0b0f8cf9a67feb80426c19b4ce24c)

source3/smbd/posix_acls.c

index 0e25ed561530295a9eacf1dad64d8993793a2d43..78708a70d9f1a9e4b676bd4f2f5f6d7348f21eab 100644 (file)
@@ -3856,6 +3856,29 @@ NTSTATUS set_nt_acl(files_struct *fsp, uint32 security_info_sent, const SEC_DESC
                return NT_STATUS_NO_MEMORY;
        }
 
+       if((security_info_sent & SECINFO_DACL) &&
+                       (psd->type & SEC_DESC_DACL_PRESENT) &&
+                       (psd->dacl == NULL)) {
+               SEC_ACE ace;
+
+               /* We can't have NULL DACL in POSIX.
+                  Use Everyone -> full access. */
+
+               init_sec_ace(&ace,
+                               &global_sid_World,
+                               SEC_ACE_TYPE_ACCESS_ALLOWED,
+                               GENERIC_ALL_ACCESS,
+                               0);
+               psd->dacl = make_sec_acl(talloc_tos(),
+                                       NT4_ACL_REVISION,
+                                       1,
+                                       &ace);
+               if (psd->dacl == NULL) {
+                       return NT_STATUS_NO_MEMORY;
+               }
+               security_acl_map_generic(psd->dacl, &file_generic_mapping);
+       }
+
        /*
         * Get the current state of the file.
         */
@@ -3872,6 +3895,14 @@ NTSTATUS set_nt_acl(files_struct *fsp, uint32 security_info_sent, const SEC_DESC
         * Unpack the user/group/world id's.
         */
 
+       /* POSIX can't cope with missing owner/group. */
+       if ((security_info_sent & SECINFO_OWNER) && (psd->owner_sid == NULL)) {
+               security_info_sent &= ~SECINFO_OWNER;
+       }
+       if ((security_info_sent & SECINFO_GROUP) && (psd->group_sid == NULL)) {
+               security_info_sent &= ~SECINFO_GROUP;
+       }
+
        status = unpack_nt_owners( SNUM(conn), &user, &grp, security_info_sent, psd);
        if (!NT_STATUS_IS_OK(status)) {
                return status;