summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1998-11-30 20:42:49 +0000
committerLuke Leighton <lkcl@samba.org>1998-11-30 20:42:49 +0000
commit279923efd357059c463544fb469851ecbc0d1133 (patch)
tree31a292909e8aa2deb0f61b92aabc29f3a80a438d
parentdc879e9ca7382cf981123ed35cdd3cace0abf5be (diff)
downloadsamba-279923efd357059c463544fb469851ecbc0d1133.tar.gz
samba-279923efd357059c463544fb469851ecbc0d1133.tar.bz2
samba-279923efd357059c463544fb469851ecbc0d1133.zip
passdb.c now calls getpwnam() which returns results in a static buffer.
a call _outside_ of this was _also_ calling getpwnam. the calls to getsmbpwnam() were therefore overwriting the static buffer. (This used to be commit c5ba5fa6feab2884a23b8bcb5dcb349ee1a7c139)
-rw-r--r--source3/passdb/smbpasschange.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/source3/passdb/smbpasschange.c b/source3/passdb/smbpasschange.c
index 843cf4a815..22b71d672b 100644
--- a/source3/passdb/smbpasschange.c
+++ b/source3/passdb/smbpasschange.c
@@ -67,6 +67,8 @@ BOOL local_password_change(char *user_name, BOOL trust_account, BOOL add_user,
struct smb_passwd *smb_pwent;
uchar new_p16[16];
uchar new_nt_p16[16];
+ fstring unix_name;
+ uid_t unix_uid;
*err_str = '\0';
*msg_str = '\0';
@@ -77,13 +79,25 @@ BOOL local_password_change(char *user_name, BOOL trust_account, BOOL add_user,
* Check for a machine account.
*/
- if(trust_account && !pwd) {
- slprintf(err_str, err_str_len - 1, "User %s does not \
-exist in system password file (usually /etc/passwd). Cannot add machine \
-account without a valid system user.\n", user_name);
+ if (pwd == NULL)
+ {
+ if (trust_account)
+ {
+ slprintf(err_str, err_str_len - 1, "User %s does not \
+exist in system password file (usually /etc/passwd). \
+Cannot add machine account without a valid system user.\n", user_name);
+ }
+ else
+ {
+ slprintf(err_str, err_str_len - 1, "User %s does not \
+exist in system password file (usually /etc/passwd).\n", user_name);
+ }
return False;
}
+ unix_uid = pwd->pw_uid;
+ fstrcpy(unix_name, pwd->pw_name);
+
/* Calculate the MD4 hash (NT compatible) of the new password. */
nt_lm_owf_gen(new_passwd, new_nt_p16, new_p16);
@@ -114,12 +128,12 @@ account without a valid system user.\n", user_name);
if (smb_pwent == NULL) {
if(add_user == False) {
slprintf(err_str, err_str_len-1,
- "Failed to find entry for user %s.\n", pwd->pw_name);
+ "Failed to find entry for user %s.\n", unix_name);
endsmbpwent(vp);
return False;
}
- if (add_new_user(user_name, pwd->pw_uid, trust_account, disable_user,
+ if (add_new_user(user_name, unix_uid, trust_account, disable_user,
set_no_password, new_p16, new_nt_p16)) {
slprintf(msg_str, msg_str_len-1, "Added user %s.\n", user_name);
endsmbpwent(vp);
@@ -160,7 +174,7 @@ account without a valid system user.\n", user_name);
if(mod_smbpwd_entry(smb_pwent,True) == False) {
slprintf(err_str, err_str_len-1, "Failed to modify entry for user %s.\n",
- pwd->pw_name);
+ unix_name);
endsmbpwent(vp);
return False;
}