summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2012-01-30 13:56:45 +0100
committerMichael Adam <obnox@samba.org>2012-01-31 17:00:30 +0100
commit63d9b5d75a435bbbc06aa8d00371a1c61b69acfb (patch)
tree752340eadaeeed50eca3026a05072d27f466e6f5
parent1d83f2118e0e9e1de02909247114ac18ce55a6be (diff)
downloadsamba-63d9b5d75a435bbbc06aa8d00371a1c61b69acfb.tar.gz
samba-63d9b5d75a435bbbc06aa8d00371a1c61b69acfb.tar.bz2
samba-63d9b5d75a435bbbc06aa8d00371a1c61b69acfb.zip
s3:net ads join: reduce indentation and improve logging in the dns update code block
by doing an early goto done upon error condition
-rw-r--r--source3/utils/net_ads.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c
index 9c3a0473c2..2a4b2ecec5 100644
--- a/source3/utils/net_ads.c
+++ b/source3/utils/net_ads.c
@@ -1467,22 +1467,26 @@ int net_ads_join(struct net_context *c, int argc, const char **argv)
ADS_STRUCT *ads_dns = NULL;
ads_dns = ads_init(lp_realm(), NULL, r->in.dc_name);
- if (ads_dns != NULL) {
- /* kinit with the machine password */
- use_in_memory_ccache();
- if (asprintf( &ads_dns->auth.user_name, "%s$", lp_netbios_name()) == -1) {
- goto fail;
- }
- 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 );
- strupper_m(ads_dns->auth.realm );
- ads_kinit_password( ads_dns );
+ if (ads_dns == NULL) {
+ d_fprintf(stderr, _("DNS update failed: out of memory!\n"));
+ goto done;
}
- if ( !ads_dns || !NT_STATUS_IS_OK(net_update_dns( ctx, ads_dns, NULL)) ) {
- d_fprintf( stderr, _("DNS update failed!\n") );
+ /* kinit with the machine password */
+
+ use_in_memory_ccache();
+ if (asprintf( &ads_dns->auth.user_name, "%s$", lp_netbios_name()) == -1) {
+ goto fail;
+ }
+ 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);
+ strupper_m(ads_dns->auth.realm);
+ ads_kinit_password(ads_dns);
+
+ if (!NT_STATUS_IS_OK(net_update_dns( ctx, ads_dns, NULL))) {
+ d_fprintf( stderr, _("DNS update failed!\n"));
}
/* exit from this block using machine creds */