From df1da96d7f9a11ee1029c1bb55a40255ea63267c Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox@samba.org>
Date: Wed, 6 Jan 2016 11:04:16 +0100
Subject: [PATCH] PATCHSET35 net: add option --no-dns-updates for net ads join

If called with this option, 'net ads join' will not attempt
to perform dns updates.

Backported for Samba 3.6 from master patches:

 ae81a40b1193ef93add61666ace6fff1a1e0676a
 d7a617f2f00c4a2b5294523fa651915c85de0d8b

Signed-off-by: Michael Adam <obnox@samba.org>
---
 docs-xml/manpages-3/net.8.xml | 9 ++++++++-
 source3/utils/net.c           | 2 ++
 source3/utils/net.h           | 2 ++
 source3/utils/net_ads.c       | 6 +++++-
 4 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/docs-xml/manpages-3/net.8.xml b/docs-xml/manpages-3/net.8.xml
index 65f1272..cff3594 100644
--- a/docs-xml/manpages-3/net.8.xml
+++ b/docs-xml/manpages-3/net.8.xml
@@ -135,6 +135,13 @@
 		</para></listitem>
 		</varlistentry>
 
+		<varlistentry>
+		<term>--no-dns-updates</term>
+		<listitem><para>Do not perform DNS updates as part of
+		"net ads join".
+		</para></listitem>
+		</varlistentry>
+
 		&stdarg.server.debug;
 	</variablelist>
 </refsect1>
@@ -194,7 +201,7 @@ the remote server using <command>/bin/date</command>. </para>
 </refsect2>
 
 <refsect2>
-<title>[RPC|ADS] JOIN [TYPE] [-U username[%password]] [createupn=UPN] [createcomputer=OU] [options]</title>
+<title>[RPC|ADS] JOIN [TYPE] [--no-dns-updates] [-U username[%password]] [createupn=UPN] [createcomputer=OU] [options]</title>
 
 <para>
 Join a domain.  If the account already exists on the server, and 
diff --git a/source3/utils/net.c b/source3/utils/net.c
index c53b285..3a95f7e 100644
--- a/source3/utils/net.c
+++ b/source3/utils/net.c
@@ -820,6 +820,8 @@ static struct functable net_func[] = {
 		{"lock", 0, POPT_ARG_NONE,   &c->opt_lock},
 		{"auto", 'a', POPT_ARG_NONE,   &c->opt_auto},
 		{"repair", 0, POPT_ARG_NONE,   &c->opt_repair},
+		/* Options for 'net ads join' */
+		{"no-dns-updates", 0, POPT_ARG_NONE, &c->opt_no_dns_updates},
 		POPT_COMMON_SAMBA
 		{ 0, 0, 0, 0}
 	};
diff --git a/source3/utils/net.h b/source3/utils/net.h
index 1d1559f..adddf34 100644
--- a/source3/utils/net.h
+++ b/source3/utils/net.h
@@ -81,6 +81,8 @@ struct net_context {
 	int opt_auto;
 	int opt_repair;
 
+	int opt_no_dns_updates;
+
 	int opt_have_ip;
 	struct sockaddr_storage opt_dest_ip;
 	bool smb_encrypt;
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c
index 816349d..5c541f3 100644
--- a/source3/utils/net_ads.c
+++ b/source3/utils/net_ads.c
@@ -1296,7 +1296,7 @@ static NTSTATUS net_update_dns(struct net_context *c, TALLOC_CTX *mem_ctx, ADS_S
 
 static int net_ads_join_usage(struct net_context *c, int argc, const char **argv)
 {
-	d_printf(_("net ads join [options]\n"
+	d_printf(_("net ads join [--no-dns-updates] [options]\n"
 	           "Valid options:\n"));
 	d_printf(_("   createupn[=UPN]    Set the userPrincipalName attribute during the join.\n"
 		   "                      The deault UPN is in the form host/netbiosname@REALM.\n"));
@@ -1455,6 +1455,10 @@ int net_ads_join(struct net_context *c, int argc, const char **argv)
 	}
 
 #if defined(WITH_DNS_UPDATES)
+	if (c->opt_no_dns_updates) {
+		goto done;
+	}
+
 	/*
 	 * In a clustered environment, don't do dynamic dns updates:
 	 * Registering the set of ip addresses that are assigned to
-- 
2.5.0

