summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2012-01-30 14:00:12 +0100
committerMichael Adam <obnox@samba.org>2012-01-31 17:00:30 +0100
commit04fa9a389c6d027dc4defb2527550fda650c4a6b (patch)
treee32cc5f2b3c9eabadbedbf52373ce306db9bc793 /source3
parent63d9b5d75a435bbbc06aa8d00371a1c61b69acfb (diff)
downloadsamba-04fa9a389c6d027dc4defb2527550fda650c4a6b.tar.gz
samba-04fa9a389c6d027dc4defb2527550fda650c4a6b.tar.bz2
samba-04fa9a389c6d027dc4defb2527550fda650c4a6b.zip
s3:net ads join: untangle assignment from check, fix return code and improve error logging
only the dns update failed, not the join. Also do proper memory cleanup
Diffstat (limited to 'source3')
-rw-r--r--source3/utils/net_ads.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c
index 2a4b2ecec5..22486ea7fb 100644
--- a/source3/utils/net_ads.c
+++ b/source3/utils/net_ads.c
@@ -1465,6 +1465,7 @@ int net_ads_join(struct net_context *c, int argc, const char **argv)
if (r->out.domain_is_ad) {
/* We enter this block with user creds */
ADS_STRUCT *ads_dns = NULL;
+ int ret;
ads_dns = ads_init(lp_realm(), NULL, r->in.dc_name);
@@ -1476,9 +1477,13 @@ int net_ads_join(struct net_context *c, int argc, const char **argv)
/* kinit with the machine password */
use_in_memory_ccache();
- if (asprintf( &ads_dns->auth.user_name, "%s$", lp_netbios_name()) == -1) {
- goto fail;
+
+ ret = asprintf(&ads_dns->auth.user_name, "%s$", lp_netbios_name());
+ if (ret == -1) {
+ d_fprintf(stderr, _("DNS update failed: out of memory\n"));
+ goto dns_done;
}
+
ads_dns->auth.password = secrets_fetch_machine_password(
r->out.netbios_domain_name, NULL, NULL);
ads_dns->auth.realm = SMB_STRDUP(r->out.dns_domain_name);
@@ -1490,6 +1495,7 @@ int net_ads_join(struct net_context *c, int argc, const char **argv)
}
/* exit from this block using machine creds */
+dns_done:
ads_destroy(&ads_dns);
}