summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2002-12-12 20:50:31 +0000
committerGerald Carter <jerry@samba.org>2002-12-12 20:50:31 +0000
commit438c460cec58270e8ac847d05281f65e1d41067c (patch)
treeb2b105380cf1911202cdbdad10c709975082f0ef
parent9327793ff5367268802ae5aa9833959ed3fd6ce7 (diff)
downloadsamba-438c460cec58270e8ac847d05281f65e1d41067c.tar.gz
samba-438c460cec58270e8ac847d05281f65e1d41067c.tar.bz2
samba-438c460cec58270e8ac847d05281f65e1d41067c.zip
merge of smbpasswd segfault from SAMBA_2_2
(This used to be commit b17af40b1c73ccf7eeb3d1d18937cb3ffe162b5d)
-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;
}