From 0a8cf4f1c067754e3f9805f1365d43b8acdeb322 Mon Sep 17 00:00:00 2001 From: Samuel Cabrero Date: Mon, 4 Sep 2023 16:49:52 +0200 Subject: [PATCH] testprogs: Add net offlinejoin composeodj tests BUG: https://bugzilla.samba.org/show_bug.cgi?id=13577 Signed-off-by: Samuel Cabrero Reviewed-by: Andrew Bartlett Autobuild-User(master): Andrew Bartlett Autobuild-Date(master): Tue Sep 5 22:11:46 UTC 2023 on atb-devel-224 (cherry picked from commit f3c632e74ba100b455eeac66e8914b11d1d9b0a0) Autobuild-User(v4-18-test): Jule Anger Autobuild-Date(v4-18-test): Wed Nov 29 15:55:45 UTC 2023 on atb-devel-224 --- testprogs/blackbox/test_net_offline.sh | 88 ++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/testprogs/blackbox/test_net_offline.sh b/testprogs/blackbox/test_net_offline.sh index a3809b59e0a..f4a8026df62 100755 --- a/testprogs/blackbox/test_net_offline.sh +++ b/testprogs/blackbox/test_net_offline.sh @@ -27,6 +27,7 @@ cd $RUNDIR failed=0 net_tool="$BINDIR/net --configfile=$BASEDIR/$WORKDIR/client.conf --option=security=ads" +samba_texpect="$BINDIR/texpect" # Load test functions . $(dirname $0)/subunit.sh @@ -69,6 +70,93 @@ rm -f $ODJFILE testit "leave" $VALGRIND $net_tool ads leave -U$DC_USERNAME%$DC_PASSWORD || failed=$(expr $failed + 1) +test_compose_odj() { + local mode=$1 + local composeargv=() + + # Retrieve the necessary information to compose the ODJ blob + # The machine needs to be correctly joined at this point + local netbios_domain_name=$($net_tool ads lookup | awk -F': ' '/^Pre-Win2k Domain/ {print $2}') + local domain_sid=$($net_tool getdomainsid | awk -F': ' "/^SID for domain $netbios_domain_name/ {print \$2}") + local domain_guid=$($net_tool ads lookup | awk -F': ' '/^GUID/ {print $2}') + local forest_name=$($net_tool ads lookup | awk -F': ' '/^Forest/ {print $2}') + local dc_name=$($net_tool ads info | awk -F': ' '/^LDAP server name/ {print $2}') + local dc_address=$($net_tool ads info | awk -F': ' '/^LDAP server:/ {print $2}') + local ret=1 + local out="" + + composeargv=( \ + "domain_sid=${domain_sid}" \ + "domain_guid=${domain_guid}" \ + "forest_name=${forest_name}" \ + "-S ${dc_name}" \ + "-I ${dc_address}" \ + "savefile=${ODJFILE}" + ) + case $mode in + machacct) + cmd='$net_tool offlinejoin composeodj ${composeargv[@]} -P 2>&1' + out=$(eval $cmd) + ret=$? + ;; + stdinfd) + cmd='echo ${netbios} | $net_tool offlinejoin composeodj ${composeargv[@]} -U${netbios^^}\$ 2>&1' + out=$(PASSWD_FD=0 eval $cmd) + ret=$? + ;; + callback) + tmpfile=$BASEDIR/$WORKDIR/composeodj_password_script + cat >$tmpfile <