From d42f08d16b95a7a5e0073577fe540c0923511a72 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 21 Feb 2022 11:20:53 +0100 Subject: [PATCH] nsswitch: Reformat shell scripts shfmt -f nsswitch/ | xargs shfmt -w -p -i 0 -fn Signed-off-by: Andreas Schneider Reviewed-by: Andrew Bartlett --- nsswitch/tests/test_idmap_ad.sh | 38 ++-- nsswitch/tests/test_idmap_nss.sh | 18 +- nsswitch/tests/test_idmap_rfc2307.sh | 82 +++---- nsswitch/tests/test_idmap_rid.sh | 86 +++---- nsswitch/tests/test_rfc2307_mapping.sh | 109 ++++----- nsswitch/tests/test_ticket_expiry.sh | 24 +- nsswitch/tests/test_wbinfo.sh | 210 +++++++++--------- nsswitch/tests/test_wbinfo_name_lookup.sh | 22 +- nsswitch/tests/test_wbinfo_sids_to_xids.sh | 6 +- nsswitch/tests/test_wbinfo_simple.sh | 8 +- nsswitch/tests/test_wbinfo_user_info.sh | 10 +- .../tests/test_wbinfo_user_info_cached.sh | 4 +- 12 files changed, 310 insertions(+), 307 deletions(-) diff --git a/nsswitch/tests/test_idmap_ad.sh b/nsswitch/tests/test_idmap_ad.sh index 8c641bdcf6d..323aa1728d0 100755 --- a/nsswitch/tests/test_idmap_ad.sh +++ b/nsswitch/tests/test_idmap_ad.sh @@ -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 < 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 <$PREFIX/tmpldbmodify < 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 <$PREFIX/tmpldbmodify < 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 diff --git a/nsswitch/tests/test_ticket_expiry.sh b/nsswitch/tests/test_ticket_expiry.sh index 3b98b0fe87a..f2fed5533da 100755 --- a/nsswitch/tests/test_ticket_expiry.sh +++ b/nsswitch/tests/test_ticket_expiry.sh @@ -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 diff --git a/nsswitch/tests/test_wbinfo.sh b/nsswitch/tests/test_wbinfo.sh index 2ac83828a0e..39d399f97e2 100755 --- a/nsswitch/tests/test_wbinfo.sh +++ b/nsswitch/tests/test_wbinfo.sh @@ -1,10 +1,10 @@ #!/bin/sh # Blackbox test for wbinfo if [ $# -lt 4 ]; then -cat < 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 diff --git a/nsswitch/tests/test_wbinfo_user_info.sh b/nsswitch/tests/test_wbinfo_user_info.sh index c699a30538f..b9a720d5c98 100755 --- a/nsswitch/tests/test_wbinfo_user_info.sh +++ b/nsswitch/tests/test_wbinfo_user_info.sh @@ -3,10 +3,10 @@ # Copyright (c) 2018 Andreas Schneider if [ $# -lt 6 ]; then -cat < if [ $# -lt 5 ]; then -cat <