summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2002-12-12 20:49:38 +0000
committerGerald Carter <jerry@samba.org>2002-12-12 20:49:38 +0000
commitd2e7d860b4e6af5121a49bcf2c6fe50530c7fa26 (patch)
treead6b72ff8b3c5560464ddd6c89ccda5d45644895 /source3
parentaabcd65020396105c683ede6fd9b5bb01891b098 (diff)
downloadsamba-d2e7d860b4e6af5121a49bcf2c6fe50530c7fa26.tar.gz
samba-d2e7d860b4e6af5121a49bcf2c6fe50530c7fa26.tar.bz2
samba-d2e7d860b4e6af5121a49bcf2c6fe50530c7fa26.zip
merge of smbpasswd segfault from SAMBA_2_2
(This used to be commit 8311c4bf8d9697f5a65a00300b60dfde12e46ae7)
Diffstat (limited to 'source3')
-rw-r--r--source3/utils/smbpasswd.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c
index d9f36119f7..bcb5629f21 100644
--- a/source3/utils/smbpasswd.c
+++ b/source3/utils/smbpasswd.c
@@ -498,7 +498,8 @@ static int process_nonroot(int local_flags)
{
struct passwd *pwd = NULL;
int result = 0;
- char *old_passwd = NULL;
+ char *old_pw = NULL;
+ char *new_pw = NULL;
if (local_flags & ~(LOCAL_AM_ROOT | LOCAL_SET_PASSWORD)) {
/* Extra flags that we can't honor non-root */
@@ -529,19 +530,21 @@ static int process_nonroot(int local_flags)
}
if (remote_machine != NULL) {
- old_passwd = get_pass("Old SMB password:",stdin_passwd_get);
+ old_pw = get_pass("Old SMB password:",stdin_passwd_get);
}
if (!new_passwd) {
- new_passwd = prompt_for_new_password(stdin_passwd_get);
+ new_pw = prompt_for_new_password(stdin_passwd_get);
}
+ else
+ new_pw = smb_xstrdup(new_passwd);
- if (!new_passwd) {
+ if (!new_pw) {
fprintf(stderr, "Unable to get new password.\n");
exit(1);
}
- if (!password_change(remote_machine, user_name, old_passwd, new_passwd, 0)) {
+ if (!password_change(remote_machine, user_name, old_pw, new_pw, 0)) {
fprintf(stderr,"Failed to change password for %s\n", user_name);
result = 1;
goto done;
@@ -550,8 +553,8 @@ static int process_nonroot(int local_flags)
printf("Password changed for user %s\n", user_name);
done:
- SAFE_FREE(old_passwd);
- SAFE_FREE(new_passwd);
+ SAFE_FREE(old_pw);
+ SAFE_FREE(new_pw);
return result;
}