mirror of
https://github.com/samba-team/samba.git
synced 2025-03-12 20:58:37 +03:00
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)
This commit is contained in:
parent
dc879e9ca7
commit
279923efd3
@ -67,6 +67,8 @@ BOOL local_password_change(char *user_name, BOOL trust_account, BOOL add_user,
|
|||||||
struct smb_passwd *smb_pwent;
|
struct smb_passwd *smb_pwent;
|
||||||
uchar new_p16[16];
|
uchar new_p16[16];
|
||||||
uchar new_nt_p16[16];
|
uchar new_nt_p16[16];
|
||||||
|
fstring unix_name;
|
||||||
|
uid_t unix_uid;
|
||||||
|
|
||||||
*err_str = '\0';
|
*err_str = '\0';
|
||||||
*msg_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.
|
* Check for a machine account.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if(trust_account && !pwd) {
|
if (pwd == NULL)
|
||||||
slprintf(err_str, err_str_len - 1, "User %s does not \
|
{
|
||||||
exist in system password file (usually /etc/passwd). Cannot add machine \
|
if (trust_account)
|
||||||
account without a valid system user.\n", user_name);
|
{
|
||||||
|
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;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unix_uid = pwd->pw_uid;
|
||||||
|
fstrcpy(unix_name, pwd->pw_name);
|
||||||
|
|
||||||
/* Calculate the MD4 hash (NT compatible) of the new password. */
|
/* Calculate the MD4 hash (NT compatible) of the new password. */
|
||||||
nt_lm_owf_gen(new_passwd, new_nt_p16, new_p16);
|
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 (smb_pwent == NULL) {
|
||||||
if(add_user == False) {
|
if(add_user == False) {
|
||||||
slprintf(err_str, err_str_len-1,
|
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);
|
endsmbpwent(vp);
|
||||||
return False;
|
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)) {
|
set_no_password, new_p16, new_nt_p16)) {
|
||||||
slprintf(msg_str, msg_str_len-1, "Added user %s.\n", user_name);
|
slprintf(msg_str, msg_str_len-1, "Added user %s.\n", user_name);
|
||||||
endsmbpwent(vp);
|
endsmbpwent(vp);
|
||||||
@ -160,7 +174,7 @@ account without a valid system user.\n", user_name);
|
|||||||
|
|
||||||
if(mod_smbpwd_entry(smb_pwent,True) == False) {
|
if(mod_smbpwd_entry(smb_pwent,True) == False) {
|
||||||
slprintf(err_str, err_str_len-1, "Failed to modify entry for user %s.\n",
|
slprintf(err_str, err_str_len-1, "Failed to modify entry for user %s.\n",
|
||||||
pwd->pw_name);
|
unix_name);
|
||||||
endsmbpwent(vp);
|
endsmbpwent(vp);
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user