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
8 $VALGRIND bin
/net groupmap $
*
17 echo "Took `expr $TNOW - $TBASE` seconds"
21 rm -f $PREFIX_ABS/var
/locks
/group_mapping.?db
26 DOMSID
=`bin/net getlocalsid | awk '{print $6}'`
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
40 for i
in `seq 1 1 $NGROUP`; do
42 gid
=`expr 40000 + $i`;
43 groupdel
$unixgroup 2> /dev
/null
44 groupadd
-g $gid $unixgroup ||
exit 1
46 for i
in `seq 1 1 $NBUILTIN`; do
48 gid
=`expr 50000 + $i`;
49 groupdel
$unixgroup 2> /dev
/null
50 groupadd
-g $gid $unixgroup ||
exit 1
56 echo "Creating local groups"
57 for i
in `seq 1 1 $NLOCAL`; do
58 unixgroup
=testlocal
$i;
60 rid
=`expr 10000 + $i`;
61 testone add rid
=$rid unixgroup
=$unixgroup ntgroup
=$ntgroup type=local ||
exit 1
64 echo "trying a duplicate add"
65 testone add rid
=10001 unixgroup
=testlocal1 ntgroup
=foo
type=local && exit 1
69 echo "Creating domain groups"
70 for i
in `seq 1 1 $NGROUP`; do
73 rid
=`expr 20000 + $i`;
74 testone add rid
=$rid unixgroup
=$unixgroup ntgroup
=$ntgroup type=domain ||
exit 1
79 echo "Creating builtin groups"
80 for i
in `seq 1 1 $NBUILTIN`; do
83 rid
=`expr 30000 + $i`;
84 testone add rid
=$rid unixgroup
=$unixgroup ntgroup
=$ntgroup type=builtin ||
exit 1
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
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
116 echo "trying a duplicate foreign addmem"
117 testone addmem
$DOMSID-10001 $FORSID-70001 && exit 1
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
127 echo "Trying memberships on bogus sid"
128 testone memberships
$DOMSID-999999 ||
exit 1
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
140 echo "Trying duplicate domain group delete"
141 testone delete sid
=$DOMSID-20002 && exit 1
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
151 echo "Trying duplicate local group delete"
152 testone delete sid
=$DOMSID-10002 && exit 1
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
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
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
185 echo "Trying duplicate delmem"
186 testone delmem
$DOMSID-10001 $DOMSID-20001 && exit 1
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
198 echo "Deleting unix groups"
199 for i
in `seq 1 1 $NLOCAL`; do
200 unixgroup
=testlocal
$i;
201 groupdel
$unixgroup 2> /dev
/null
203 for i
in `seq 1 1 $NGROUP`; do
205 groupdel
$unixgroup 2> /dev
/null
207 for i
in `seq 1 1 $NBUILTIN`; do
209 groupdel
$unixgroup 2> /dev
/null