smbd: Remove NT4 compatability handling in posix -> NT ACL conversion
authorAndrew Bartlett <abartlet@samba.org>
Mon, 12 Nov 2012 06:11:34 +0000 (17:11 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 13 Nov 2012 21:48:19 +0000 (22:48 +0100)
NT4 is long dead, and we should not change which ACL we return based
on what we think the client is.  The reason we should not do this, is
that if we are using vfs_acl_xattr then the hash will break if we do.
Additionally, it would require that the python VFS interface set the
global remote_arch to fake up being a modern client.

This instead seems cleaner and removes untested code (the tests are
updated to then handle the results of the modern codepath).

The supporting 'acl compatability' parameter is also removed.

Andrew Bartlett

Reviewed by: Jeremy Allison <jra@samba.org>

docs-xml/smbdotconf/vfs/aclcompatibility.xml [deleted file]
lib/param/param_functions.c
lib/param/param_table.c
source3/include/proto.h
source3/smbd/posix_acls.c
source3/smbd/proto.h
source4/libcli/pysmb.c
source4/scripting/python/samba/tests/posixacl.py

diff --git a/docs-xml/smbdotconf/vfs/aclcompatibility.xml b/docs-xml/smbdotconf/vfs/aclcompatibility.xml
deleted file mode 100644 (file)
index 95f42cf..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<samba:parameter name="acl compatibility"
-                 context="G"
-                                type="enum"
-                 advanced="1" developer="1"
-                 xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
-<description>
-       <para>This parameter specifies what OS ACL semantics should 
-       be compatible with. Possible values are <emphasis>winnt</emphasis> for Windows NT 4, 
-       <emphasis>win2k</emphasis> for Windows 2000 and above and <emphasis>auto</emphasis>.
-       If you specify <emphasis>auto</emphasis>, the value for this parameter 
-       will be based upon the version of the client. There should 
-       be no reason to change this parameter from the default.</para>
-</description>
-
-<value type="default">Auto</value>
-<value type="example">win2k</value>
-</samba:parameter>
index d5cd0181c5551062809a11b9afa63bb42716138f..94652fad896c936797878c6ac72f81e1f241509b 100644 (file)
@@ -266,7 +266,6 @@ FN_GLOBAL_CONST_STRING(winbindd_socket_directory, szWinbinddSocketDirectory)
 FN_GLOBAL_CONST_STRING(winbind_separator, szWinbindSeparator)
 FN_GLOBAL_CONST_STRING(workgroup, szWorkgroup)
 FN_GLOBAL_CONST_STRING(wtmpdir, szWtmpDir)
-FN_GLOBAL_INTEGER(acl_compatibility, iAclCompat)
 FN_GLOBAL_INTEGER(afs_token_lifetime, iAfsTokenLifetime)
 FN_GLOBAL_INTEGER(algorithmic_rid_base, AlgorithmicRidBase)
 FN_GLOBAL_INTEGER(allow_dns_updates, allow_dns_updates)
index 01f65fef97195eeaba8500b5ca3db05ace9ea314..a73cd966bc0c13d45993122d722ac1c71e3ecde7 100644 (file)
@@ -180,16 +180,6 @@ static const struct enum_list enum_kerberos_method[] = {
        {-1, NULL}
 };
 
-
-/* ACL compatibility options. */
-static const struct enum_list enum_acl_compat_vals[] = {
-    { ACL_COMPAT_AUTO, "auto" },
-    { ACL_COMPAT_WINNT, "winnt" },
-    { ACL_COMPAT_WIN2K, "win2k" },
-    { -1, NULL}
-};
-
-
 static const struct enum_list enum_printing[] = {
        {PRINT_SYSV, "sysv"},
        {PRINT_AIX, "aix"},
@@ -1458,15 +1448,6 @@ static struct parm_struct parm_table[] = {
                .enum_list      = NULL,
                .flags          = FLAG_ADVANCED,
        },
-       {
-               .label          = "acl compatibility",
-               .type           = P_ENUM,
-               .p_class        = P_GLOBAL,
-               .offset         = GLOBAL_VAR(iAclCompat),
-               .special        = NULL,
-               .enum_list      = enum_acl_compat_vals,
-               .flags          = FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL,
-       },
        {
                .label          = "defer sharing violations",
                .type           = P_BOOL,
index 7c5a5a734604e3f04bed263cd40b790f7e760734..5f3d937ee079c03ca0d708c11ccaa482a73ce4ea 100644 (file)
@@ -1068,7 +1068,6 @@ char *lp_wins_hook(TALLOC_CTX *ctx);
 const char *lp_template_homedir(void);
 const char *lp_template_shell(void);
 const char *lp_winbind_separator(void);
-int lp_acl_compatibility(void);
 bool lp_winbind_enum_users(void);
 bool lp_winbind_enum_groups(void);
 bool lp_winbind_use_default_domain(void);
index 74ea257d363d083f19f07b269a88fe8c7b23dcbc..b8e0d4aba42a7497516d0e073e917e46b3cde43a 100644 (file)
@@ -1058,24 +1058,6 @@ static void merge_aces( canon_ace **pp_list_head, bool dir_acl)
        *pp_list_head = l_head;
 }
 
-/****************************************************************************
- Check if we need to return NT4.x compatible ACL entries.
-****************************************************************************/
-
-bool nt4_compatible_acls(void)
-{
-       int compat = lp_acl_compatibility();
-
-       if (compat == ACL_COMPAT_AUTO) {
-               enum remote_arch_types ra_type = get_remote_arch();
-
-               /* Automatically adapt to client */
-               return (ra_type <= RA_WINNT);
-       } else
-               return (compat == ACL_COMPAT_WINNT);
-}
-
-
 /****************************************************************************
  Map canon_ace perms to permission bits NT.
  The attr element is not used here - we only process deny entries on set,
@@ -1107,10 +1089,7 @@ uint32_t map_canon_ace_perms(int snum,
                 * to be changed in the future.
                 */
 
-               if (nt4_compatible_acls())
-                       nt_mask = UNIX_ACCESS_NONE;
-               else
-                       nt_mask = 0;
+               nt_mask = 0;
        } else {
                if (directory_ace) {
                        nt_mask |= ((perms & S_IRUSR) ? UNIX_DIRECTORY_ACCESS_R : 0 );
@@ -1954,26 +1933,6 @@ static bool create_canon_ace_lists(files_struct *fsp,
                        DEBUG(3,("create_canon_ace_lists: unable to set anything but an ALLOW or DENY ACE.\n"));
                        return False;
                }
-
-               if (nt4_compatible_acls()) {
-                       /*
-                        * The security mask may be UNIX_ACCESS_NONE which should map into
-                        * no permissions (we overload the WRITE_OWNER bit for this) or it
-                        * should be one of the ALL/EXECUTE/READ/WRITE bits. Arrange for this
-                        * to be so. Any other bits override the UNIX_ACCESS_NONE bit.
-                        */
-
-                       /*
-                        * Convert GENERIC bits to specific bits.
-                        */
-                       se_map_generic(&psa->access_mask, &file_generic_mapping);
-
-                       psa->access_mask &= (UNIX_ACCESS_NONE|FILE_ALL_ACCESS);
-
-                       if(psa->access_mask != UNIX_ACCESS_NONE)
-                               psa->access_mask &= ~UNIX_ACCESS_NONE;
-               }
        }
 
        /*
@@ -3163,22 +3122,6 @@ static bool set_canon_ace_list(files_struct *fsp,
        return ret;
 }
 
-/****************************************************************************
- Find a particular canon_ace entry.
-****************************************************************************/
-
-static struct canon_ace *canon_ace_entry_for(struct canon_ace *list, SMB_ACL_TAG_T type, struct unixid *id)
-{
-       while (list) {
-               if (list->type == type && ((type != SMB_ACL_USER && type != SMB_ACL_GROUP) ||
-                               (type == SMB_ACL_USER  && id && id->id == list->unix_ug.id) ||
-                               (type == SMB_ACL_GROUP && id && id->id == list->unix_ug.id)))
-                       break;
-               list = list->next;
-       }
-       return list;
-}
-
 /****************************************************************************
  
 ****************************************************************************/
@@ -3461,55 +3404,6 @@ static NTSTATUS posix_get_nt_acl_common(struct connection_struct *conn,
                        canon_ace *ace;
                        enum security_ace_type nt_acl_type;
 
-                       if (nt4_compatible_acls() && dir_ace) {
-                               /*
-                                * NT 4 chokes if an ACL contains an INHERIT_ONLY entry
-                                * but no non-INHERIT_ONLY entry for one SID. So we only
-                                * remove entries from the Access ACL if the
-                                * corresponding Default ACL entries have also been
-                                * removed. ACEs for CREATOR-OWNER and CREATOR-GROUP
-                                * are exceptions. We can do nothing
-                                * intelligent if the Default ACL contains entries that
-                                * are not also contained in the Access ACL, so this
-                                * case will still fail under NT 4.
-                                */
-
-                               ace = canon_ace_entry_for(dir_ace, SMB_ACL_OTHER, NULL);
-                               if (ace && !ace->perms) {
-                                       DLIST_REMOVE(dir_ace, ace);
-                                       TALLOC_FREE(ace);
-
-                                       ace = canon_ace_entry_for(file_ace, SMB_ACL_OTHER, NULL);
-                                       if (ace && !ace->perms) {
-                                               DLIST_REMOVE(file_ace, ace);
-                                               TALLOC_FREE(ace);
-                                       }
-                               }
-
-                               /*
-                                * WinNT doesn't usually have Creator Group
-                                * in browse lists, so we send this entry to
-                                * WinNT even if it contains no relevant
-                                * permissions. Once we can add
-                                * Creator Group to browse lists we can
-                                * re-enable this.
-                                */
-
-#if 0
-                               ace = canon_ace_entry_for(dir_ace, SMB_ACL_GROUP_OBJ, NULL);
-                               if (ace && !ace->perms) {
-                                       DLIST_REMOVE(dir_ace, ace);
-                                       TALLOC_FREE(ace);
-                               }
-#endif
-
-                               ace = canon_ace_entry_for(file_ace, SMB_ACL_GROUP_OBJ, NULL);
-                               if (ace && !ace->perms) {
-                                       DLIST_REMOVE(file_ace, ace);
-                                       TALLOC_FREE(ace);
-                               }
-                       }
-
                        num_acls = count_canon_ace_list(file_ace);
                        num_def_acls = count_canon_ace_list(dir_ace);
 
index aae4bd02dbe827f5c80c796a6f5ebfbe52d780dd..f95fddd0c6ff46a2cdafe475c808b7ab5a701701 100644 (file)
@@ -703,7 +703,6 @@ void reply_pipe_read_and_X(struct smb_request *req);
 /* The following definitions come from smbd/posix_acls.c  */
 
 void create_file_sids(const SMB_STRUCT_STAT *psbuf, struct dom_sid *powner_sid, struct dom_sid *pgroup_sid);
-bool nt4_compatible_acls(void);
 uint32_t map_canon_ace_perms(int snum,
                                 enum security_ace_type *pacl_type,
                                 mode_t perms,
index 1122305c283344106d1890c281aac159ec49e840..fb981c7f18994544cb12785704fa23b12c2ca3f0 100644 (file)
@@ -317,10 +317,11 @@ static PyObject *py_smb_getacl(pytalloc_Object *self, PyObject *args, PyObject *
        union smb_fileinfo fio;
        struct smb_private_data *spdata;
        const char *filename;
-       int sinfo = 0;
+       uint32_t sinfo = 0;
+       int access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
        int fnum;
 
-       if (!PyArg_ParseTuple(args, "s|i:get_acl", &filename, &sinfo)) {
+       if (!PyArg_ParseTuple(args, "s|Ii:get_acl", &filename, &sinfo, &access_mask)) {
                return NULL;
        }
 
@@ -331,7 +332,7 @@ static PyObject *py_smb_getacl(pytalloc_Object *self, PyObject *args, PyObject *
        io.generic.level = RAW_OPEN_NTCREATEX;
        io.ntcreatex.in.root_fid.fnum = 0;
        io.ntcreatex.in.flags = 0;
-       io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
+       io.ntcreatex.in.access_mask = access_mask;
        io.ntcreatex.in.create_options = 0;
        io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
        io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | 
index f949ab47b3385c316df0f027c61b06f928dcccc7..652721f4f107979e36f18dc8489c79376c6015e7 100644 (file)
@@ -92,7 +92,7 @@ class PosixAclMappingTests(TestCaseInTempDir):
 
     def test_setntacl_smbd_invalidate_getntacl_smbd(self):
         acl = "O:S-1-5-21-2212615479-2695158682-2101375467-512G:S-1-5-21-2212615479-2695158682-2101375467-513D:(A;OICI;0x001f01ff;;;S-1-5-21-2212615479-2695158682-2101375467-512)"
-        simple_acl_from_posix = "O:S-1-5-21-2212615479-2695158682-2101375467-512G:S-1-5-21-2212615479-2695158682-2101375467-513D:(A;;0x001f01ff;;;S-1-5-21-2212615479-2695158682-2101375467-512)(A;;0x001200a9;;;S-1-5-21-2212615479-2695158682-2101375467-513)(A;;WO;;;WD)"
+        simple_acl_from_posix = "O:S-1-5-21-2212615479-2695158682-2101375467-512G:S-1-5-21-2212615479-2695158682-2101375467-513D:(A;;0x001f01ff;;;S-1-5-21-2212615479-2695158682-2101375467-512)(A;;0x001200a9;;;S-1-5-21-2212615479-2695158682-2101375467-513)(A;;;;;WD)"
         os.chmod(self.tempf, 0750)
         setntacl(self.lp, self.tempf, acl, "S-1-5-21-2212615479-2695158682-2101375467", use_ntvfs=False)
 
@@ -122,7 +122,7 @@ class PosixAclMappingTests(TestCaseInTempDir):
 
     def test_setntacl_smbd_setposixacl_getntacl_smbd(self):
         acl = "O:S-1-5-21-2212615479-2695158682-2101375467-512G:S-1-5-21-2212615479-2695158682-2101375467-513D:(A;OICI;0x001f01ff;;;S-1-5-21-2212615479-2695158682-2101375467-512)"
-        simple_acl_from_posix = "O:S-1-5-21-2212615479-2695158682-2101375467-512G:S-1-5-21-2212615479-2695158682-2101375467-513D:(A;;0x001f019f;;;S-1-5-21-2212615479-2695158682-2101375467-512)(A;;0x00120089;;;S-1-5-21-2212615479-2695158682-2101375467-513)(A;;WO;;;WD)"
+        simple_acl_from_posix = "O:S-1-5-21-2212615479-2695158682-2101375467-512G:S-1-5-21-2212615479-2695158682-2101375467-513D:(A;;0x001f019f;;;S-1-5-21-2212615479-2695158682-2101375467-512)(A;;0x00120089;;;S-1-5-21-2212615479-2695158682-2101375467-513)(A;;;;;WD)"
         setntacl(self.lp, self.tempf, acl, "S-1-5-21-2212615479-2695158682-2101375467", use_ntvfs=False)
         # This invalidates the hash of the NT acl just set because there is a hook in the posix ACL set code
         smbd.set_simple_acl(self.tempf, 0640)
@@ -133,7 +133,7 @@ class PosixAclMappingTests(TestCaseInTempDir):
     def test_setntacl_smbd_setposixacl_group_getntacl_smbd(self):
         acl = "O:S-1-5-21-2212615479-2695158682-2101375467-512G:S-1-5-21-2212615479-2695158682-2101375467-513D:(A;OICI;0x001f01ff;;;S-1-5-21-2212615479-2695158682-2101375467-512)"
         BA_sid = security.dom_sid(security.SID_BUILTIN_ADMINISTRATORS)
-        simple_acl_from_posix = "O:S-1-5-21-2212615479-2695158682-2101375467-512G:S-1-5-21-2212615479-2695158682-2101375467-513D:(A;;0x001f019f;;;S-1-5-21-2212615479-2695158682-2101375467-512)(A;;0x00120089;;;BA)(A;;0x00120089;;;S-1-5-21-2212615479-2695158682-2101375467-513)(A;;WO;;;WD)"
+        simple_acl_from_posix = "O:S-1-5-21-2212615479-2695158682-2101375467-512G:S-1-5-21-2212615479-2695158682-2101375467-513D:(A;;0x001f019f;;;S-1-5-21-2212615479-2695158682-2101375467-512)(A;;0x00120089;;;BA)(A;;0x00120089;;;S-1-5-21-2212615479-2695158682-2101375467-513)(A;;;;;WD)"
         setntacl(self.lp, self.tempf, acl, "S-1-5-21-2212615479-2695158682-2101375467", use_ntvfs=False)
         # This invalidates the hash of the NT acl just set because there is a hook in the posix ACL set code
         s4_passdb = passdb.PDB(self.lp.get("passdb backend"))
@@ -193,7 +193,7 @@ class PosixAclMappingTests(TestCaseInTempDir):
         user_SID = s4_passdb.uid_to_sid(os.stat(self.tempf).st_uid)
         smbd.set_simple_acl(self.tempf, 0640)
         facl = getntacl(self.lp, self.tempf, direct_db_access=False)
-        acl = "O:%sG:%sD:(A;;0x001f019f;;;%s)(A;;0x00120089;;;%s)(A;;WO;;;WD)" % (user_SID, group_SID, user_SID, group_SID)
+        acl = "O:%sG:%sD:(A;;0x001f019f;;;%s)(A;;0x00120089;;;%s)(A;;;;;WD)" % (user_SID, group_SID, user_SID, group_SID)
         anysid = security.dom_sid(security.SID_NT_SELF)
         self.assertEquals(acl, facl.as_sddl(anysid))
 
@@ -210,7 +210,7 @@ class PosixAclMappingTests(TestCaseInTempDir):
         smbd.chown(self.tempdir, BA_id, SO_id)
         smbd.set_simple_acl(self.tempdir, 0750)
         facl = getntacl(self.lp, self.tempdir, direct_db_access=False)
-        acl = "O:BAG:SOD:(A;;0x001f01ff;;;BA)(A;;0x001200a9;;;SO)(A;;WO;;;WD)(A;OICIIO;0x001f01ff;;;CO)(A;OICIIO;0x001f01ff;;;CG)(A;OICIIO;0x001f01ff;;;WD)"
+        acl = "O:BAG:SOD:(A;;0x001f01ff;;;BA)(A;;0x001200a9;;;SO)(A;;;;;WD)(A;OICIIO;0x001f01ff;;;CO)(A;OICIIO;0x001f01ff;;;CG)(A;OICIIO;0x001f01ff;;;WD)"
 
         anysid = security.dom_sid(security.SID_NT_SELF)
         self.assertEquals(acl, facl.as_sddl(anysid))
@@ -225,7 +225,7 @@ class PosixAclMappingTests(TestCaseInTempDir):
         smbd.set_simple_acl(self.tempf, 0640, BA_gid)
         facl = getntacl(self.lp, self.tempf, direct_db_access=False)
         domsid = passdb.get_global_sam_sid()
-        acl = "O:%sG:%sD:(A;;0x001f019f;;;%s)(A;;0x00120089;;;BA)(A;;0x00120089;;;%s)(A;;WO;;;WD)" % (user_SID, group_SID, user_SID, group_SID)
+        acl = "O:%sG:%sD:(A;;0x001f019f;;;%s)(A;;0x00120089;;;BA)(A;;0x00120089;;;%s)(A;;;;;WD)" % (user_SID, group_SID, user_SID, group_SID)
         anysid = security.dom_sid(security.SID_NT_SELF)
         self.assertEquals(acl, facl.as_sddl(anysid))