selftest: make check password script more portable
authorStefan Metzmacher <metze@samba.org>
Tue, 5 Feb 2019 14:30:36 +0000 (15:30 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 11 Feb 2019 06:43:31 +0000 (07:43 +0100)
We should not rely on Linux specific sed options.

grep -q also works on FreeBSD (tested on FreeBSD 12).

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
selftest/checkpassword_arg1.sh [new file with mode: 0755]
selftest/target/Samba4.pm

diff --git a/selftest/checkpassword_arg1.sh b/selftest/checkpassword_arg1.sh
new file mode 100755 (executable)
index 0000000..9cb28ef
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+#
+
+set -e
+set -u
+
+INVALIDPW="$1"
+NEWPW=`cat -`
+
+echo -n "${NEWPW}" | grep -q "^${INVALIDPW}\$" && {
+       echo "Found invalid password" >&1
+       exit 1
+}
+
+exit 0
index 33c66848c562ba299c9479ac1c2bf64951b1b906..d8e066f6f4472d14599388ebef903c2c0bb27297 100755 (executable)
@@ -2173,7 +2173,7 @@ sub provision_chgdcpass($$)
        # (and also removes the default AD complexity checks)
        my $unacceptable_password = "widk3Dsle32jxdBdskldsk55klASKQ";
        my $extra_smb_conf = "
-       check password script = sed -e '/$unacceptable_password/{;q1}; /$unacceptable_password/!{q0}'
+       check password script = $self->{srcdir}/selftest/checkpassword_arg1.sh ${unacceptable_password}
        allow dcerpc auth level connect:lsarpc = yes
        dcesrv:max auth states = 8
 ";