Remove a bunch of direct inbuf references by adding "buf" to smb_request
[Samba.git] / source3 / script / tests / test_groupmap.sh
blob46640a913127716a19befdc746da817913c4c03a
1 #!/bin/sh
2 # test groupmap code tridge@samba.org September 2006
3 # note that this needs root access to add unix groups,
4 # so this cannot be run on the build farm
6 testone() {
7 echo $*
8 $VALGRIND bin/net groupmap $*
11 tstart() {
12 TBASE=`date '+%s'`
15 treport() {
16 TNOW=`date '+%s'`
17 echo "Took `expr $TNOW - $TBASE` seconds"
18 TBASE=$TNOW
21 rm -f $PREFIX_ABS/var/locks/group_mapping.?db
23 NLOCAL=12
24 NGROUP=11
25 NBUILTIN=10
26 DOMSID=`bin/net getlocalsid | awk '{print $6}'`
27 FORSID="S-1-2-3-4-5"
29 echo "DOMSID $DOMSID"
30 echo "FORSID $FORSID"
32 tstart
33 echo "Creating unix groups"
34 for i in `seq 1 1 $NLOCAL`; do
35 unixgroup=testlocal$i;
36 gid=`expr 30000 + $i`;
37 groupdel $unixgroup 2> /dev/null
38 groupadd -g $gid $unixgroup || exit 1
39 done
40 for i in `seq 1 1 $NGROUP`; do
41 unixgroup=testgrp$i;
42 gid=`expr 40000 + $i`;
43 groupdel $unixgroup 2> /dev/null
44 groupadd -g $gid $unixgroup || exit 1
45 done
46 for i in `seq 1 1 $NBUILTIN`; do
47 unixgroup=testb$i;
48 gid=`expr 50000 + $i`;
49 groupdel $unixgroup 2> /dev/null
50 groupadd -g $gid $unixgroup || exit 1
51 done
52 date
54 treport
56 echo "Creating local groups"
57 for i in `seq 1 1 $NLOCAL`; do
58 unixgroup=testlocal$i;
59 ntgroup=ntlgrp$i;
60 rid=`expr 10000 + $i`;
61 testone add rid=$rid unixgroup=$unixgroup ntgroup=$ntgroup type=local || exit 1
62 done
64 echo "trying a duplicate add"
65 testone add rid=10001 unixgroup=testlocal1 ntgroup=foo type=local && exit 1
67 treport
69 echo "Creating domain groups"
70 for i in `seq 1 1 $NGROUP`; do
71 unixgroup=testgrp$i;
72 ntgroup=ntgrp$i;
73 rid=`expr 20000 + $i`;
74 testone add rid=$rid unixgroup=$unixgroup ntgroup=$ntgroup type=domain || exit 1
75 done
77 treport
79 echo "Creating builtin groups"
80 for i in `seq 1 1 $NBUILTIN`; do
81 unixgroup=testb$i;
82 ntgroup=ntbgrp$i;
83 rid=`expr 30000 + $i`;
84 testone add rid=$rid unixgroup=$unixgroup ntgroup=$ntgroup type=builtin || exit 1
85 done
87 treport
89 echo "Adding domain groups to local groups"
90 for i in `seq 1 1 $NLOCAL`; do
91 for j in `seq 1 1 $i`; do
93 lrid=`expr 10000 + $i`;
94 drid=`expr 20000 + $j`;
96 testone addmem $DOMSID-$lrid $DOMSID-$drid || exit 1
97 ( testone listmem $DOMSID-$lrid | sort -r ) || exit 1
98 done
99 done
101 echo "trying a duplicate addmem"
102 testone addmem $DOMSID-10001 $DOMSID-20001 && exit 1
104 echo "Adding foreign SIDs to local groups"
105 for i in `seq 1 1 $NLOCAL`; do
106 for j in `seq 1 1 $i`; do
108 lrid=`expr 10000 + $i`;
109 frid=`expr 70000 + $j`;
111 testone addmem $DOMSID-$lrid $FORSID-$frid || exit 1
112 ( testone listmem $DOMSID-$lrid | sort -r ) || exit 1
113 done
114 done
116 echo "trying a duplicate foreign addmem"
117 testone addmem $DOMSID-10001 $FORSID-70001 && exit 1
119 treport
121 echo "Listing local group memberships of domain groups"
122 for i in `seq 1 1 $NGROUP`; do
123 rid=`expr 20000 + $i`;
124 ( testone memberships $DOMSID-$rid | sort -r ) || exit 1
125 done
127 echo "Trying memberships on bogus sid"
128 testone memberships $DOMSID-999999 || exit 1
130 treport
132 testone list | sort
134 echo "Deleting some domain groups"
135 for i in `seq 2 2 $NGROUP`; do
136 drid=`expr 20000 + $i`;
137 testone delete sid=$DOMSID-$drid || exit 1
138 done
140 echo "Trying duplicate domain group delete"
141 testone delete sid=$DOMSID-20002 && exit 1
143 treport
145 echo "Deleting some local groups"
146 for i in `seq 2 4 $NLOCAL`; do
147 lrid=`expr 10000 + $i`;
148 testone delete sid=$DOMSID-$lrid || exit 1
149 done
151 echo "Trying duplicate local group delete"
152 testone delete sid=$DOMSID-10002 && exit 1
154 treport
156 echo "Modifying some domain groups"
157 for i in `seq 3 2 $NGROUP`; do
158 drid=`expr 20000 + $i`;
159 testone modify sid=$DOMSID-$drid comment="newcomment-$i" type=domain || exit 1
160 done
162 treport
164 testone list | sort
166 echo "Listing local group memberships"
167 for i in `seq 1 1 $NLOCAL`; do
168 rid=`expr 20000 + $i`;
169 ( testone memberships $DOMSID-$rid | sort -r ) || exit 1
170 done
172 treport
174 echo "Removing some domain groups from local groups"
175 for i in `seq 1 2 $NLOCAL`; do
176 for j in `seq 1 3 $i`; do
178 lrid=`expr 10000 + $i`;
179 drid=`expr 20000 + $j`;
181 testone delmem $DOMSID-$lrid $DOMSID-$drid || exit 1
182 done
183 done
185 echo "Trying duplicate delmem"
186 testone delmem $DOMSID-10001 $DOMSID-20001 && exit 1
188 treport
190 echo "Listing local group memberships"
191 for i in `seq 1 1 $NLOCAL`; do
192 rid=`expr 20000 + $i`;
193 ( testone memberships $DOMSID-$rid | sort -r ) || exit 1
194 done
196 treport
198 echo "Deleting unix groups"
199 for i in `seq 1 1 $NLOCAL`; do
200 unixgroup=testlocal$i;
201 groupdel $unixgroup 2> /dev/null
202 done
203 for i in `seq 1 1 $NGROUP`; do
204 unixgroup=testgrp$i;
205 groupdel $unixgroup 2> /dev/null
206 done
207 for i in `seq 1 1 $NBUILTIN`; do
208 unixgroup=testb$i;
209 groupdel $unixgroup 2> /dev/null
210 done
212 treport
214 echo "ALL DONE"