From bcd9794d64bbd0639ee6b44fbe62256301e171cf Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 23 Feb 2022 12:03:50 +0100 Subject: [PATCH] s4:setup: Reformat shell scripts MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit shfmt -f source4/setup/ | xargs shfmt -w -p -i 0 -fn Signed-off-by: Andreas Schneider Reviewed-by: Pavel Filipenský --- source4/setup/tests/blackbox_group.sh | 23 ++++--- source4/setup/tests/blackbox_newuser.sh | 7 +- source4/setup/tests/blackbox_provision.sh | 30 +++++---- source4/setup/tests/blackbox_s3upgrade.sh | 14 ++-- source4/setup/tests/blackbox_setpassword.sh | 6 +- source4/setup/tests/blackbox_spn.sh | 7 +- source4/setup/tests/blackbox_start_backup.sh | 66 +++++++++---------- .../tests/blackbox_supported_features.sh | 42 ++++++------ .../setup/tests/blackbox_upgradeprovision.sh | 59 +++++++++-------- source4/setup/tests/provision_fileperms.sh | 63 +++++++++--------- 10 files changed, 162 insertions(+), 155 deletions(-) diff --git a/source4/setup/tests/blackbox_group.sh b/source4/setup/tests/blackbox_group.sh index 5fa622ecb25..7a5b3147f11 100755 --- a/source4/setup/tests/blackbox_group.sh +++ b/source4/setup/tests/blackbox_group.sh @@ -1,17 +1,16 @@ #!/bin/sh if [ $# -lt 1 ]; then -cat < $PREFIX/simple-dc/etc/smb.conf +echo " " >$PREFIX/simple-dc/etc/smb.conf testit "simple-dc" $PYTHON $BINDIR/samba-tool domain provision --server-role="dc" --domain=FOO --realm=foo.example.com --domain-sid=S-1-5-21-4177067393-1453636373-93818738 --targetdir=$PREFIX/simple-dc --use-ntvfs #The rest of these tests are with no smb.conf file present @@ -35,7 +35,8 @@ testit "simple-standalone" $PYTHON $BINDIR/samba-tool domain provision --server- rm -rf $PREFIX/blank-dc testit "blank-dc" $PYTHON $BINDIR/samba-tool domain provision --server-role="dc" --domain=FOO --realm=foo.example.com --domain-sid=S-1-5-21-4177067393-1453636373-93818738 --targetdir=$PREFIX/blank-dc --blank --use-ntvfs -reprovision() { +reprovision() +{ $PYTHON $BINDIR/samba-tool domain provision --domain=FOO --realm=foo.example.com --targetdir="$PREFIX/simple-default" --use-ntvfs } @@ -44,29 +45,30 @@ testit "reprovision" reprovision V_2012_R2=69 V_2008_R2=47 -check_baseschema() { +check_baseschema() +{ ldbsearch="ldbsearch" if [ -x "$BINDIR/ldbsearch" ]; then - ldbsearch="$BINDIR/ldbsearch" + ldbsearch="$BINDIR/ldbsearch" fi base=$($ldbsearch -H $PREFIX/$1/private/sam.ldb --scope=base dn) - dom=$(echo "$base" | grep "dn: " | cut -d " " -f 2); + dom=$(echo "$base" | grep "dn: " | cut -d " " -f 2) if [ -z "$dom" ]; then - echo "Unexpected ldbsearch output: $base"; + echo "Unexpected ldbsearch output: $base" fi version=$($ldbsearch -H $PREFIX/$1/private/sam.ldb --scope=base \ - "objectVersion" -b "CN=SCHEMA,CN=CONFIGURATION,$dom"); - version_num=$(echo "$version" | grep "objectVersion: " | cut -d " " -f 2); + "objectVersion" -b "CN=SCHEMA,CN=CONFIGURATION,$dom") + version_num=$(echo "$version" | grep "objectVersion: " | cut -d " " -f 2) if [ "$version_num" -eq "$2" ]; then - return 0; + return 0 fi - echo "Fail: schema version $version_num != $2"; - return 1; + echo "Fail: schema version $version_num != $2" + return 1 } tname="schema version" diff --git a/source4/setup/tests/blackbox_s3upgrade.sh b/source4/setup/tests/blackbox_s3upgrade.sh index 3c0afe96744..908cb69b8df 100755 --- a/source4/setup/tests/blackbox_s3upgrade.sh +++ b/source4/setup/tests/blackbox_s3upgrade.sh @@ -1,13 +1,13 @@ #!/bin/sh if [ $# -lt 1 ]; then -cat < $PREFIX/samba3-upgrade/samba3/smb1.conf <$PREFIX/samba3-upgrade/samba3/smb1.conf < $PREFIX/samba3-upgrade/samba3/smb2.conf <$PREFIX/samba3-upgrade/samba3/smb2.conf < $PREFIX/samba3-upgrade/samba3/smb3.conf <$PREFIX/samba3-upgrade/samba3/smb3.conf <&1) - if [ $? -eq 0 ] ; then - echo "ERROR: Samba should not have started successfully" - return 1 - fi - - # check the reason we're failing is because prime_ldb_databases() is - # detecting that this is a backup DB (and not some other reason) - echo "$OUTPUT" | grep "failed to start: Database is a backup" + # start samba in interactive mode (if we don't, samba daemonizes and so the + # command's exit status is always zero (success), regardless of whether + # samba actually starts up or not). However, this means if this assertion + # were ever to fail (i.e. samba DOES startup from a backup file), then the + # test case would just hang. So we use a max-run-time of 5 secs so that + # samba will self-destruct in the bad case (max_runtime_handler() returns + # zero/success in this case, which allows us to tell the good case from the + # bad case). + OPTS="--maximum-runtime=5 -i" + + # redirect logs to stderr (which we'll then redirect to stdout so we can + # capture it in a bash variable) + OPTS="$OPTS --debug-stdout" + + # start samba and capture the debug output + OUTPUT=$($BINDIR/samba --configfile=$DBPATH/etc/smb.conf $OPTS 2>&1) + if [ $? -eq 0 ]; then + echo "ERROR: Samba should not have started successfully" + return 1 + fi + + # check the reason we're failing is because prime_ldb_databases() is + # detecting that this is a backup DB (and not some other reason) + echo "$OUTPUT" | grep "failed to start: Database is a backup" } # setup a DB and manually mark it as being a "backup" diff --git a/source4/setup/tests/blackbox_supported_features.sh b/source4/setup/tests/blackbox_supported_features.sh index e8c6a151c62..9861fbc3927 100755 --- a/source4/setup/tests/blackbox_supported_features.sh +++ b/source4/setup/tests/blackbox_supported_features.sh @@ -1,10 +1,10 @@ #!/bin/sh if [ $# -lt 1 ]; then -cat < $SMB_CONF +mkdir -p $(dirname $SMB_CONF) +echo "vfs objects = fake_acls xattr_tdb" >$SMB_CONF # provision a basic DC testit "basic-provision" $PYTHON $BINDIR/samba-tool domain provision --server-role="dc" --domain=FOO --realm=foo.example.com --targetdir=$TARGET_DIR --configfile=$SMB_CONF -- 2.34.1