diff options
author | Michael Adam <obnox@samba.org> | 2010-12-16 00:52:41 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2010-12-17 15:59:44 +0100 |
commit | 4d91f98b433e07922373bf4e3ba9668b7af71a00 (patch) | |
tree | 539605370c6f337bff095c2513a5c61d07e7f3f8 /source3/utils | |
parent | b8f19df53e66bf0260b4ae6c49acea87ac379deb (diff) | |
download | samba-4d91f98b433e07922373bf4e3ba9668b7af71a00.tar.gz samba-4d91f98b433e07922373bf4e3ba9668b7af71a00.tar.bz2 samba-4d91f98b433e07922373bf4e3ba9668b7af71a00.zip |
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 <metze@samba.org>
Diffstat (limited to 'source3/utils')
-rw-r--r-- | source3/utils/net_ads.c | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 8f0d2fb815..2d418c49e1 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -1216,10 +1216,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; @@ -1230,19 +1232,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 |