diff options
author | Andrew Bartlett <abartlet@samba.org> | 2001-11-29 06:21:56 +0000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2001-11-29 06:21:56 +0000 |
commit | fe64484824d8169bf66822ebf7f6a9180a238e6e (patch) | |
tree | dcb44452ab1e776819dd695df8063bda603c212c /source3/utils | |
parent | ff27a326f17223cba12b7e0b41ec84aad8238385 (diff) | |
download | samba-fe64484824d8169bf66822ebf7f6a9180a238e6e.tar.gz samba-fe64484824d8169bf66822ebf7f6a9180a238e6e.tar.bz2 samba-fe64484824d8169bf66822ebf7f6a9180a238e6e.zip |
Make better use of the ads_init() function to get the kerberos relam etc.
This allows us to use automagically obtained values in future, and the value
from krb5.conf now.
Also fix mem leaks etc.
Andrew Bartlett
(This used to be commit 8f9ce717819235d98a1463f20ac659cb4b4ebbd2)
Diffstat (limited to 'source3/utils')
-rw-r--r-- | source3/utils/net_ads.c | 1 | ||||
-rw-r--r-- | source3/utils/net_join.c | 13 |
2 files changed, 8 insertions, 6 deletions
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 345fc5c3db..1bfd5c637a 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -74,6 +74,7 @@ static int net_ads_user(int argc, const char **argv) } ads_dump(ads, res); + ads_destroy(&ads); return 0; } diff --git a/source3/utils/net_join.c b/source3/utils/net_join.c index 883ff3ffa6..7456e54364 100644 --- a/source3/utils/net_join.c +++ b/source3/utils/net_join.c @@ -76,7 +76,6 @@ int net_join(int argc, const char **argv) { char *ldap_host; char *hostname; - char *realm; ADS_STRUCT *ads; int rc; char *password; @@ -85,10 +84,7 @@ int net_join(int argc, const char **argv) hostname = strdup(global_myname); strlower(hostname); - realm = lp_realm(); - ldap_host = lp_ads_server(); if (!*ldap_host) ldap_host = NULL; - if (!*realm) realm = NULL; if (!secrets_init()) { DEBUG(1,("Failed to initialise secrets database\n")); @@ -97,33 +93,38 @@ int net_join(int argc, const char **argv) password = generate_random_password(15); - ads = ads_init(realm, ldap_host, NULL); + ads = ads_init(NULL, NULL, NULL); rc = ads_connect(ads); if (rc) { d_printf("ads_connect: %s\n", ads_errstr(rc)); + ads_destory(&ads); return -1; } rc = ads_join_realm(ads, hostname); if (rc) { d_printf("ads_join_realm: %s\n", ads_errstr(rc)); + ads_destory(&ads); return -1; } status = ads_set_machine_password(ads, hostname, password); if (!NT_STATUS_IS_OK(status)) { d_printf("ads_set_machine_password: %s\n", get_nt_error_msg(status)); + ads_destory(&ads); return -1; } if (!secrets_store_machine_password(password)) { DEBUG(1,("Failed to save machine password\n")); + ads_destory(&ads); return -1; } - d_printf("Joined %s to realm %s\n", hostname, realm); + d_printf("Joined %s to realm %s\n", hostname, ads->realm); + ads_destory(&ads); return 0; } |