summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2008-02-28 13:04:30 +0100
committerGünther Deschner <gd@samba.org>2008-02-28 13:04:30 +0100
commitbbe6d400e7bbc0089c8158a49a5d8d0b5717125f (patch)
treebb0967cc8d5c3f30e0ecf2ebe0973349e464d2b9 /source3/utils
parentb9ca5bf0a12f40030bbbe6a5c881cc4a035ed68d (diff)
downloadsamba-bbe6d400e7bbc0089c8158a49a5d8d0b5717125f.tar.gz
samba-bbe6d400e7bbc0089c8158a49a5d8d0b5717125f.tar.bz2
samba-bbe6d400e7bbc0089c8158a49a5d8d0b5717125f.zip
Re-arrange dns update block during "net ads join" a little.
Guenther (This used to be commit 5d30e9f9fef98de7764ae53d3cbe659b78ae9fce)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/net_ads.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c
index 8cf76ecbb6..daddbfae73 100644
--- a/source3/utils/net_ads.c
+++ b/source3/utils/net_ads.c
@@ -1645,34 +1645,36 @@ int net_ads_join(int argc, const char **argv)
DEBUG(1,("Error creating host keytab!\n"));
}
-#if defined(WITH_DNS_UPDATES)
- /* We enter this block with user creds */
+ d_printf("Joined '%s' to realm '%s'\n", global_myname(), ads->server.realm);
+
ads_kdestroy( NULL );
ads_destroy(&ads);
- ads = NULL;
- if ( (ads = ads_init( lp_realm(), NULL, NULL )) != NULL ) {
- /* kinit with the machine password */
+#if defined(WITH_DNS_UPDATES)
+ {
+ /* We enter this block with user creds */
+ ADS_STRUCT *ads_dns = NULL;
+
+ if ( (ads_dns = ads_init( lp_realm(), NULL, NULL )) != NULL ) {
+ /* kinit with the machine password */
+
+ use_in_memory_ccache();
+ asprintf( &ads_dns->auth.user_name, "%s$", global_myname() );
+ ads_dns->auth.password = secrets_fetch_machine_password(
+ lp_workgroup(), NULL, NULL );
+ ads_dns->auth.realm = SMB_STRDUP( lp_realm() );
+ ads_kinit_password( ads_dns );
+ }
- use_in_memory_ccache();
- asprintf( &ads->auth.user_name, "%s$", global_myname() );
- ads->auth.password = secrets_fetch_machine_password(
- lp_workgroup(), NULL, NULL );
- ads->auth.realm = SMB_STRDUP( lp_realm() );
- ads_kinit_password( ads );
- }
+ if ( !ads_dns || !NT_STATUS_IS_OK(net_update_dns( ctx, ads_dns )) ) {
+ d_fprintf( stderr, "DNS update failed!\n" );
+ }
- if ( !ads || !NT_STATUS_IS_OK(net_update_dns( ctx, ads )) ) {
- d_fprintf( stderr, "DNS update failed!\n" );
+ /* exit from this block using machine creds */
+ ads_destroy(&ads_dns);
}
-
- /* exit from this block using machine creds */
#endif
-
- d_printf("Joined '%s' to realm '%s'\n", global_myname(), ads->server.realm);
-
TALLOC_FREE( ctx );
- ads_destroy(&ads);
return 0;