testprogs/blackbox: PY3 bulk change for python scripts use correct python
[sfrench/samba-autobuild/.git] / testprogs / blackbox / test_samba-tool_ntacl.sh
1 #!/bin/sh
2 # Blackbox tests for samba-tool ntacl get/set on member server
3 # Copyright (C) 2018 Björn Baumbach <bb@sernet.de>
4
5 if [ $# -lt 1 ]; then
6 cat <<EOF
7 Usage: test_net_ads_dns.sh PREFIX
8 EOF
9 exit 1;
10 fi
11
12 PREFIX=$1
13
14 failed=0
15
16 samba4bindir="$BINDIR"
17 samba_tool="$samba4bindir/samba-tool"
18
19 testfile="$PREFIX/ntacl_testfile"
20
21 # acl from samba_tool/ntacl.py tests
22 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)"
23
24 . `dirname $0`/subunit.sh
25
26 UID_WRAPPER_ROOT=1
27 export UID_WRAPPER_ROOT
28
29 test_get_acl()
30 {
31         testfile="$1"
32         exptextedacl="$2"
33
34         retacl=$($samba_tool ntacl get "$testfile" --as-sddl) || return $?
35
36         test "$retacl" = "$exptextedacl"
37 }
38
39 test_set_acl()
40 {
41         testfile="$1"
42         acl="$2"
43
44         $samba_tool ntacl set "$acl" "$testfile"
45 }
46
47 # work around include error - s4-loadparm does not allow missing include files
48 #
49 # Unable to load file /home/bbaumba/src/git/samba/st/ad_member/lib/server.conf
50 #  File "bin/python/samba/netcmd/__init__.py", line 183, in _run
51 #    return self.run(*args, **kwargs)
52 #  File "bin/python/samba/netcmd/ntacl.py", line 175, in run
53 #    lp = sambaopts.get_loadparm()
54 #  File "bin/python/samba/getopt.py", line 92, in get_loadparm
55 #    self._lp.load(os.getenv("SMB_CONF_PATH"))
56 #    Processing section "[global]"
57 touch "$(dirname $SMB_CONF_PATH)/error_inject.conf"
58 touch "$(dirname $SMB_CONF_PATH)/delay_inject.conf"
59
60 touch "$testfile"
61
62 testit "set_ntacl" test_set_acl "$testfile" "$acl" || failed=`expr $failed + 1`
63
64 testit "get_ntacl" test_get_acl "$testfile" "$acl" || failed=`expr $failed + 1`
65
66 rm -f "$testfile"
67
68 exit $failed