The branch, master has been updated via 8025467 s3:libads: Add net ads keep-account test via d881f0c s3:libads: Add net ads leave keep-account option from e3ce1a2 ctdb-docs: Update documentation for "ctdb event" command
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 8025467bb3d3ee6998ccbe5d054454e9b951d0bd Author: Justin Stephenson <jstep...@redhat.com> Date: Thu Jun 28 11:08:27 2018 -0400 s3:libads: Add net ads keep-account test Add test for the new --keep-account net ads leave operation BUG: https://bugzilla.samba.org/show_bug.cgi?id=13498 Signed-off-by: Justin Stephenson <jstep...@redhat.com> Reviewed-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Alexander Bokovoy <a...@samba.org> Autobuild-User(master): Andrew Bartlett <abart...@samba.org> Autobuild-Date(master): Mon Jul 30 10:22:59 CEST 2018 on sn-devel-144 commit d881f0c8a0ce2fc7cabf1966c5724e72c70d6694 Author: Justin Stephenson <jstep...@redhat.com> Date: Wed Jun 27 11:32:31 2018 -0400 s3:libads: Add net ads leave keep-account option Add the ability to leave the domain with --keep-account argument to avoid removal of the host machine account. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13498 Signed-off-by: Justin Stephenson <jstep...@redhat.com> Reviewed-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Alexander Bokovoy <a...@samba.org> ----------------------------------------------------------------------- Summary of changes: docs-xml/manpages/net.8.xml | 9 ++++++++- source3/libnet/libnet_join.c | 2 ++ source3/utils/net.c | 3 ++- source3/utils/net.h | 1 + source3/utils/net_ads.c | 9 +++++++-- testprogs/blackbox/test_net_ads.sh | 14 ++++++++++++++ 6 files changed, 34 insertions(+), 4 deletions(-) Changeset truncated at 500 lines: diff --git a/docs-xml/manpages/net.8.xml b/docs-xml/manpages/net.8.xml index 3154ee5..d2bcd24 100644 --- a/docs-xml/manpages/net.8.xml +++ b/docs-xml/manpages/net.8.xml @@ -377,6 +377,13 @@ </para></listitem> </varlistentry> + <varlistentry> + <term>--keep-account</term> + <listitem><para>Prevent the machine account removal as + part of "net ads leave". + </para></listitem> + </varlistentry> + &stdarg.encrypt; &popt.common.samba.client; @@ -1276,7 +1283,7 @@ against an NT4 Domain Controller. </refsect2> <refsect2> -<title>ADS LEAVE</title> +<title>ADS LEAVE [--keep-account]</title> <para>Make the remote host leave the domain it is part of. </para> diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index a9405e8..27fc513 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -2868,6 +2868,8 @@ static WERROR libnet_DomainUnjoin(TALLOC_CTX *mem_ctx, return ntstatus_to_werror(status); } + r->out.dns_domain_name = talloc_strdup(mem_ctx, + r->in.domain_name); r->out.disabled_machine_account = true; } diff --git a/source3/utils/net.c b/source3/utils/net.c index 44daa60..69564f6 100644 --- a/source3/utils/net.c +++ b/source3/utils/net.c @@ -971,8 +971,9 @@ static struct functable net_func[] = { {"wipe", 0, POPT_ARG_NONE, &c->opt_wipe}, /* Options for 'net registry import' */ {"precheck", 0, POPT_ARG_STRING, &c->opt_precheck}, - /* Options for 'net ads join' */ + /* Options for 'net ads join or leave' */ {"no-dns-updates", 0, POPT_ARG_NONE, &c->opt_no_dns_updates}, + {"keep-account", 0, POPT_ARG_NONE, &c->opt_keep_account}, POPT_COMMON_SAMBA { 0, 0, 0, 0} }; diff --git a/source3/utils/net.h b/source3/utils/net.h index d6dfeb6..5e70fd3 100644 --- a/source3/utils/net.h +++ b/source3/utils/net.h @@ -85,6 +85,7 @@ struct net_context { int opt_wipe; const char *opt_precheck; int opt_no_dns_updates; + int opt_keep_account; int opt_have_ip; struct sockaddr_storage opt_dest_ip; diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index ffa67d8..afe47da 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -964,7 +964,7 @@ static int net_ads_leave(struct net_context *c, int argc, const char **argv) if (c->display_usage) { d_printf( "%s\n" - "net ads leave\n" + "net ads leave [--keep-account]\n" " %s\n", _("Usage:"), _("Leave an AD domain")); @@ -1009,7 +1009,12 @@ static int net_ads_leave(struct net_context *c, int argc, const char **argv) WKSSVC_JOIN_FLAGS_ACCOUNT_DELETE really means "disable */ r->in.unjoin_flags = WKSSVC_JOIN_FLAGS_JOIN_TYPE | WKSSVC_JOIN_FLAGS_ACCOUNT_DELETE; - r->in.delete_machine_account = true; + if (c->opt_keep_account) { + r->in.delete_machine_account = false; + } else { + r->in.delete_machine_account = true; + } + r->in.msg_ctx = c->msg_ctx; werr = libnet_Unjoin(ctx, r); diff --git a/testprogs/blackbox/test_net_ads.sh b/testprogs/blackbox/test_net_ads.sh index f83ce01..d3c4de5 100755 --- a/testprogs/blackbox/test_net_ads.sh +++ b/testprogs/blackbox/test_net_ads.sh @@ -26,6 +26,11 @@ failed=0 net_tool="$BINDIR/net -s $BASEDIR/$WORKDIR/client.conf --option=security=ads" +ldbsearch="ldbsearch" +if [ -x "$BINDIR/ldbsearch" ]; then + ldbsearch="$BINDIR/ldbsearch" +fi + # Load test functions . `dirname $0`/subunit.sh @@ -181,6 +186,15 @@ testit_expect_failure "leave+invalid_server" $VALGRIND $net_tool ads leave -U$DC testit "testjoin user+password" $VALGRIND $net_tool ads testjoin -U$DC_USERNAME%$DC_PASSWORD || failed=`expr $failed + 1` +testit "leave+keep_account" $VALGRIND $net_tool ads leave -U$DC_USERNAME%$DC_PASSWORD --keep-account || failed=`expr $failed + 1` + +computers_ldb_ou="CN=Computers,DC=addom,DC=samba,DC=example,DC=com" +testit "ldb check for existence of machine account" $ldbsearch -U$DC_USERNAME%$DC_PASSWORD -H ldap://$SERVER.$REALM -s base -b "cn=$HOSTNAME,$computers_ldb_ou" || failed=`expr $failed + 1` + +testit "join" $VALGRIND $net_tool ads join -U$DC_USERNAME%$DC_PASSWORD || failed=`expr $failed + 1` + +testit "testjoin" $VALGRIND $net_tool ads testjoin || failed=`expr $failed + 1` + ##Goodbye... testit "leave" $VALGRIND $net_tool ads leave -U$DC_USERNAME%$DC_PASSWORD || failed=`expr $failed + 1` -- Samba Shared Repository