3 # Test id mapping with various SIDs and idmap_rid
7 echo Usage
: $0 DOMAIN RANGE_START
14 wbinfo
="$VALGRIND $BINDIR/wbinfo"
17 .
`dirname $0`/..
/..
/testprogs
/blackbox
/subunit.sh
19 DOMAIN_SID
=$
($wbinfo -n "$DOMAIN/" | cut
-f 1 -d " ")
20 if [ $?
-ne 0 ] ; then
21 echo "Could not find domain SID" | subunit_fail_test
"test_idmap_rid"
25 # Find an unused uid and SID
30 if [ $?
-ne 0 ] ; then
31 SID
="$DOMAIN_SID-$RID"
33 if [ $?
-ne 0 ] ; then
38 if [ $RID -eq $MAX_RID ] ; then
39 echo "Could not find free SID" | subunit_fail_test
"test_idmap_rid"
45 # Test 1: Using non-existing SID to check backend returns a mapping
48 EXPECTED_ID
=$
(expr $RID + $RANGE_START)
49 out
="$($wbinfo --sids-to-unix-ids=$SID)"
50 echo "wbinfo returned: \"$out\", expecting \"$SID -> uid/gid $EXPECTED_ID\""
51 test "$out" = "$SID -> uid/gid $EXPECTED_ID"
53 testit
"Unknown RID from primary domain returns a mapping" test $ret -eq 0 || failed
=$
(expr $failed + 1)
56 # Test 2: Using bogus SID with bad domain part to check idmap backend does not generate a mapping
59 SID
=S-1-5-21-1111-2222-3333-666
60 out
="$($wbinfo --sids-to-unix-ids=$SID)"
61 echo "wbinfo returned: \"$out\", expecting \"$SID -> unmapped\""
62 test "$out" = "$SID -> unmapped"
64 testit
"Bogus SID returns unmapped" test $ret -eq 0 || failed
=$
(expr $failed + 1)
67 # Test 3: ID_TYPE_BOTH mappings for group
70 GROUP
="$DOMAIN/Domain Users"
71 GROUP_SID
=$
($wbinfo --name-to-sid="$GROUP" |
sed -e 's/ .*//')
73 uid
=$
($wbinfo --sid-to-uid=$GROUP_SID)
75 testit
"ID_TYPE_BOTH group map to uid succeeds" test $ret -eq 0 ||\
76 failed
=$
(expr $failed + 1)
77 testit
"ID_TYPE_BOTH group map to uid has result" test -n $uid ||\
78 failed
=$
(expr $failed + 1)
80 gid
=$
($wbinfo --sid-to-gid=$GROUP_SID)
82 testit
"ID_TYPE_BOTH group map to gid succeeds" test $ret -eq 0 ||\
83 failed
=$
(expr $failed + 1)
84 testit
"ID_TYPE_BOTH group map to gid has result" test -n $gid ||\
85 failed
=$
(expr $failed + 1)
87 testit
"ID_TYPE_BOTH group uid equals gid" test $uid -eq $gid ||\
88 failed
=$
(expr $failed + 1)
90 group_pw
="$DOMAIN/domain users:*:$uid:$gid::/home/$DOMAIN/domain users:/bin/false"
92 out
=$
(getent passwd
"$GROUP")
94 testit
"getpwnam for ID_TYPE_BOTH group succeeds" test $ret -eq 0 ||\
95 failed
=$
(expr $failed + 1)
97 test "$out" = "$group_pw"
99 testit
"getpwnam for ID_TYPE_BOTH group output" test $ret -eq 0 ||\
100 failed
=$
(expr $failed + 1)
102 out
=$
(getent passwd
$uid)
104 testit
"getpwuid for ID_TYPE_BOTH group succeeds" test $ret -eq 0 ||\
105 failed
=$
(expr $failed + 1)
106 test "$out" = "$group_pw"
108 testit
"getpwuid for ID_TYPE_BOTH group output" test $ret -eq 0 ||\
109 failed
=$
(expr $failed + 1)
111 group_gr
="$DOMAIN/domain users:x:$gid:"
113 out
=$
(getent group
"$GROUP")
115 testit
"getgrnam for ID_TYPE_BOTH group succeeds" test $ret -eq 0 ||\
116 failed
=$
(expr $failed + 1)
117 test "$out" = "$group_gr"
119 testit
"getgrnam for ID_TYPE_BOTH group output" test $ret -eq 0 ||\
120 failed
=$
(expr $failed + 1)
122 out
=$
(getent group
"$gid")
124 testit
"getgrgid for ID_TYPE_BOTH group succeeds" test $ret -eq 0 ||\
125 failed
=$
(expr $failed + 1)
126 test "$out" = "$group_gr"
128 testit
"getgrgid for ID_TYPE_BOTH group output" test $ret -eq 0 ||\
129 failed
=$
(expr $failed + 1)
132 # Test 4: ID_TYPE_BOTH mappings for user
137 USER
="$DOMAIN/Administrator"
138 USER_SID
=$
($wbinfo --name-to-sid="$USER" |
sed -e 's/ .*//')
140 uid
=$
($wbinfo --sid-to-uid=$USER_SID)
142 testit
"ID_TYPE_BOTH user map to uid succeeds" test $ret -eq 0 ||\
143 failed
=$
(expr $failed + 1)
144 testit
"ID_TYPE_BOTH user map to uid has result" test -n $uid ||\
145 failed
=$
(expr $failed + 1)
147 gid
=$
($wbinfo --sid-to-gid=$USER_SID)
149 testit
"ID_TYPE_BOTH user map to gid succeeds" test $ret -eq 0 ||\
150 failed
=$
(expr $failed + 1)
151 testit
"ID_TYPE_BOTH user map to gid has result" test -n $gid ||\
152 failed
=$
(expr $failed + 1)
154 testit
"ID_TYPE_BOTH user uid equals gid" test $uid -eq $gid ||\
155 failed
=$
(expr $failed + 1)
157 user_pw
="$DOMAIN/administrator:*:$uid:$dom_users_gid::/home/$DOMAIN/administrator:/bin/false"
159 out
=$
(getent passwd
"$USER")
161 testit
"getpwnam for ID_TYPE_BOTH user succeeds" test $ret -eq 0 ||\
162 failed
=$
(expr $failed + 1)
164 test "$out" = "$user_pw"
166 testit
"getpwnam for ID_TYPE_BOTH user output" test $ret -eq 0 ||\
167 failed
=$
(expr $failed + 1)
169 out
=$
(getent passwd
$uid)
171 testit
"getpwuid for ID_TYPE_BOTH user succeeds" test $ret -eq 0 ||\
172 failed
=$
(expr $failed + 1)
173 test "$out" = "$user_pw"
175 testit
"getpwuid for ID_TYPE_BOTH user output" test $ret -eq 0 ||\
176 failed
=$
(expr $failed + 1)
178 user_gr
="$DOMAIN/administrator:x:$gid:$DOMAIN/administrator"
180 out
=$
(getent group
"$USER")
182 testit
"getgrnam for ID_TYPE_BOTH user succeeds" test $ret -eq 0 ||\
183 failed
=$
(expr $failed + 1)
184 test "$out" = "$user_gr"
186 testit
"getgrnam for ID_TYPE_BOTH user output" test $ret -eq 0 ||\
187 failed
=$
(expr $failed + 1)
189 out
=$
(getent group
"$gid")
191 testit
"getgrgid for ID_TYPE_BOTH user succeeds" test $ret -eq 0 ||\
192 failed
=$
(expr $failed + 1)
193 test "$out" = "$user_gr"
195 testit
"getgrgid for ID_TYPE_BOTH user output" test $ret -eq 0 ||\
196 failed
=$
(expr $failed + 1)