summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/utils/net_ads.c16
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 );