nsswitch: Lookup the domain in tests with the wb seperator
[gd/samba-autobuild/.git] / nsswitch / tests / test_idmap_nss.sh
1 #!/bin/sh
2 # Test id mapping with unknown SID and non-allocating idmap backend
3 if [ $# -lt 1 ]; then
4         echo Usage: $0 DOMAIN
5         exit 1
6 fi
7
8 DOMAIN="$1"
9
10 wbinfo="$VALGRIND $BINDIR/wbinfo"
11
12 failed=0
13
14 . `dirname $0`/../../testprogs/blackbox/subunit.sh
15
16 testit "wbinfo returns domain SID" $wbinfo -n "$DOMAIN/" || exit 1
17 DOMAIN_SID=$($wbinfo -n "$DOMAIN/" | cut -f 1 -d " ")
18 echo "Domain $DOMAIN has SID $DOMAIN_SID"
19
20 # Find an unused uid and SID
21 RID=66666
22 while true ; do
23     id $RID
24     if [ $? -ne 0 ] ; then
25         $wbinfo -s $DOMAIN_SID-$RID
26         if [ $? -ne 0 ] ; then
27             break
28         fi
29     fi
30     RID=$(expr $RID + 1)
31 done
32
33 echo "Using non-existing SID $DOMAIN_SID-$RID to check no id allocation is done by the backend"
34
35 out="$($wbinfo --sids-to-unix-ids=$DOMAIN_SID-$RID)"
36 echo "wbinfo returned: $out"
37 test "$out" = "$DOMAIN_SID-$RID -> unmapped"
38 ret=$?
39 testit "wbinfo SID to xid returns unmapped for unknown SID" test $ret -eq 0 || failed=$(expr $failed + 1)
40
41 exit $failed