s3:rpc_server: Return NTSTATUS for dcesrv_setup_ncacn_np_socket
[Samba.git] / nsswitch / tests / test_idmap_rid.sh
blob8209a50a4fc34525d255bfc91868a0bda702141d
1 #!/bin/sh
3 # Test id mapping with various SIDs and idmap_rid
6 if [ $# -lt 1 ]; then
7 echo Usage: $0 DOMAIN RANGE_START
8 exit 1
9 fi
11 DOMAIN="$1"
12 RANGE_START="$2"
14 wbinfo="$VALGRIND $BINDIR/wbinfo"
15 failed=0
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"
22 exit 1
25 # Find an unused uid and SID
26 RID=66666
27 MAX_RID=77777
28 while true ; do
29 id $RID
30 if [ $? -ne 0 ] ; then
31 SID="$DOMAIN_SID-$RID"
32 $wbinfo -s $SID
33 if [ $? -ne 0 ] ; then
34 break
37 RID=$(expr $RID + 1)
38 if [ $RID -eq $MAX_RID ] ; then
39 echo "Could not find free SID" | subunit_fail_test "test_idmap_rid"
40 exit 1
42 done
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"
52 ret=$?
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"
63 ret=$?
64 testit "Bogus SID returns unmapped" test $ret -eq 0 || failed=$(expr $failed + 1)
66 exit $failed