]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4-scripting: Redefine getntacl() as accessing via the smbd VFS or directly
authorAndrew Bartlett <abartlet@samba.org>
Tue, 7 Aug 2012 06:54:28 +0000 (16:54 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 23 Aug 2012 13:02:26 +0000 (15:02 +0200)
This allows us to write tests that compare the smbd vfs with what is
in the DB or xattr.

Andrew Bartlett

source4/scripting/python/samba/ntacls.py
source4/scripting/python/samba/tests/ntacls.py

index 64dfd17d64a553da26609245c10263a967a8b954..6f8e770bba4d2ebdef605a7bc1d3945a91083cbc 100644 (file)
@@ -55,8 +55,8 @@ def checkset_backend(lp, backend, eadbfile):
         raise XattrBackendError("Invalid xattr backend choice %s"%backend)
 
 
-def getntacl(lp, file, backend=None, eadbfile=None):
-    if use_ntvfs:
+def getntacl(lp, file, backend=None, eadbfile=None, direct_db_access=True):
+    if direct_db_access:
         (backend_obj, dbname) = checkset_backend(lp, backend, eadbfile)
         if dbname is not None:
             try:
@@ -71,8 +71,13 @@ def getntacl(lp, file, backend=None, eadbfile=None):
         else:
             attribute = samba.xattr_native.wrap_getxattr(file,
                                                          xattr.XATTR_NTACL_NAME)
-            ntacl = ndr_unpack(xattr.NTACL, attribute)
-            return ntacl
+        ntacl = ndr_unpack(xattr.NTACL, attribute)
+        if ntacl.version == 1:
+            return ntacl.info
+        elif ntacl.version == 2:
+            return ntacl.info.sd
+        elif ntacl.version == 3:
+            return ntacl.info.sd
     else:
         return smbd.get_nt_acl(file)
 
index c867c95c4e1032dd43b70c78cc9f151c703dba51..8cdf613078a4babb795aff4f31d8d41c77771144 100644 (file)
@@ -49,7 +49,7 @@ class NtaclsTests(TestCase):
         setntacl(lp,tempf,acl,"S-1-5-21-2212615479-2695158682-2101375467")
         facl = getntacl(lp,tempf)
         anysid = security.dom_sid(security.SID_NT_SELF)
-        self.assertEquals(facl.info.as_sddl(anysid),acl)
+        self.assertEquals(facl.as_sddl(anysid),acl)
         os.unlink(tempf)
 
     def test_setntacl_getntacl_param(self):
@@ -62,7 +62,7 @@ class NtaclsTests(TestCase):
         setntacl(lp,tempf,acl,"S-1-5-21-2212615479-2695158682-2101375467","tdb",os.path.join(path,"eadbtest.tdb"))
         facl=getntacl(lp,tempf,"tdb",os.path.join(path,"eadbtest.tdb"))
         domsid=security.dom_sid(security.SID_NT_SELF)
-        self.assertEquals(facl.info.as_sddl(domsid),acl)
+        self.assertEquals(facl.as_sddl(domsid),acl)
         os.unlink(tempf)
 
     def test_setntacl_invalidbackend(self):