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