From bce7e8c8e11321d98a30a8b6bb79a392a5e644ba Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 10 Dec 2010 15:08:53 +1100 Subject: [PATCH] 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 (cherry picked from commit c2a1ad9047508cf2745a9019e6783c8b8f7ef475) (cherry picked from commit 10c5a59315ef69eeb4d8bc19237de9787284a63d) Signed-off-by: Stefan Metzmacher --- source3/utils/net_ads.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index b618ab81b91..6b354ed66f5 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -1197,14 +1197,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 @@ -1394,7 +1398,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") ); } @@ -1431,9 +1435,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")); @@ -1452,7 +1456,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 ); -- 2.34.1