diff options
author | Michael Adam <obnox@samba.org> | 2012-01-31 01:05:14 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2012-01-31 17:00:30 +0100 |
commit | be312e76d2b27674c5e38b760ca6521052caa460 (patch) | |
tree | 03df3985e861784875853557f10899f804f44789 /source3 | |
parent | 7e5c5bdcc46b55c5890d755601fe5278557d0948 (diff) | |
download | samba-be312e76d2b27674c5e38b760ca6521052caa460.tar.gz samba-be312e76d2b27674c5e38b760ca6521052caa460.tar.bz2 samba-be312e76d2b27674c5e38b760ca6521052caa460.zip |
s3:net ads join: reduce indentation in _net_ads_join_dns_updates()
Diffstat (limited to 'source3')
-rw-r--r-- | source3/utils/net_ads.c | 93 |
1 files changed, 47 insertions, 46 deletions
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index c52dfb9bf9..09235051e9 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -1309,6 +1309,10 @@ static int net_ads_join_usage(struct net_context *c, int argc, const char **argv static void _net_ads_join_dns_updates(TALLOC_CTX *ctx, struct libnet_JoinCtx *r) { #if defined(WITH_DNS_UPDATES) + ADS_STRUCT *ads_dns = NULL; + int ret; + NTSTATUS status; + /* * In a clustered environment, don't do dynamic dns updates: * Registering the set of ip addresses that are assigned to @@ -1323,67 +1327,64 @@ static void _net_ads_join_dns_updates(TALLOC_CTX *ctx, struct libnet_JoinCtx *r) if (lp_clustering()) { d_fprintf(stderr, _("Not doing automatic DNS update in a " "clustered setup.\n")); - goto done; + return; } - if (r->out.domain_is_ad) { - /* - * We enter this block with user creds. - * kinit with the machine password to do dns update. - */ - ADS_STRUCT *ads_dns = NULL; - int ret; - NTSTATUS status; + if (!r->out.domain_is_ad) { + return; + } - ads_dns = ads_init(lp_realm(), NULL, r->in.dc_name); + /* + * We enter this block with user creds. + * kinit with the machine password to do dns update. + */ - if (ads_dns == NULL) { - d_fprintf(stderr, _("DNS update failed: out of memory!\n")); - goto done; - } + ads_dns = ads_init(lp_realm(), NULL, r->in.dc_name); - use_in_memory_ccache(); + if (ads_dns == NULL) { + d_fprintf(stderr, _("DNS update failed: out of memory!\n")); + goto done; + } - 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; - } + use_in_memory_ccache(); - ads_dns->auth.password = secrets_fetch_machine_password( - r->out.netbios_domain_name, NULL, NULL); - if (ads_dns->auth.password == NULL) { - d_fprintf(stderr, _("DNS update failed: out of memory\n")); - goto dns_done; - } + 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 done; + } - ads_dns->auth.realm = SMB_STRDUP(r->out.dns_domain_name); - if (ads_dns->auth.realm == NULL) { - 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); + if (ads_dns->auth.password == NULL) { + d_fprintf(stderr, _("DNS update failed: out of memory\n")); + goto done; + } - strupper_m(ads_dns->auth.realm); + ads_dns->auth.realm = SMB_STRDUP(r->out.dns_domain_name); + if (ads_dns->auth.realm == NULL) { + d_fprintf(stderr, _("DNS update failed: out of memory\n")); + goto done; + } - ret = ads_kinit_password(ads_dns); - if (ret != 0) { - d_fprintf(stderr, - _("DNS update failed: kinit failed: %s\n"), - error_message(ret)); - goto dns_done; - } + strupper_m(ads_dns->auth.realm); - status = net_update_dns(ctx, ads_dns, NULL); - if (!NT_STATUS_IS_OK(status)) { - d_fprintf( stderr, _("DNS update failed: %s\n"), - nt_errstr(status)); - } + ret = ads_kinit_password(ads_dns); + if (ret != 0) { + d_fprintf(stderr, + _("DNS update failed: kinit failed: %s\n"), + error_message(ret)); + goto done; + } -dns_done: - ads_destroy(&ads_dns); + status = net_update_dns(ctx, ads_dns, NULL); + if (!NT_STATUS_IS_OK(status)) { + d_fprintf( stderr, _("DNS update failed: %s\n"), + nt_errstr(status)); } done: + ads_destroy(&ads_dns); #endif return; |