summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2003-06-10 04:15:55 +0000
committerAndrew Tridgell <tridge@samba.org>2003-06-10 04:15:55 +0000
commit0d556758de08a450fe7a725acef9c73c76688d81 (patch)
treebc64122b0f156aa4eb8195d3791119d0ce2b0298 /source3/utils
parent057ec70b53c8cf97066fcc6f0673a28d9ccc15ab (diff)
downloadsamba-0d556758de08a450fe7a725acef9c73c76688d81.tar.gz
samba-0d556758de08a450fe7a725acef9c73c76688d81.tar.bz2
samba-0d556758de08a450fe7a725acef9c73c76688d81.zip
use lp_realm() to find the default realm for 'net ads password'
(This used to be commit 21d92802781ac224f569a990df3ec1070f0da434)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/net_ads.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c
index 5051f18188..9a824e2662 100644
--- a/source3/utils/net_ads.c
+++ b/source3/utils/net_ads.c
@@ -899,20 +899,34 @@ static int net_ads_password(int argc, const char **argv)
const char *auth_password = opt_password;
char *realm = NULL;
char *new_password = NULL;
- char *c;
- char *prompt;
+ char *c, *prompt;
+ const char *user;
ADS_STATUS ret;
+ if (opt_user_name == NULL || opt_password == NULL) {
+ d_printf("You must supply an administrator username/password\n");
+ return -1;
+ }
+
- if ((argc != 1) || (opt_user_name == NULL) ||
- (opt_password == NULL) || (strchr(opt_user_name, '@') == NULL) ||
- (strchr(argv[0], '@') == NULL)) {
- return net_ads_usage(argc, argv);
+ if (argc != 1) {
+ d_printf("ERROR: You must say which username to change password for\n");
+ return -1;
+ }
+
+ user = argv[0];
+ if (!strchr(user, '@')) {
+ asprintf(&c, "%s@%s", argv[0], lp_realm());
+ user = c;
}
use_in_memory_ccache();
c = strchr(auth_principal, '@');
- realm = ++c;
+ if (c) {
+ realm = ++c;
+ } else {
+ realm = lp_realm();
+ }
/* use the realm so we can eventually change passwords for users
in realms other than default */
@@ -927,12 +941,12 @@ static int net_ads_password(int argc, const char **argv)
return -1;
}
- asprintf(&prompt, "Enter new password for %s:", argv[0]);
+ asprintf(&prompt, "Enter new password for %s:", user);
new_password = getpass(prompt);
ret = kerberos_set_password(ads->auth.kdc_server, auth_principal,
- auth_password, argv[0], new_password, ads->auth.time_offset);
+ auth_password, user, new_password, ads->auth.time_offset);
if (!ADS_ERR_OK(ret)) {
d_printf("Password change failed :-( ...\n");
ads_destroy(&ads);
@@ -940,7 +954,7 @@ static int net_ads_password(int argc, const char **argv)
return -1;
}
- d_printf("Password change for %s completed.\n", argv[0]);
+ d_printf("Password change for %s completed.\n", user);
ads_destroy(&ads);
free(prompt);