1 # Unix SMB/CIFS implementation.
2 # Copyright (C) Andrew Bartlett 2012
5 # Copyright (C) Sean Dague <sdague@linux.vnet.ibm.com> 2011
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 from samba
.tests
.samba_tool
.base
import SambaToolCmdTest
27 class NtACLCmdSysvolTestCase(SambaToolCmdTest
):
28 """Tests for samba-tool ntacl sysvol* subcommands"""
32 (result
, out
, err
) = self
.runsubcmd("ntacl", "sysvolreset",
34 self
.assertCmdSuccess(result
)
35 self
.assertEquals(out
,"","Shouldn't be any output messages")
36 self
.assertIn("Please note that POSIX permissions have NOT been changed, only the stored NT ACL", err
)
39 (result
, out
, err
) = self
.runsubcmd("ntacl", "sysvolreset",
42 self
.assertCmdSuccess(result
)
43 self
.assertEquals(err
,"","Shouldn't be any error messages")
44 self
.assertEquals(out
,"","Shouldn't be any output messages")
46 def test_ntvfs_check(self
):
47 (result
, out
, err
) = self
.runsubcmd("ntacl", "sysvolreset",
49 self
.assertCmdSuccess(result
)
50 self
.assertEquals(out
,"","Shouldn't be any output messages")
51 self
.assertIn("Please note that POSIX permissions have NOT been changed, only the stored NT ACL", err
)
52 # Now check they were set correctly
53 (result
, out
, err
) = self
.runsubcmd("ntacl", "sysvolcheck")
54 self
.assertCmdSuccess(result
)
55 self
.assertEquals(err
,"","Shouldn't be any error messages")
56 self
.assertEquals(out
,"","Shouldn't be any output messages")
58 def test_s3fs_check(self
):
59 (result
, out
, err
) = self
.runsubcmd("ntacl", "sysvolreset",
62 self
.assertCmdSuccess(result
)
63 self
.assertEquals(err
,"","Shouldn't be any error messages")
64 self
.assertEquals(out
,"","Shouldn't be any output messages")
66 # Now check they were set correctly
67 (result
, out
, err
) = self
.runsubcmd("ntacl", "sysvolcheck")
68 self
.assertCmdSuccess(result
)
69 self
.assertEquals(err
,"","Shouldn't be any error messages")
70 self
.assertEquals(out
,"","Shouldn't be any output messages")
72 class NtACLCmdGetSetTestCase(SambaToolCmdTest
):
73 """Tests for samba-tool ntacl get/set subcommands"""
75 acl
= "O:DAG:DUD:P(A;OICI;0x001f01ff;;;DA)(A;OICI;0x001f01ff;;;EA)(A;OICIIO;0x001f01ff;;;CO)(A;OICI;0x001f01ff;;;DA)(A;OICI;0x001f01ff;;;SY)(A;OICI;0x001200a9;;;AU)(A;OICI;0x001200a9;;;ED)S:AI(OU;CIIDSA;WP;f30e3bbe-9ff0-11d1-b603-0000f80367c1;bf967aa5-0de6-11d0-a285-00aa003049e2;WD)(OU;CIIDSA;WP;f30e3bbf-9ff0-11d1-b603-0000f80367c1;bf967aa5-0de6-11d0-a285-00aa003049e2;WD)"
79 path
= os
.environ
['SELFTEST_PREFIX']
80 tempf
= os
.path
.join(path
,"pytests"+str(int(100000*random
.random())))
81 open(tempf
, 'w').write("empty")
83 (result
, out
, err
) = self
.runsubcmd("ntacl", "set", self
.acl
, tempf
,
85 self
.assertCmdSuccess(result
)
86 self
.assertEquals(out
,"","Shouldn't be any output messages")
87 self
.assertIn("Please note that POSIX permissions have NOT been changed, only the stored NT ACL", err
)
90 path
= os
.environ
['SELFTEST_PREFIX']
91 tempf
= os
.path
.join(path
,"pytests"+str(int(100000*random
.random())))
92 open(tempf
, 'w').write("empty")
94 (result
, out
, err
) = self
.runsubcmd("ntacl", "set", self
.acl
, tempf
,
97 self
.assertCmdSuccess(result
)
98 self
.assertEquals(err
,"","Shouldn't be any error messages")
99 self
.assertEquals(out
,"","Shouldn't be any output messages")
101 def test_ntvfs_check(self
):
102 path
= os
.environ
['SELFTEST_PREFIX']
103 tempf
= os
.path
.join(path
,"pytests"+str(int(100000*random
.random())))
104 open(tempf
, 'w').write("empty")
106 (result
, out
, err
) = self
.runsubcmd("ntacl", "set", self
.acl
, tempf
,
108 self
.assertCmdSuccess(result
)
109 self
.assertEquals(out
,"","Shouldn't be any output messages")
110 self
.assertIn("Please note that POSIX permissions have NOT been changed, only the stored NT ACL", err
)
112 # Now check they were set correctly
113 (result
, out
, err
) = self
.runsubcmd("ntacl", "get", tempf
,
114 "--use-ntvfs", "--as-sddl")
115 self
.assertCmdSuccess(result
)
116 self
.assertEquals(err
,"","Shouldn't be any error messages")
117 self
.assertEquals(self
.acl
+"\n", out
, "Output should be the ACL")
119 def test_s3fs_check(self
):
120 path
= os
.environ
['SELFTEST_PREFIX']
121 tempf
= os
.path
.join(path
,"pytests"+str(int(100000*random
.random())))
122 open(tempf
, 'w').write("empty")
124 (result
, out
, err
) = self
.runsubcmd("ntacl", "set", self
.acl
, tempf
,
126 self
.assertCmdSuccess(result
)
127 self
.assertEquals(out
,"","Shouldn't be any output messages")
128 self
.assertEquals(err
,"","Shouldn't be any error messages")
130 # Now check they were set correctly
131 (result
, out
, err
) = self
.runsubcmd("ntacl", "get", tempf
,
132 "--use-s3fs", "--as-sddl")
133 self
.assertCmdSuccess(result
)
134 self
.assertEquals(err
,"","Shouldn't be any error messages")
135 self
.assertEquals(self
.acl
+"\n", out
,"Output should be the ACL")