1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

nsswitch: Reformat shell scripts

shfmt -f nsswitch/ | xargs shfmt -w -p -i 0 -fn

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Andreas Schneider 2022-02-21 11:20:53 +01:00 committed by Andreas Schneider
parent 5b70f21d15
commit d42f08d16b
12 changed files with 310 additions and 307 deletions

View File

@ -21,30 +21,30 @@ ldbsearch="$VALGRIND $BINDIR/ldbsearch"
failed=0
. `dirname $0`/../../testprogs/blackbox/subunit.sh
. $(dirname $0)/../../testprogs/blackbox/subunit.sh
DOMAIN_SID=$($wbinfo -n "$DOMAIN/" | cut -f 1 -d " ")
if [ $? -ne 0 ] ; then
echo "Could not find domain SID" | subunit_fail_test "test_idmap_ad"
exit 1
if [ $? -ne 0 ]; then
echo "Could not find domain SID" | subunit_fail_test "test_idmap_ad"
exit 1
fi
TRUST_DOMAIN_SID=$($wbinfo -n "$TRUST_DOMAIN/" | cut -f 1 -d " ")
if [ $? -ne 0 ] ; then
echo "Could not find trusted domain SID" | subunit_fail_test "test_idmap_ad"
exit 1
if [ $? -ne 0 ]; then
echo "Could not find trusted domain SID" | subunit_fail_test "test_idmap_ad"
exit 1
fi
BASE_DN=$($ldbsearch -H ldap://$DC_SERVER -b "" --scope=base defaultNamingContext | awk '/^defaultNamingContext/ {print $2}')
if [ $? -ne 0 ] ; then
echo "Could not find base DN" | subunit_fail_test "test_idmap_ad"
exit 1
if [ $? -ne 0 ]; then
echo "Could not find base DN" | subunit_fail_test "test_idmap_ad"
exit 1
fi
TRUST_BASE_DN=$($ldbsearch -H ldap://$TRUST_SERVER -b "" --scope=base defaultNamingContext | awk '/^defaultNamingContext/ {print $2}')
if [ $? -ne 0 ] ; then
echo "Could not find trusted base DN" | subunit_fail_test "test_idmap_ad"
exit 1
if [ $? -ne 0 ]; then
echo "Could not find trusted base DN" | subunit_fail_test "test_idmap_ad"
exit 1
fi
#
@ -83,7 +83,7 @@ EOF
# Add POSIX ids to trusted domain
#
cat <<EOF | $ldbmodify -H ldap://$TRUST_SERVER \
-U "$TRUST_DOMAIN\Administrator%$TRUST_PASSWORD"
-U "$TRUST_DOMAIN\Administrator%$TRUST_PASSWORD"
dn: CN=Administrator,CN=Users,$TRUST_BASE_DN
changetype: modify
add: uidNumber
@ -91,7 +91,7 @@ uidNumber: 2500000
EOF
cat <<EOF | $ldbmodify -H ldap://$TRUST_SERVER \
-U "$TRUST_DOMAIN\Administrator%$TRUST_PASSWORD"
-U "$TRUST_DOMAIN\Administrator%$TRUST_PASSWORD"
dn: CN=Domain Users,CN=Users,$TRUST_BASE_DN
changetype: modify
add: gidNumber
@ -99,7 +99,7 @@ gidNumber: 2500001
EOF
cat <<EOF | $ldbmodify -H ldap://$TRUST_SERVER \
-U "$TRUST_DOMAIN\Administrator%$TRUST_PASSWORD"
-U "$TRUST_DOMAIN\Administrator%$TRUST_PASSWORD"
dn: CN=Domain Admins,CN=Users,$TRUST_BASE_DN
changetype: modify
add: gidNumber
@ -222,7 +222,7 @@ EOF
# Remove POSIX ids from trusted domain
#
cat <<EOF | $ldbmodify -H ldap://$TRUST_SERVER \
-U "$TRUST_DOMAIN\Administrator%$TRUST_PASSWORD"
-U "$TRUST_DOMAIN\Administrator%$TRUST_PASSWORD"
dn: CN=Administrator,CN=Users,$TRUST_BASE_DN
changetype: modify
delete: uidNumber
@ -230,7 +230,7 @@ uidNumber: 2500000
EOF
cat <<EOF | $ldbmodify -H ldap://$TRUST_SERVER \
-U "$TRUST_DOMAIN\Administrator%$TRUST_PASSWORD"
-U "$TRUST_DOMAIN\Administrator%$TRUST_PASSWORD"
dn: CN=Domain Users,CN=Users,$TRUST_BASE_DN
changetype: modify
delete: gidNumber
@ -238,7 +238,7 @@ gidNumber: 2500001
EOF
cat <<EOF | $ldbmodify -H ldap://$TRUST_SERVER \
-U "$TRUST_DOMAIN\Administrator%$TRUST_PASSWORD"
-U "$TRUST_DOMAIN\Administrator%$TRUST_PASSWORD"
dn: CN=Domain Admins,CN=Users,$TRUST_BASE_DN
changetype: modify
delete: gidNumber

View File

@ -11,7 +11,7 @@ wbinfo="$VALGRIND $BINDIR/wbinfo"
failed=0
. `dirname $0`/../../testprogs/blackbox/subunit.sh
. $(dirname $0)/../../testprogs/blackbox/subunit.sh
testit "wbinfo returns domain SID" $wbinfo -n "$DOMAIN/" || exit 1
DOMAIN_SID=$($wbinfo -n "$DOMAIN/" | cut -f 1 -d " ")
@ -19,15 +19,15 @@ echo "Domain $DOMAIN has SID $DOMAIN_SID"
# Find an unused uid and SID
RID=66666
while true ; do
id $RID
if [ $? -ne 0 ] ; then
$wbinfo -s $DOMAIN_SID-$RID
if [ $? -ne 0 ] ; then
break
while true; do
id $RID
if [ $? -ne 0 ]; then
$wbinfo -s $DOMAIN_SID-$RID
if [ $? -ne 0 ]; then
break
fi
fi
fi
RID=$(expr $RID + 1)
RID=$(expr $RID + 1)
done
echo "Using non-existing SID $DOMAIN_SID-$RID to check no id allocation is done by the backend"

View File

@ -1,9 +1,9 @@
#!/bin/sh
# Test id mapping through idmap_rfc2307 module
if [ $# -lt 15 ]; then
echo Usage: $0 DOMAIN USERNAME UID USERNAME2 UID2 \
GROUPNAME GID GROUPNAME2 GID2 GID_START NUMGROUPS \
LDAPPREFIX DC_SERVER DC_USERNAME DC_PASSWORD
echo Usage: $0 DOMAIN USERNAME UID USERNAME2 UID2 \
GROUPNAME GID GROUPNAME2 GID2 GID_START NUMGROUPS \
LDAPPREFIX DC_SERVER DC_USERNAME DC_PASSWORD
exit 1
fi
@ -44,7 +44,7 @@ fi
failed=0
. `dirname $0`/../../testprogs/blackbox/subunit.sh
. $(dirname $0)/../../testprogs/blackbox/subunit.sh
# Delete LDAP records
$VALGRIND $ldbdel -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "$LDAPPREFIX" --controls="tree_delete:1"
@ -52,13 +52,13 @@ $VALGRIND $ldbdel -H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD "$LDA
# Add id mapping information to LDAP
testit "add ldap prefix" $VALGRIND $ldbadd -H ldap://$DC_SERVER \
-U$DOMAIN/$DC_USERNAME%$DC_PASSWORD <<EOF
-U$DOMAIN/$DC_USERNAME%$DC_PASSWORD <<EOF
dn: $LDAPPREFIX
objectclass: organizationalUnit
EOF
testit "add ldap user mapping record" $VALGRIND $ldbadd -H ldap://$DC_SERVER \
-U$DOMAIN/$DC_USERNAME%$DC_PASSWORD <<EOF
-U$DOMAIN/$DC_USERNAME%$DC_PASSWORD <<EOF
dn: cn=$USERNAME,$LDAPPREFIX
objectClass: organizationalPerson
objectClass: posixAccount
@ -71,7 +71,7 @@ homeDirectory: /home/admin
EOF
testit "add second ldap user mapping record" $VALGRIND $ldbadd \
-H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD <<EOF
-H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD <<EOF
dn: cn=$USERNAME2,$LDAPPREFIX
objectClass: organizationalPerson
objectClass: posixAccount
@ -84,7 +84,7 @@ homeDirectory: /home/admin
EOF
testit "add ldap group mapping record" $VALGRIND $ldbadd \
-H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD <<EOF
-H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD <<EOF
dn: cn=$GROUPNAME,$LDAPPREFIX
objectClass: posixGroup
objectClass: groupOfNames
@ -94,7 +94,7 @@ member: cn=$USERNAME,$LDAPPREFIX
EOF
testit "add second ldap group mapping record" $VALGRIND $ldbadd \
-H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD <<EOF
-H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD <<EOF
dn: cn=$GROUPNAME2,$LDAPPREFIX
objectClass: posixGroup
objectClass: groupOfNames
@ -147,20 +147,20 @@ echo "SID $group_sid2 resolved to $group_name2"
testit "test $group_name2 = $DOMAIN/$GROUPNAME2" test "$(echo $group_name2 | tr A-Z a-z)" = "$(echo $DOMAIN/$GROUPNAME2 | tr A-Z a-z)" || failed=$(expr $failed + 1)
i=0
while [ ${i} -lt ${NUMGROUPS} ] ; do
GRP=$(printf "test_rfc2307_group_%3.3d" "$i")
GRP_GID=$(expr "$GID_START" + "$i")
testit "Add group $GRP" $net rpc group add "$GRP" -S "$DC_SERVER" \
-U"${DOMAIN}\\${DC_USERNAME}"%"${DC_PASSWORD}" ||
failed=$(expr $failed + 1)
testit "Add groupmem $GRP $USERNAME" \
$net rpc group addmem "$GRP" "$USERNAME" \
-S "$DC_SERVER" \
-U"${DOMAIN}\\${DC_USERNAME}"%"${DC_PASSWORD}" ||
failed=$(expr $failed + 1)
testit "Add group object for $GRP $GRP_GID" \
$VALGRIND $ldbadd \
-H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD <<EOF
while [ ${i} -lt ${NUMGROUPS} ]; do
GRP=$(printf "test_rfc2307_group_%3.3d" "$i")
GRP_GID=$(expr "$GID_START" + "$i")
testit "Add group $GRP" $net rpc group add "$GRP" -S "$DC_SERVER" \
-U"${DOMAIN}\\${DC_USERNAME}"%"${DC_PASSWORD}" ||
failed=$(expr $failed + 1)
testit "Add groupmem $GRP $USERNAME" \
$net rpc group addmem "$GRP" "$USERNAME" \
-S "$DC_SERVER" \
-U"${DOMAIN}\\${DC_USERNAME}"%"${DC_PASSWORD}" ||
failed=$(expr $failed + 1)
testit "Add group object for $GRP $GRP_GID" \
$VALGRIND $ldbadd \
-H ldap://$DC_SERVER -U$DOMAIN/$DC_USERNAME%$DC_PASSWORD <<EOF
dn: cn=$GRP,$LDAPPREFIX
objectClass: posixGroup
objectClass: groupOfNames
@ -168,51 +168,51 @@ cn: $GRP
gidNumber: $GRP_GID
member: cn=$USERNAME,$LDAPPREFIX
EOF
i=$(expr "$i" + 1)
i=$(expr "$i" + 1)
done
# Test whether wbinfo --xids-to-sids finds everything
GIDS=""
i=0
while [ ${i} -lt ${NUMGROUPS} ] ; do
GIDS="$GIDS g$(expr ${i} + ${GID_START})"
i=$(expr "$i" + 1)
while [ ${i} -lt ${NUMGROUPS} ]; do
GIDS="$GIDS g$(expr ${i} + ${GID_START})"
i=$(expr "$i" + 1)
done
NUM_VALID_SIDS=$($wbinfo --unix-ids-to-sids="$GIDS" | grep -v ^"NOT MAPPED" | wc -l)
testit "Count number of valid sids found" \
test ${NUM_VALID_SIDS} = ${NUMGROUPS} ||
failed=$(expr $failed + 1)
test ${NUM_VALID_SIDS} = ${NUMGROUPS} ||
failed=$(expr $failed + 1)
# Prime the cache so we test idmap, not the harder problem of
# consistent group memberships for users without a login.
testit "Authenticate the user to prime the netlogon cache" \
$wbinfo -a $DOMAIN/$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
$wbinfo -a $DOMAIN/$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1)
# Test whether wbinfo -r shows all groups
EXPECTED_USERGROUPS="1000000/1000001/2000002/"
i=0
while [ ${i} -lt ${NUMGROUPS} ] ; do
EXPECTED_USERGROUPS="$EXPECTED_USERGROUPS$(expr ${i} + ${GID_START})/"
i=$(expr "$i" + 1)
while [ ${i} -lt ${NUMGROUPS} ]; do
EXPECTED_USERGROUPS="$EXPECTED_USERGROUPS$(expr ${i} + ${GID_START})/"
i=$(expr "$i" + 1)
done
USERGROUPS=$($wbinfo -r $DOMAIN/$USERNAME | sort -n | tr '\n' '/')
testit "Testing for expected group memberships" \
test "$USERGROUPS" = "$EXPECTED_USERGROUPS" ||
failed=$(expr $failed + 1)
test "$USERGROUPS" = "$EXPECTED_USERGROUPS" ||
failed=$(expr $failed + 1)
i=0
while [ ${i} -lt ${NUMGROUPS} ] ; do
GRP=$(printf "test_rfc2307_group_%3.3d" ${i})
testit "Del group $GRP" $net rpc group delete "$GRP" -S "$DC_SERVER" \
-U"${DOMAIN}\\${DC_USERNAME}"%"${DC_PASSWORD}" ||
failed=$(expr $failed + 1)
i=$(expr "$i" + 1)
while [ ${i} -lt ${NUMGROUPS} ]; do
GRP=$(printf "test_rfc2307_group_%3.3d" ${i})
testit "Del group $GRP" $net rpc group delete "$GRP" -S "$DC_SERVER" \
-U"${DOMAIN}\\${DC_USERNAME}"%"${DC_PASSWORD}" ||
failed=$(expr $failed + 1)
i=$(expr "$i" + 1)
done
# Delete LDAP records

View File

@ -14,31 +14,31 @@ RANGE_START="$2"
wbinfo="$VALGRIND $BINDIR/wbinfo"
failed=0
. `dirname $0`/../../testprogs/blackbox/subunit.sh
. $(dirname $0)/../../testprogs/blackbox/subunit.sh
DOMAIN_SID=$($wbinfo -n "$DOMAIN/" | cut -f 1 -d " ")
if [ $? -ne 0 ] ; then
echo "Could not find domain SID" | subunit_fail_test "test_idmap_rid"
exit 1
if [ $? -ne 0 ]; then
echo "Could not find domain SID" | subunit_fail_test "test_idmap_rid"
exit 1
fi
# Find an unused uid and SID
RID=66666
MAX_RID=77777
while true ; do
id $RID
if [ $? -ne 0 ] ; then
SID="$DOMAIN_SID-$RID"
$wbinfo -s $SID
if [ $? -ne 0 ] ; then
break
while true; do
id $RID
if [ $? -ne 0 ]; then
SID="$DOMAIN_SID-$RID"
$wbinfo -s $SID
if [ $? -ne 0 ]; then
break
fi
fi
RID=$(expr $RID + 1)
if [ $RID -eq $MAX_RID ]; then
echo "Could not find free SID" | subunit_fail_test "test_idmap_rid"
exit 1
fi
fi
RID=$(expr $RID + 1)
if [ $RID -eq $MAX_RID ] ; then
echo "Could not find free SID" | subunit_fail_test "test_idmap_rid"
exit 1
fi
done
#
@ -72,60 +72,60 @@ GROUP_SID=$($wbinfo --name-to-sid="$GROUP" | sed -e 's/ .*//')
uid=$($wbinfo --sid-to-uid=$GROUP_SID)
ret=$?
testit "ID_TYPE_BOTH group map to uid succeeds" test $ret -eq 0 ||\
testit "ID_TYPE_BOTH group map to uid succeeds" test $ret -eq 0 ||
failed=$(expr $failed + 1)
testit "ID_TYPE_BOTH group map to uid has result" test -n $uid ||\
testit "ID_TYPE_BOTH group map to uid has result" test -n $uid ||
failed=$(expr $failed + 1)
gid=$($wbinfo --sid-to-gid=$GROUP_SID)
ret=$?
testit "ID_TYPE_BOTH group map to gid succeeds" test $ret -eq 0 ||\
testit "ID_TYPE_BOTH group map to gid succeeds" test $ret -eq 0 ||
failed=$(expr $failed + 1)
testit "ID_TYPE_BOTH group map to gid has result" test -n $gid ||\
testit "ID_TYPE_BOTH group map to gid has result" test -n $gid ||
failed=$(expr $failed + 1)
testit "ID_TYPE_BOTH group uid equals gid" test $uid -eq $gid ||\
testit "ID_TYPE_BOTH group uid equals gid" test $uid -eq $gid ||
failed=$(expr $failed + 1)
group_pw="$DOMAIN/domain users:*:$uid:$gid::/home/$DOMAIN/domain users:/bin/false"
out=$(getent passwd "$GROUP")
ret=$?
testit "getpwnam for ID_TYPE_BOTH group succeeds" test $ret -eq 0 ||\
testit "getpwnam for ID_TYPE_BOTH group succeeds" test $ret -eq 0 ||
failed=$(expr $failed + 1)
test "$out" = "$group_pw"
ret=$?
testit "getpwnam for ID_TYPE_BOTH group output" test $ret -eq 0 ||\
testit "getpwnam for ID_TYPE_BOTH group output" test $ret -eq 0 ||
failed=$(expr $failed + 1)
out=$(getent passwd $uid)
ret=$?
testit "getpwuid for ID_TYPE_BOTH group succeeds" test $ret -eq 0 ||\
testit "getpwuid for ID_TYPE_BOTH group succeeds" test $ret -eq 0 ||
failed=$(expr $failed + 1)
test "$out" = "$group_pw"
ret=$?
testit "getpwuid for ID_TYPE_BOTH group output" test $ret -eq 0 ||\
testit "getpwuid for ID_TYPE_BOTH group output" test $ret -eq 0 ||
failed=$(expr $failed + 1)
group_gr="$DOMAIN/domain users:x:$gid:"
out=$(getent group "$GROUP")
ret=$?
testit "getgrnam for ID_TYPE_BOTH group succeeds" test $ret -eq 0 ||\
testit "getgrnam for ID_TYPE_BOTH group succeeds" test $ret -eq 0 ||
failed=$(expr $failed + 1)
test "$out" = "$group_gr"
ret=$?
testit "getgrnam for ID_TYPE_BOTH group output" test $ret -eq 0 ||\
testit "getgrnam for ID_TYPE_BOTH group output" test $ret -eq 0 ||
failed=$(expr $failed + 1)
out=$(getent group "$gid")
ret=$?
testit "getgrgid for ID_TYPE_BOTH group succeeds" test $ret -eq 0 ||\
testit "getgrgid for ID_TYPE_BOTH group succeeds" test $ret -eq 0 ||
failed=$(expr $failed + 1)
test "$out" = "$group_gr"
ret=$?
testit "getgrgid for ID_TYPE_BOTH group output" test $ret -eq 0 ||\
testit "getgrgid for ID_TYPE_BOTH group output" test $ret -eq 0 ||
failed=$(expr $failed + 1)
#
@ -139,60 +139,60 @@ USER_SID=$($wbinfo --name-to-sid="$USER" | sed -e 's/ .*//')
uid=$($wbinfo --sid-to-uid=$USER_SID)
ret=$?
testit "ID_TYPE_BOTH user map to uid succeeds" test $ret -eq 0 ||\
testit "ID_TYPE_BOTH user map to uid succeeds" test $ret -eq 0 ||
failed=$(expr $failed + 1)
testit "ID_TYPE_BOTH user map to uid has result" test -n $uid ||\
testit "ID_TYPE_BOTH user map to uid has result" test -n $uid ||
failed=$(expr $failed + 1)
gid=$($wbinfo --sid-to-gid=$USER_SID)
ret=$?
testit "ID_TYPE_BOTH user map to gid succeeds" test $ret -eq 0 ||\
testit "ID_TYPE_BOTH user map to gid succeeds" test $ret -eq 0 ||
failed=$(expr $failed + 1)
testit "ID_TYPE_BOTH user map to gid has result" test -n $gid ||\
testit "ID_TYPE_BOTH user map to gid has result" test -n $gid ||
failed=$(expr $failed + 1)
testit "ID_TYPE_BOTH user uid equals gid" test $uid -eq $gid ||\
testit "ID_TYPE_BOTH user uid equals gid" test $uid -eq $gid ||
failed=$(expr $failed + 1)
user_pw="$DOMAIN/administrator:*:$uid:$dom_users_gid::/home/$DOMAIN/administrator:/bin/false"
out=$(getent passwd "$USER")
ret=$?
testit "getpwnam for ID_TYPE_BOTH user succeeds" test $ret -eq 0 ||\
testit "getpwnam for ID_TYPE_BOTH user succeeds" test $ret -eq 0 ||
failed=$(expr $failed + 1)
test "$out" = "$user_pw"
ret=$?
testit "getpwnam for ID_TYPE_BOTH user output" test $ret -eq 0 ||\
testit "getpwnam for ID_TYPE_BOTH user output" test $ret -eq 0 ||
failed=$(expr $failed + 1)
out=$(getent passwd $uid)
ret=$?
testit "getpwuid for ID_TYPE_BOTH user succeeds" test $ret -eq 0 ||\
testit "getpwuid for ID_TYPE_BOTH user succeeds" test $ret -eq 0 ||
failed=$(expr $failed + 1)
test "$out" = "$user_pw"
ret=$?
testit "getpwuid for ID_TYPE_BOTH user output" test $ret -eq 0 ||\
testit "getpwuid for ID_TYPE_BOTH user output" test $ret -eq 0 ||
failed=$(expr $failed + 1)
user_gr="$DOMAIN/administrator:x:$gid:$DOMAIN/administrator"
out=$(getent group "$USER")
ret=$?
testit "getgrnam for ID_TYPE_BOTH user succeeds" test $ret -eq 0 ||\
testit "getgrnam for ID_TYPE_BOTH user succeeds" test $ret -eq 0 ||
failed=$(expr $failed + 1)
test "$out" = "$user_gr"
ret=$?
testit "getgrnam for ID_TYPE_BOTH user output" test $ret -eq 0 ||\
testit "getgrnam for ID_TYPE_BOTH user output" test $ret -eq 0 ||
failed=$(expr $failed + 1)
out=$(getent group "$gid")
ret=$?
testit "getgrgid for ID_TYPE_BOTH user succeeds" test $ret -eq 0 ||\
testit "getgrgid for ID_TYPE_BOTH user succeeds" test $ret -eq 0 ||
failed=$(expr $failed + 1)
test "$out" = "$user_gr"
ret=$?
testit "getgrgid for ID_TYPE_BOTH user output" test $ret -eq 0 ||\
testit "getgrgid for ID_TYPE_BOTH user output" test $ret -eq 0 ||
failed=$(expr $failed + 1)
exit $failed

View File

@ -1,10 +1,10 @@
#!/bin/sh
# Blackbox test for wbinfo and rfc2307 mappings
if [ $# -lt 4 ]; then
cat <<EOF
cat <<EOF
Usage: test_rfc2307_mapping.sh DOMAIN USERNAME PASSWORD SERVER UID_RFC2307TEST GID_RFC2307TEST
EOF
exit 1;
exit 1
fi
DOMAIN=$1
@ -26,41 +26,42 @@ else
ldbmodify="ldbmodify"
fi
. `dirname $0`/../../testprogs/blackbox/subunit.sh
. $(dirname $0)/../../testprogs/blackbox/subunit.sh
testfail() {
testfail()
{
name="$1"
shift
cmdline="$*"
echo "test: $name"
$cmdline
status=$?
if [ x$status = x0 ]; then
echo "failure: $name"
else
echo "success: $name"
fi
return $status
if [ x$status = x0 ]; then
echo "failure: $name"
else
echo "success: $name"
fi
return $status
}
knownfail() {
name="$1"
shift
cmdline="$*"
echo "test: $name"
$cmdline
status=$?
if [ x$status = x0 ]; then
echo "failure: $name [unexpected success]"
status=1
else
echo "knownfail: $name"
status=0
fi
return $status
knownfail()
{
name="$1"
shift
cmdline="$*"
echo "test: $name"
$cmdline
status=$?
if [ x$status = x0 ]; then
echo "failure: $name [unexpected success]"
status=1
else
echo "knownfail: $name"
status=0
fi
return $status
}
# Create new testing account
testit "user add" $PYTHON $samba_tool user create --given-name="rfc2307" --surname="Tester" --initial="UT" rfc2307_test_user testp@ssw0Rd $@
@ -70,112 +71,112 @@ testit "group add" $PYTHON $samba_tool group add $CONFIG --group-scope='Domain'
# Create new testing group
# Convert name to SID
testit "wbinfo -n against $TARGET" $wbinfo -n "$DOMAIN/rfc2307_test_user" || failed=`expr $failed + 1`
user_sid=`$wbinfo -n "$DOMAIN/rfc2307_test_user" | cut -d " " -f1`
testit "wbinfo -n against $TARGET" $wbinfo -n "$DOMAIN/rfc2307_test_user" || failed=$(expr $failed + 1)
user_sid=$($wbinfo -n "$DOMAIN/rfc2307_test_user" | cut -d " " -f1)
echo "$DOMAIN/rfc2307_test_user resolved to $user_sid"
testit "wbinfo -s $user_sid against $TARGET" $wbinfo -s $user_sid || failed=`expr $failed + 1`
user_name=`$wbinfo -s $user_sid | cut -d " " -f1| tr a-z A-Z`
testit "wbinfo -s $user_sid against $TARGET" $wbinfo -s $user_sid || failed=$(expr $failed + 1)
user_name=$($wbinfo -s $user_sid | cut -d " " -f1 | tr a-z A-Z)
echo "$user_sid resolved to $user_name"
tested_name=`echo $DOMAIN/rfc2307_test_user | tr a-z A-Z`
tested_name=$(echo $DOMAIN/rfc2307_test_user | tr a-z A-Z)
# Now check that wbinfo works correctly (sid <=> name)
echo "test: wbinfo -s check for sane mapping"
if test x$user_name != x$tested_name; then
echo "$user_name does not match $tested_name"
echo "failure: wbinfo -s check for sane mapping"
failed=`expr $failed + 1`
failed=$(expr $failed + 1)
else
echo "success: wbinfo -s check for sane mapping"
fi
testit "wbinfo -n on the returned name against $TARGET" $wbinfo -n $user_name || failed=`expr $failed + 1`
test_sid=`$wbinfo -n $tested_name | cut -d " " -f1`
testit "wbinfo -n on the returned name against $TARGET" $wbinfo -n $user_name || failed=$(expr $failed + 1)
test_sid=$($wbinfo -n $tested_name | cut -d " " -f1)
echo "test: wbinfo -n check for sane mapping"
if test x$user_sid != x$test_sid; then
echo "$user_sid does not match $test_sid"
echo "failure: wbinfo -n check for sane mapping"
failed=`expr $failed + 1`
failed=$(expr $failed + 1)
else
echo "success: wbinfo -n check for sane mapping"
fi
testit "wbinfo -n against $TARGET" $wbinfo -n "$DOMAIN/rfc2307_test_group" || failed=`expr $failed + 1`
group_sid=`$wbinfo -n "$DOMAIN/rfc2307_test_group" | cut -d " " -f1`
testit "wbinfo -n against $TARGET" $wbinfo -n "$DOMAIN/rfc2307_test_group" || failed=$(expr $failed + 1)
group_sid=$($wbinfo -n "$DOMAIN/rfc2307_test_group" | cut -d " " -f1)
echo "$DOMAIN/rfc2307_test_group resolved to $group_sid"
# Then add a uidNumber to the group record using ldbmodify
cat > $PREFIX/tmpldbmodify <<EOF
cat >$PREFIX/tmpldbmodify <<EOF
dn: <SID=$user_sid>
changetype: modify
add: uidNumber
uidNumber: $UID_RFC2307TEST
EOF
testit "modify gidNumber on group" $VALGRIND $ldbmodify -H ldap://$SERVER $PREFIX/tmpldbmodify -U$DOMAIN/$USERNAME%$PASSWORD $@ || failed=`expr $failed + 1`
testit "modify gidNumber on group" $VALGRIND $ldbmodify -H ldap://$SERVER $PREFIX/tmpldbmodify -U$DOMAIN/$USERNAME%$PASSWORD $@ || failed=$(expr $failed + 1)
# Then add a gidNumber to the group record using ldbmodify
cat > $PREFIX/tmpldbmodify <<EOF
cat >$PREFIX/tmpldbmodify <<EOF
dn: <SID=$group_sid>
changetype: modify
add: gidNumber
gidNumber: $GID_RFC2307TEST
EOF
testit "modify gidNumber on group" $VALGRIND $ldbmodify -H ldap://$SERVER $PREFIX/tmpldbmodify -U$DOMAIN/$USERNAME%$PASSWORD $@ || failed=`expr $failed + 1`
testit "modify gidNumber on group" $VALGRIND $ldbmodify -H ldap://$SERVER $PREFIX/tmpldbmodify -U$DOMAIN/$USERNAME%$PASSWORD $@ || failed=$(expr $failed + 1)
rm -f $PREFIX/tmpldbmodify
# Now check we get a correct SID for the UID
testit "wbinfo -U against $TARGET" $wbinfo -U $UID_RFC2307TEST || failed=`expr $failed + 1`
testit "wbinfo -U against $TARGET" $wbinfo -U $UID_RFC2307TEST || failed=$(expr $failed + 1)
echo "test: wbinfo -U check for sane mapping"
sid_for_user=`$wbinfo -U $UID_RFC2307TEST`
sid_for_user=$($wbinfo -U $UID_RFC2307TEST)
if test x"$sid_for_user" != x"$user_sid"; then
echo "uid $UID_RFC2307TEST mapped to $sid_for_user, not $user_sid"
echo "failure: wbinfo -U check for sane mapping"
failed=`expr $failed + 1`
failed=$(expr $failed + 1)
else
echo "success: wbinfo -U check for sane mapping"
fi
testit "wbinfo -G against $TARGET" $wbinfo -G $GID_RFC2307TEST || failed=`expr $failed + 1`
testit "wbinfo -G against $TARGET" $wbinfo -G $GID_RFC2307TEST || failed=$(expr $failed + 1)
echo "test: wbinfo -G check for sane mapping"
sid_for_group=`$wbinfo -G $GID_RFC2307TEST`
sid_for_group=$($wbinfo -G $GID_RFC2307TEST)
if test x$sid_for_group != "x$group_sid"; then
echo "gid $GID_RFC2307TEST mapped to $sid_for_group, not $group_sid"
echo "gid $GID_RFC2307TEST mapped to $sid_for_group, not $group_sid"
echo "failure: wbinfo -G check for sane mapping"
failed=`expr $failed + 1`
failed=$(expr $failed + 1)
else
echo "success: wbinfo -G check for sane mapping"
fi
# Now check we get the right UID from the SID
testit "wbinfo -S against $TARGET" $wbinfo -S "$user_sid" || failed=`expr $failed + 1`
testit "wbinfo -S against $TARGET" $wbinfo -S "$user_sid" || failed=$(expr $failed + 1)
echo "test: wbinfo -S check for sane mapping"
uid_for_user_sid=`$wbinfo -S $user_sid`
uid_for_user_sid=$($wbinfo -S $user_sid)
if test 0$uid_for_user_sid -ne $UID_RFC2307TEST; then
echo "$user_sid mapped to $uid_for_sid, not $UID_RFC2307TEST"
echo "failure: wbinfo -S check for sane mapping"
failed=`expr $failed + 1`
failed=$(expr $failed + 1)
else
echo "success: wbinfo -S check for sane mapping"
fi
# Now check we get the right GID from the SID
testit "wbinfo -Y" $wbinfo -Y "$group_sid" || failed=`expr $failed + 1`
testit "wbinfo -Y" $wbinfo -Y "$group_sid" || failed=$(expr $failed + 1)
echo "test: wbinfo -Y check for sane mapping"
gid_for_user_sid=`$wbinfo -Y $group_sid`
gid_for_user_sid=$($wbinfo -Y $group_sid)
if test 0$gid_for_user_sid -ne $GID_RFC2307TEST; then
echo "$group_sid mapped to $gid_for_sid, not $GID_RFC2307TEST"
echo "failure: wbinfo -Y check for sane mapping"
failed=`expr $failed + 1`
failed=$(expr $failed + 1)
else
echo "success: wbinfo -Y check for sane mapping"
fi

View File

@ -2,8 +2,8 @@
# Test winbind ad backend behaviour when the kerberos ticket expires
if [ $# -ne 1 ]; then
echo Usage: $0 DOMAIN
exit 1
echo Usage: $0 DOMAIN
exit 1
fi
DOMAIN="$1"
@ -13,12 +13,12 @@ net="$VALGRIND $BINDIR/net"
failed=0
. `dirname $0`/../../testprogs/blackbox/subunit.sh
. $(dirname $0)/../../testprogs/blackbox/subunit.sh
DOMAIN_SID=$($wbinfo -n "$DOMAIN/" | cut -f 1 -d " ")
if [ $? -ne 0 ] ; then
echo "Could not find domain SID" | subunit_fail_test "test_idmap_ad"
exit 1
if [ $? -ne 0 ]; then
echo "Could not find domain SID" | subunit_fail_test "test_idmap_ad"
exit 1
fi
ADMINS_SID="$DOMAIN_SID-512"
@ -35,13 +35,13 @@ $net cache del IDMAP/SID2XID/"$ADMINS_SID"
# connection.
testit_expect_failure "Deleting0 IDMAP/SID2XID/$ADMINS_SID" $net cache del IDMAP/SID2XID/"$ADMINS_SID" ||
failed=$(expr $failed + 1)
failed=$(expr $failed + 1)
testit_expect_failure "Expecting failure1, no mapping in AD" $wbinfo --sid-to-gid "$ADMINS_SID" ||
failed=$(expr $failed + 1)
failed=$(expr $failed + 1)
testit "Deleting1 IDMAP/SID2XID/$ADMINS_SID" $net cache del IDMAP/SID2XID/"$ADMINS_SID" ||
failed=$(expr $failed + 1)
failed=$(expr $failed + 1)
# allow our kerberos ticket to expire
testit "Sleeping for 6 seconds" sleep 6 || failed=$(expr $failed + 1)
@ -62,13 +62,13 @@ testit "Sleeping for 6 seconds" sleep 6 || failed=$(expr $failed + 1)
START=$(date +%s)
testit_expect_failure "Expecting failure2, no mapping in AD" $wbinfo --sid-to-gid "$ADMINS_SID" ||
failed=$(expr $failed + 1)
failed=$(expr $failed + 1)
END=$(date +%s)
DURATION=$(expr $END - $START)
testit "timeout DURATION[$DURATION] < 8" test "$DURATION" -le 8 ||
failed=$(expr $failed + 1)
failed=$(expr $failed + 1)
testit "Deleting2 IDMAP/SID2XID/$ADMINS_SID" $net cache del IDMAP/SID2XID/"$ADMINS_SID" ||
failed=$(expr $failed + 1)
failed=$(expr $failed + 1)
exit $failed

View File

@ -1,10 +1,10 @@
#!/bin/sh
# Blackbox test for wbinfo
if [ $# -lt 4 ]; then
cat <<EOF
cat <<EOF
Usage: test_wbinfo.sh DOMAIN USERNAME PASSWORD TARGET
EOF
exit 1;
exit 1
fi
DOMAIN=$1
@ -17,38 +17,40 @@ failed=0
samba4bindir="$BINDIR"
wbinfo="$VALGRIND $samba4bindir/wbinfo"
. `dirname $0`/../../testprogs/blackbox/subunit.sh
. $(dirname $0)/../../testprogs/blackbox/subunit.sh
testfail() {
testfail()
{
name="$1"
shift
cmdline="$*"
echo "test: $name"
$cmdline
status=$?
if [ x$status = x0 ]; then
echo "failure: $name"
else
echo "success: $name"
fi
return $status
if [ x$status = x0 ]; then
echo "failure: $name"
else
echo "success: $name"
fi
return $status
}
knownfail() {
name="$1"
shift
cmdline="$*"
echo "test: $name"
$cmdline
status=$?
if [ x$status = x0 ]; then
echo "failure: $name [unexpected success]"
status=1
else
echo "knownfail: $name"
status=0
fi
return $status
knownfail()
{
name="$1"
shift
cmdline="$*"
echo "test: $name"
$cmdline
status=$?
if [ x$status = x0 ]; then
echo "failure: $name [unexpected success]"
status=1
else
echo "knownfail: $name"
status=0
fi
return $status
}
KRB5CCNAME_PATH="$PREFIX/test_wbinfo_krb5ccache"
@ -58,52 +60,52 @@ KRB5CCNAME="FILE:$KRB5CCNAME_PATH"
export KRB5CCNAME
# List users
testit "wbinfo -u against $TARGET" $wbinfo -u || failed=`expr $failed + 1`
testit "wbinfo -u against $TARGET" $wbinfo -u || failed=$(expr $failed + 1)
# List groups
testit "wbinfo -g against $TARGET" $wbinfo -g || failed=`expr $failed + 1`
testit "wbinfo -g against $TARGET" $wbinfo -g || failed=$(expr $failed + 1)
# Convert netbios name to IP
# Does not work yet
testit "wbinfo -N against $TARGET" $wbinfo -N $NETBIOSNAME || failed=`expr $failed + 1`
testit "wbinfo -N against $TARGET" $wbinfo -N $NETBIOSNAME || failed=$(expr $failed + 1)
# Convert IP to netbios name
# Does not work yet
testit "wbinfo -I against $TARGET" $wbinfo -I $SERVER_IP || failed=`expr $failed + 1`
testit "wbinfo -I against $TARGET" $wbinfo -I $SERVER_IP || failed=$(expr $failed + 1)
# Convert name to SID
testit "wbinfo -n against $TARGET" $wbinfo -n "$DOMAIN/$USERNAME" || failed=`expr $failed + 1`
admin_sid=`$wbinfo -n "$DOMAIN/$USERNAME" | cut -d " " -f1`
testit "wbinfo -n against $TARGET" $wbinfo -n "$DOMAIN/$USERNAME" || failed=$(expr $failed + 1)
admin_sid=$($wbinfo -n "$DOMAIN/$USERNAME" | cut -d " " -f1)
echo "$DOMAIN/$USERNAME resolved to $admin_sid"
testit "wbinfo -s $admin_sid against $TARGET" $wbinfo -s $admin_sid || failed=`expr $failed + 1`
admin_name=`$wbinfo -s $admin_sid | cut -d " " -f1| tr a-z A-Z`
testit "wbinfo -s $admin_sid against $TARGET" $wbinfo -s $admin_sid || failed=$(expr $failed + 1)
admin_name=$($wbinfo -s $admin_sid | cut -d " " -f1 | tr a-z A-Z)
echo "$admin_sid resolved to $admin_name"
tested_name=`echo $DOMAIN/$USERNAME | tr a-z A-Z`
tested_name=$(echo $DOMAIN/$USERNAME | tr a-z A-Z)
echo "test: wbinfo -s check for sane mapping"
if test x$admin_name != x$tested_name; then
echo "$admin_name does not match $tested_name"
echo "failure: wbinfo -s check for sane mapping"
failed=`expr $failed + 1`
failed=$(expr $failed + 1)
else
echo "success: wbinfo -s check for sane mapping"
fi
while read SID ; do
read NAME
while read SID; do
read NAME
testit "wbinfo -s $SID against $TARGET" $wbinfo -s $SID || failed=`expr $failed + 1`
testit "wbinfo -s $SID against $TARGET" $wbinfo -s $SID || failed=$(expr $failed + 1)
RESOLVED_NAME=`$wbinfo -s $SID | tr a-z A-Z`
echo "$SID resolved to $RESOLVED_NAME"
RESOLVED_NAME=$($wbinfo -s $SID | tr a-z A-Z)
echo "$SID resolved to $RESOLVED_NAME"
echo "test: wbinfo -s $SID against $TARGET"
if test x"$RESOLVED_NAME" != x"$NAME" ; then
echo "$RESOLVED_NAME does not match $NAME"
echo "failure: wbinfo -s $SID against $TARGET"
failed=`expr $failed + 1`
else
echo "success: wbinfo -s $SID against $TARGET"
fi
echo "test: wbinfo -s $SID against $TARGET"
if test x"$RESOLVED_NAME" != x"$NAME"; then
echo "$RESOLVED_NAME does not match $NAME"
echo "failure: wbinfo -s $SID against $TARGET"
failed=$(expr $failed + 1)
else
echo "success: wbinfo -s $SID against $TARGET"
fi
done <<EOF
S-1-1-0
/EVERYONE 5
@ -113,133 +115,133 @@ S-1-5-1
NT AUTHORITY/DIALUP 5
EOF
testit "wbinfo -n on the returned name against $TARGET" $wbinfo -n $admin_name || failed=`expr $failed + 1`
test_sid=`$wbinfo -n $tested_name | cut -d " " -f1`
testit "wbinfo -n on the returned name against $TARGET" $wbinfo -n $admin_name || failed=$(expr $failed + 1)
test_sid=$($wbinfo -n $tested_name | cut -d " " -f1)
echo "test: wbinfo -n check for sane mapping"
if test x$admin_sid != x$test_sid; then
echo "$admin_sid does not match $test_sid"
echo "failure: wbinfo -n check for sane mapping"
failed=`expr $failed + 1`
failed=$(expr $failed + 1)
else
echo "success: wbinfo -n check for sane mapping"
fi
echo "test: wbinfo -n NT Authority/Authenticated Users"
$wbinfo -n "NT Authority/Authenticated Users"
if [ $? -ne 0 ] ; then
echo "failure: wbinfo -n NT Authority/Authenticated Users"
failed=`expr $failed + 1`
if [ $? -ne 0 ]; then
echo "failure: wbinfo -n NT Authority/Authenticated Users"
failed=$(expr $failed + 1)
else
echo "success: wbinfo -n NT Authority/Authenticated Users"
echo "success: wbinfo -n NT Authority/Authenticated Users"
fi
echo "test: wbinfo --group-info NT Authority/Authenticated Users"
$wbinfo --group-info "NT Authority/Authenticated Users"
if [ $? -ne 0 ] ; then
echo "failure: wbinfo --group-info NT Authority/Authenticated Users"
failed=`expr $failed + 1`
if [ $? -ne 0 ]; then
echo "failure: wbinfo --group-info NT Authority/Authenticated Users"
failed=$(expr $failed + 1)
else
echo "success: wbinfo --group-info NT Authority/Authenticated Users"
echo "success: wbinfo --group-info NT Authority/Authenticated Users"
fi
testit "wbinfo -U against $TARGET" $wbinfo -U 30000 || failed=`expr $failed + 1`
testit "wbinfo -U against $TARGET" $wbinfo -U 30000 || failed=$(expr $failed + 1)
echo "test: wbinfo -U check for sane mapping"
sid_for_30000=`$wbinfo -U 30000`
sid_for_30000=$($wbinfo -U 30000)
if test x$sid_for_30000 != "xS-1-22-1-30000"; then
echo "uid 30000 mapped to $sid_for_30000, not S-1-22-1-30000"
echo "failure: wbinfo -U check for sane mapping"
failed=`expr $failed + 1`
failed=$(expr $failed + 1)
else
echo "success: wbinfo -U check for sane mapping"
fi
admin_uid=`$wbinfo -S $admin_sid`
admin_uid=$($wbinfo -S $admin_sid)
testit "wbinfo -G against $TARGET" $wbinfo -G 30000 || failed=`expr $failed + 1`
testit "wbinfo -G against $TARGET" $wbinfo -G 30000 || failed=$(expr $failed + 1)
echo "test: wbinfo -G check for sane mapping"
sid_for_30000=`$wbinfo -G 30000`
sid_for_30000=$($wbinfo -G 30000)
if test x$sid_for_30000 != "xS-1-22-2-30000"; then
echo "gid 30000 mapped to $sid_for_30000, not S-1-22-2-30000"
echo "gid 30000 mapped to $sid_for_30000, not S-1-22-2-30000"
echo "failure: wbinfo -G check for sane mapping"
failed=`expr $failed + 1`
failed=$(expr $failed + 1)
else
echo "success: wbinfo -G check for sane mapping"
fi
testit "wbinfo -S against $TARGET" $wbinfo -S "S-1-22-1-30000" || failed=`expr $failed + 1`
testit "wbinfo -S against $TARGET" $wbinfo -S "S-1-22-1-30000" || failed=$(expr $failed + 1)
echo "test: wbinfo -S check for sane mapping"
uid_for_sid=`$wbinfo -S S-1-22-1-30000`
uid_for_sid=$($wbinfo -S S-1-22-1-30000)
if test 0$uid_for_sid -ne 30000; then
echo "S-1-22-1-30000 mapped to $uid_for_sid, not 30000"
echo "failure: wbinfo -S check for sane mapping"
failed=`expr $failed + 1`
failed=$(expr $failed + 1)
else
echo "success: wbinfo -S check for sane mapping"
fi
testfail "wbinfo -S against $TARGET using invalid SID" $wbinfo -S "S-1-22-2-30000" && failed=`expr $failed + 1`
testfail "wbinfo -S against $TARGET using invalid SID" $wbinfo -S "S-1-22-2-30000" && failed=$(expr $failed + 1)
testit "wbinfo -Y against $TARGET" $wbinfo -Y "S-1-22-2-30000" || failed=`expr $failed + 1`
testit "wbinfo -Y against $TARGET" $wbinfo -Y "S-1-22-2-30000" || failed=$(expr $failed + 1)
echo "test: wbinfo -Y check for sane mapping"
gid_for_sid=`$wbinfo -Y S-1-22-2-30000`
gid_for_sid=$($wbinfo -Y S-1-22-2-30000)
if test 0$gid_for_sid -ne 30000; then
echo "S-1-22-2-30000 mapped to $gid_for_sid, not 30000"
echo "failure: wbinfo -Y check for sane mapping"
failed=`expr $failed + 1`
failed=$(expr $failed + 1)
else
echo "success: wbinfo -Y check for sane mapping"
fi
testfail "wbinfo -Y against $TARGET using invalid SID" $wbinfo -Y "S-1-22-1-30000" && failed=`expr $failed + 1`
testfail "wbinfo -Y against $TARGET using invalid SID" $wbinfo -Y "S-1-22-1-30000" && failed=$(expr $failed + 1)
testit "wbinfo -t against $TARGET" $wbinfo -t || failed=`expr $failed + 1`
testit "wbinfo -t against $TARGET" $wbinfo -t || failed=$(expr $failed + 1)
#didn't really work anyway
testit "wbinfo --trusted-domains against $TARGET" $wbinfo --trusted-domains || failed=`expr $failed + 1`
testit "wbinfo --all-domains against $TARGET" $wbinfo --all-domains || failed=`expr $failed + 1`
testit "wbinfo --trusted-domains against $TARGET" $wbinfo --trusted-domains || failed=$(expr $failed + 1)
testit "wbinfo --all-domains against $TARGET" $wbinfo --all-domains || failed=$(expr $failed + 1)
testit "wbinfo --own-domain against $TARGET" $wbinfo --own-domain || failed=`expr $failed + 1`
testit "wbinfo --own-domain against $TARGET" $wbinfo --own-domain || failed=$(expr $failed + 1)
echo "test: wbinfo --own-domain against $TARGET check output"
own_domain=`$wbinfo --own-domain`
own_domain=$($wbinfo --own-domain)
if test x$own_domain = x$DOMAIN; then
echo "success: wbinfo --own-domain against $TARGET check output"
else
echo "Own domain reported as $own_domain instead of $DOMAIN"
echo "failure: wbinfo --own-domain against $TARGET check output"
failed=`expr $failed + 1`
failed=$(expr $failed + 1)
fi
# this does not work
knownfail "wbinfo --sequence against $TARGET" $wbinfo --sequence
# this is stubbed out now
testit "wbinfo -D against $TARGET" $wbinfo -D $DOMAIN || failed=`expr $failed + 1`
testit "wbinfo -D against $TARGET" $wbinfo -D $DOMAIN || failed=$(expr $failed + 1)
testit "wbinfo -i against $TARGET" $wbinfo -i "$DOMAIN/$USERNAME" || failed=`expr $failed + 1`
testit "wbinfo -i against $TARGET" $wbinfo -i "$DOMAIN/$USERNAME" || failed=$(expr $failed + 1)
echo "test: wbinfo --group-info against $TARGET"
gid=`$wbinfo --group-info "$DOMAIN/Domain users" | cut -d: -f3`
gid=$($wbinfo --group-info "$DOMAIN/Domain users" | cut -d: -f3)
if test x$? = x0; then
echo "success: wbinfo --group-info against $TARGET"
else
echo "failure: wbinfo --group-info against $TARGET"
failed=`expr $failed + 1`
failed=$(expr $failed + 1)
fi
test_name="wbinfo -i against $TARGET"
subunit_start_test "$test_name"
passwd_line=`$wbinfo -i "$DOMAIN/$USERNAME"`
passwd_line=$($wbinfo -i "$DOMAIN/$USERNAME")
if test x$? = x0; then
subunit_pass_test "$test_name"
else
subunit_fail_test "$test_name"
failed=`expr $failed + 1`
failed=$(expr $failed + 1)
fi
test_name="confirm output of wbinfo -i against $TARGET"
@ -260,17 +262,17 @@ if test "x$passwd_line" = "x$expected1_line" -o "x$passwd_line" = "x$expected2_l
subunit_pass_test "$test_name"
else
echo "expected '$expected1_line' or '$expected2_line' got '$passwd_line'" | subunit_fail_test "$test_name"
failed=`expr $failed + 1`
failed=$(expr $failed + 1)
fi
test_name="wbinfo --uid-info against $TARGET"
subunit_start_test "$test_name"
passwd_line=`$wbinfo --uid-info=$admin_uid`
passwd_line=$($wbinfo --uid-info=$admin_uid)
if test x$? = x0; then
subunit_pass_test "$test_name"
else
subunit_fail_test "$test_name"
failed=`expr $failed + 1`
failed=$(expr $failed + 1)
fi
test_name="confirm output of wbinfo --uid-info against $TARGET"
@ -279,38 +281,38 @@ if test "x$passwd_line" = "x$expected1_line" -o "x$passwd_line" = "x$expected2_l
subunit_pass_test "$test_name"
else
echo "expected '$expected1_line' or '$expected2_line' got '$passwd_line'" | subunit_fail_test "$test_name"
failed=`expr $failed + 1`
failed=$(expr $failed + 1)
fi
testfail "wbinfo --group-info against $TARGET with $USERNAME" $wbinfo --group-info $USERNAME && failed=`expr $failed + 1`
testfail "wbinfo --group-info against $TARGET with $USERNAME" $wbinfo --group-info $USERNAME && failed=$(expr $failed + 1)
testit "wbinfo --gid-info against $TARGET" $wbinfo --gid-info $gid || failed=`expr $failed + 1`
testit "wbinfo --gid-info against $TARGET" $wbinfo --gid-info $gid || failed=$(expr $failed + 1)
testit "wbinfo -r against $TARGET" $wbinfo -r "$DOMAIN/$USERNAME" || failed=`expr $failed + 1`
testit "wbinfo -r against $TARGET" $wbinfo -r "$DOMAIN/$USERNAME" || failed=$(expr $failed + 1)
testit "wbinfo --user-domgroups against $TARGET" $wbinfo --user-domgroups $admin_sid || failed=`expr $failed + 1`
testit "wbinfo --user-domgroups against $TARGET" $wbinfo --user-domgroups $admin_sid || failed=$(expr $failed + 1)
testit "wbinfo --user-sids against $TARGET" $wbinfo --user-sids $admin_sid || failed=`expr $failed + 1`
testit "wbinfo --user-sids against $TARGET" $wbinfo --user-sids $admin_sid || failed=$(expr $failed + 1)
testit "wbinfo -a against $TARGET with domain creds" $wbinfo -a "$DOMAIN/$USERNAME"%"$PASSWORD" || failed=`expr $failed + 1`
testit "wbinfo -a against $TARGET with domain creds" $wbinfo -a "$DOMAIN/$USERNAME"%"$PASSWORD" || failed=$(expr $failed + 1)
testit "wbinfo --getdcname against $TARGET" $wbinfo --getdcname=$DOMAIN
testit "wbinfo -p against $TARGET" $wbinfo -p || failed=`expr $failed + 1`
testit "wbinfo -p against $TARGET" $wbinfo -p || failed=$(expr $failed + 1)
testit "wbinfo -K against $TARGET with domain creds" $wbinfo --krb5ccname=$KRB5CCNAME --krb5auth="$DOMAIN/$USERNAME"%"$PASSWORD" || failed=`expr $failed + 1`
testit "wbinfo -K against $TARGET with domain creds" $wbinfo --krb5ccname=$KRB5CCNAME --krb5auth="$DOMAIN/$USERNAME"%"$PASSWORD" || failed=$(expr $failed + 1)
testit "wbinfo --separator against $TARGET" $wbinfo --separator || failed=`expr $failed + 1`
testit "wbinfo --separator against $TARGET" $wbinfo --separator || failed=$(expr $failed + 1)
if test "$TARGET" = "ad_member"; then
testit "wbinfo --domain-info=$DOMAIN" $wbinfo --domain-info=$DOMAIN || failed=`expr $failed + 1`
testit "wbinfo --domain-info=$DOMAIN" $wbinfo --domain-info=$DOMAIN || failed=$(expr $failed + 1)
testit "wbinfo --dc-info=$DOMAIN" $wbinfo --dc-info=$DOMAIN || failed=`expr $failed + 1`
testit "wbinfo --dc-info=$DOMAIN" $wbinfo --dc-info=$DOMAIN || failed=$(expr $failed + 1)
fi
testit_expect_failure "wbinfo -a against $TARGET with invalid password" $wbinfo -a "$DOMAIN/$USERNAME%InvalidPassword" && failed=`expr $failed + 1`
testit_expect_failure "wbinfo -a against $TARGET with invalid password" $wbinfo -a "$DOMAIN/$USERNAME%InvalidPassword" && failed=$(expr $failed + 1)
testit_expect_failure "wbinfo -K against $TARGET with invalid password" $wbinfo -K "$DOMAIN/$USERNAME%InvalidPassword" && failed=`expr $failed + 1`
testit_expect_failure "wbinfo -K against $TARGET with invalid password" $wbinfo -K "$DOMAIN/$USERNAME%InvalidPassword" && failed=$(expr $failed + 1)
rm -f $KRB5CCNAME_PATH

View File

@ -1,10 +1,10 @@
#!/bin/sh
# Blackbox test for wbinfo name lookup
if [ $# -lt 3 ]; then
cat <<EOF
cat <<EOF
Usage: test_wbinfo.sh DOMAIN REALM DC_USERNAME
EOF
exit 1;
exit 1
fi
DOMAIN=$1
@ -16,23 +16,23 @@ failed=0
sambabindir="$BINDIR"
wbinfo="$VALGRIND $sambabindir/wbinfo"
. `dirname $0`/../../testprogs/blackbox/subunit.sh
. $(dirname $0)/../../testprogs/blackbox/subunit.sh
# Correct query is expected to work
testit "name-to-sid.single-separator" \
$wbinfo -n $DOMAIN/$DC_USERNAME || \
$wbinfo -n $DOMAIN/$DC_USERNAME ||
failed=$(expr $failed + 1)
testit "name-to-sid.at_domain" \
$wbinfo -n $DOMAIN/ || \
$wbinfo -n $DOMAIN/ ||
failed=$(expr $failed + 1)
testit "name-to-sid.upn" \
$wbinfo -n $DC_USERNAME@$REALM || \
$wbinfo -n $DC_USERNAME@$REALM ||
failed=$(expr $failed + 1)
testit "name-to-sid.realm-user" \
$wbinfo -n $REALM/$DC_USERNAME || \
$wbinfo -n $REALM/$DC_USERNAME ||
failed=$(expr $failed + 1)
# For the name-to-sid.realm-user query, ensure
@ -43,22 +43,22 @@ out=$($wbinfo -s $sid | sed -e 's/ .//')
# winbindd returns usernames in lowercase
lcuser=$(echo $DC_USERNAME | tr A-Z a-z)
testit "Verify DOMAIN/USER output" \
test "$out" = "$DOMAIN/$lcuser" || \
test "$out" = "$DOMAIN/$lcuser" ||
failed=$(expr $failed + 1)
# Two separator characters should fail
testit_expect_failure "name-to-sid.double-separator" \
$wbinfo -n $DOMAIN//$DC_USERNAME || \
$wbinfo -n $DOMAIN//$DC_USERNAME ||
failed=$(expr $failed + 1)
# Invalid domain is expected to fail
testit_expect_failure "name-to-sid.invalid-domain" \
$wbinfo -n INVALID/$DC_USERNAME || \
$wbinfo -n INVALID/$DC_USERNAME ||
failed=$(expr $failed + 1)
# Invalid domain with two separator characters is expected to fail
testit_expect_failure "name-to-sid.double-separator-invalid-domain" \
$wbinfo -n INVALID//$DC_USERNAME || \
$wbinfo -n INVALID//$DC_USERNAME ||
failed=$(expr $failed + 1)
exit $failed

View File

@ -1,6 +1,6 @@
#!/bin/sh
incdir=`dirname $0`/../../testprogs/blackbox
incdir=$(dirname $0)/../../testprogs/blackbox
. $incdir/subunit.sh
#
@ -9,7 +9,7 @@ incdir=`dirname $0`/../../testprogs/blackbox
#
wbinfo_some_mapped()
{
output=`$VALGRIND $BINDIR/wbinfo --sids-to-unix-ids=S-1-5-123456789,S-1-5-11`
output=$($VALGRIND $BINDIR/wbinfo --sids-to-unix-ids=S-1-5-123456789,S-1-5-11)
test x"$?" = x"0" || {
return 1
}
@ -27,6 +27,6 @@ wbinfo_some_mapped()
return 0
}
testit "wbinfo some mapped" wbinfo_some_mapped || failed=`expr $failed + 1`
testit "wbinfo some mapped" wbinfo_some_mapped || failed=$(expr $failed + 1)
testok $0 $failed

View File

@ -1,15 +1,15 @@
#!/bin/sh
if [ $# -lt 1 ]; then
cat <<EOF
cat <<EOF
Usage: test_wbinfo_simple.sh <wbinfo args>
EOF
exit 1;
exit 1
fi
ADDARGS="$*"
incdir=`dirname $0`/../../testprogs/blackbox
incdir=$(dirname $0)/../../testprogs/blackbox
. $incdir/subunit.sh
KRB5CCNAME_PATH="$PREFIX/test_wbinfo_simple_krb5ccname"
@ -18,7 +18,7 @@ rm -f $KRB5CCNAME_PATH
KRB5CCNAME="FILE:$KRB5CCNAME_PATH"
export KRB5CCNAME
testit "wbinfo" $VALGRIND $BINDIR/wbinfo --krb5ccname="$KRB5CCNAME" $ADDARGS || failed=`expr $failed + 1`
testit "wbinfo" $VALGRIND $BINDIR/wbinfo --krb5ccname="$KRB5CCNAME" $ADDARGS || failed=$(expr $failed + 1)
rm -f $KRB5CCNAME_PATH

View File

@ -3,10 +3,10 @@
# Copyright (c) 2018 Andreas Schneider <asn@samba.org>
if [ $# -lt 6 ]; then
cat <<EOF
cat <<EOF
Usage: $(basename $0) DOMAIN REALM OWN_DOMAIN USERNAME1 UPN_NAME1 USERNAME2 UPN_NAME2 ENVNAME
EOF
exit 1;
exit 1
fi
DOMAIN=$1
@ -120,16 +120,16 @@ testit "getpwnam.domain.$DOMAIN.$USERNAME1" test_getpwnam "$DOMAIN/$USERNAME1" 0
testit "getpwnam.upn.$UPN_NAME1" test_getpwnam "$UPN1" 0 "$DOMAIN/$USERNAME1" || failed=$(expr $failed + 1)
case ${ENVNAME} in
ad_member*)
ad_member*)
# We should not be able to lookup the user just by the name
test_ret=2
test_output=""
;;
fl2008r2dc*)
fl2008r2dc*)
test_ret=0
test_output="$OWN_DOMAIN/$USERNAME1"
;;
*)
*)
test_ret=0
test_output="$DOMAIN/$USERNAME1"
;;

View File

@ -3,10 +3,10 @@
# Copyright (c) 2020 Andreas Schneider <asn@samba.org>
if [ $# -lt 5 ]; then
cat <<EOF
cat <<EOF
Usage: $(basename $0) DOMAIN REALM USERNAME PASSWORD PRIMARY_GROUP
EOF
exit 1;
exit 1
fi
DOMAIN=$1