From: Michael Adam Date: Wed, 15 Dec 2010 23:52:41 +0000 (+0100) Subject: s3:net: add net_update_dns_ext() that accepts a list of addresses as parameter (bug... X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=ed914296df896a3805c8c6b74ad8bd9e1dcac35b;p=samba.git s3:net: add net_update_dns_ext() that accepts a list of addresses as parameter (bug# 7871) 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 (cherry picked from commit 4d91f98b433e07922373bf4e3ba9668b7af71a00) (cherry picked from commit 4b7775500b1055acf62decbc0fc8283b088da452) --- diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 8c04eda7888..75b115e28bc 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -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