summaryrefslogtreecommitdiff
path: root/source3/utils/net_ads.c
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2010-12-16 01:49:14 +0100
committerStefan Metzmacher <metze@samba.org>2010-12-17 15:59:47 +0100
commit5e83a05009787d8a2086db1adc1ed58d61b3725d (patch)
tree55c4d20915303fea09621c52df0ae133b8258d90 /source3/utils/net_ads.c
parent4d91f98b433e07922373bf4e3ba9668b7af71a00 (diff)
downloadsamba-5e83a05009787d8a2086db1adc1ed58d61b3725d.tar.gz
samba-5e83a05009787d8a2086db1adc1ed58d61b3725d.tar.bz2
samba-5e83a05009787d8a2086db1adc1ed58d61b3725d.zip
s3:net ads dns register: add support for specifying addresse on the commandline (bug #7871)
In the clustering case, this is also made the only possiblity to do dns updates, since the list addresses on the local interfaces is not suitable in that case. This fixes the "net ads dns register" part of bug #7871. It might be extended by a parsing of the "cluster addresses" setting. Signed-off-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source3/utils/net_ads.c')
-rw-r--r--source3/utils/net_ads.c43
1 files changed, 40 insertions, 3 deletions
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c
index 2d418c49e1..f5aeb49198 100644
--- a/source3/utils/net_ads.c
+++ b/source3/utils/net_ads.c
@@ -1490,15 +1490,27 @@ static int net_ads_dns_register(struct net_context *c, int argc, const char **ar
#if defined(WITH_DNS_UPDATES)
ADS_STRUCT *ads;
ADS_STATUS status;
+ NTSTATUS ntstatus;
TALLOC_CTX *ctx;
+ const char *hostname = NULL;
+ struct sockaddr_storage *addrs = NULL;
+ int num_addrs = 0;
+ int count;
#ifdef DEVELOPER
talloc_enable_leak_report();
#endif
- if (argc > 1 || c->display_usage) {
+ if (argc <= 1 && lp_clustering()) {
+ d_fprintf(stderr, _("Refusing DNS updates with automatic "
+ "detection of addresses in a clustered "
+ "setup.\n"));
+ c->display_usage = true;
+ }
+
+ if (c->display_usage) {
d_printf( "%s\n"
- "net ads dns register [hostname]\n"
+ "net ads dns register [hostname [IP [IP...]]]\n"
" %s\n",
_("Usage:"),
_("Register hostname with DNS\n"));
@@ -1510,6 +1522,30 @@ static int net_ads_dns_register(struct net_context *c, int argc, const char **ar
return -1;
}
+ if (argc >= 1) {
+ hostname = argv[0];
+ }
+
+ if (argc > 1) {
+ num_addrs = argc - 1;
+ addrs = talloc_zero_array(ctx, struct sockaddr_storage, num_addrs);
+ if (addrs == NULL) {
+ d_fprintf(stderr, _("Error allocating memory!\n"));
+ talloc_free(ctx);
+ return -1;
+ }
+ }
+
+ for (count = 0; count < num_addrs; count++) {
+ if (!interpret_string_addr(&addrs[count], argv[count+1], 0)) {
+ d_fprintf(stderr, "%s '%s'.\n",
+ _("Cannot interpret address"),
+ argv[count+1]);
+ talloc_free(ctx);
+ return -1;
+ }
+ }
+
status = ads_startup(c, true, &ads);
if ( !ADS_ERR_OK(status) ) {
DEBUG(1, ("error on ads_startup: %s\n", ads_errstr(status)));
@@ -1517,7 +1553,8 @@ 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, argc == 1 ? argv[0] : NULL)) ) {
+ ntstatus = net_update_dns_ext(ctx, ads, hostname, addrs, num_addrs);
+ if (!NT_STATUS_IS_OK(ntstatus)) {
d_fprintf( stderr, _("DNS update failed!\n") );
ads_destroy( &ads );
TALLOC_FREE( ctx );