diff options
author | Andrew Bartlett <abartlet@samba.org> | 2010-12-10 15:08:53 +1100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2010-12-10 17:58:13 +1100 |
commit | c2a1ad9047508cf2745a9019e6783c8b8f7ef475 (patch) | |
tree | 95419c42c1640746c2a791edd12af1cc599a70f3 | |
parent | 4408f8a0dec80c34dfe770cc2a81f2d4e074ba8a (diff) | |
download | samba-c2a1ad9047508cf2745a9019e6783c8b8f7ef475.tar.gz samba-c2a1ad9047508cf2745a9019e6783c8b8f7ef475.tar.bz2 samba-c2a1ad9047508cf2745a9019e6783c8b8f7ef475.zip |
s3-net Allow 'net ads dns register' to take an optional hostname argument
This allows the administrator to more carefully chose what name to register.
Andrew Bartlett
-rw-r--r-- | source3/utils/net_ads.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 1d617c057b..858830f3c1 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -1210,14 +1210,18 @@ done: return status; } -static NTSTATUS net_update_dns(TALLOC_CTX *mem_ctx, ADS_STRUCT *ads) +static NTSTATUS net_update_dns(TALLOC_CTX *mem_ctx, ADS_STRUCT *ads, const char *hostname) { int num_addrs; struct sockaddr_storage *iplist = NULL; fstring machine_name; NTSTATUS status; - name_to_fqdn( machine_name, global_myname() ); + if (hostname) { + fstrcpy(machine_name, hostname); + } else { + name_to_fqdn( machine_name, global_myname() ); + } strlower_m( machine_name ); /* Get our ip address (not the 127.0.0.x address but a real ip @@ -1408,7 +1412,7 @@ int net_ads_join(struct net_context *c, int argc, const char **argv) ads_kinit_password( ads_dns ); } - if ( !ads_dns || !NT_STATUS_IS_OK(net_update_dns( ctx, ads_dns )) ) { + if ( !ads_dns || !NT_STATUS_IS_OK(net_update_dns( ctx, ads_dns, NULL)) ) { d_fprintf( stderr, _("DNS update failed!\n") ); } @@ -1445,9 +1449,9 @@ static int net_ads_dns_register(struct net_context *c, int argc, const char **ar talloc_enable_leak_report(); #endif - if (argc > 0 || c->display_usage) { + if (argc > 1 || c->display_usage) { d_printf( "%s\n" - "net ads dns register\n" + "net ads dns register [hostname]\n" " %s\n", _("Usage:"), _("Register hostname with DNS\n")); @@ -1466,7 +1470,7 @@ static int net_ads_dns_register(struct net_context *c, int argc, const char **ar return -1; } - if ( !NT_STATUS_IS_OK(net_update_dns(ctx, ads)) ) { + if ( !NT_STATUS_IS_OK(net_update_dns(ctx, ads, argc == 1 ? argv[0] : NULL)) ) { d_fprintf( stderr, _("DNS update failed!\n") ); ads_destroy( &ads ); TALLOC_FREE( ctx ); |