s3:net: add net_update_dns_ext() that accepts a list of addresses as parameter (bug...
authorMichael Adam <obnox@samba.org>
Wed, 15 Dec 2010 23:52:41 +0000 (00:52 +0100)
committerKarolin Seeger <kseeger@samba.org>
Sat, 5 Mar 2011 13:34:44 +0000 (14:34 +0100)
This generalized form of net_update_dns() will be used to
add support for specifying a list of addresses on the commandline
of "net ads dns register".

This prepares the "net ads dns register" part of the fix for bug #7871.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit 4d91f98b433e07922373bf4e3ba9668b7af71a00)
(cherry picked from commit 4b7775500b1055acf62decbc0fc8283b088da452)
(cherry picked from commit ed914296df896a3805c8c6b74ad8bd9e1dcac35b)

source3/utils/net_ads.c

index 8c04eda788882617a4418ef25e4aadbd28851080..75b115e28bcd63590cb95e2b3f92c8b966bb8500 100644 (file)
@@ -1197,10 +1197,12 @@ done:
        return status;
 }
 
-static NTSTATUS net_update_dns(TALLOC_CTX *mem_ctx, ADS_STRUCT *ads, const char *hostname)
+static NTSTATUS net_update_dns_ext(TALLOC_CTX *mem_ctx, ADS_STRUCT *ads,
+                                  const char *hostname,
+                                  struct sockaddr_storage *iplist,
+                                  int num_addrs)
 {
-       int num_addrs;
-       struct sockaddr_storage *iplist = NULL;
+       struct sockaddr_storage *iplist_alloc = NULL;
        fstring machine_name;
        NTSTATUS status;
 
@@ -1211,19 +1213,32 @@ static NTSTATUS net_update_dns(TALLOC_CTX *mem_ctx, ADS_STRUCT *ads, const char
        }
        strlower_m( machine_name );
 
-       /* Get our ip address (not the 127.0.0.x address but a real ip
-        * address) */
-
-       num_addrs = get_my_ip_address( &iplist );
-       if ( num_addrs <= 0 ) {
-               DEBUG(4,("net_update_dns: Failed to find my non-loopback IP "
-                        "addresses!\n"));
-               return NT_STATUS_INVALID_PARAMETER;
+       if (num_addrs == 0 || iplist == NULL) {
+               /*
+                * Get our ip address
+                * (not the 127.0.0.x address but a real ip address)
+                */
+               num_addrs = get_my_ip_address(&iplist_alloc);
+               if ( num_addrs <= 0 ) {
+                       DEBUG(4, ("net_update_dns_ext: Failed to find my "
+                                 "non-loopback IP addresses!\n"));
+                       return NT_STATUS_INVALID_PARAMETER;
+               }
+               iplist = iplist_alloc;
        }
 
        status = net_update_dns_internal(mem_ctx, ads, machine_name,
                                         iplist, num_addrs);
-       SAFE_FREE( iplist );
+
+       SAFE_FREE(iplist_alloc);
+       return status;
+}
+
+static NTSTATUS net_update_dns(TALLOC_CTX *mem_ctx, ADS_STRUCT *ads, const char *hostname)
+{
+       NTSTATUS status;
+
+       status = net_update_dns_ext(mem_ctx, ads, hostname, NULL, 0);
        return status;
 }
 #endif