1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-21 18:04:06 +03:00

smbd: Safeguards for getpwuid

Attempt to fix

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14900

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 929ccd3d1afb864ea715fa4d3d8af8f997e5d2aa)

Autobuild-User(v4-16-test): Jule Anger <janger@samba.org>
Autobuild-Date(v4-16-test): Mon Feb 14 22:18:31 UTC 2022 on sn-devel-184
This commit is contained in:
Volker Lendecke 2022-02-03 13:20:11 +01:00 committed by Jule Anger
parent cdc5e9e4db
commit 1bbb3677ae

View File

@ -1402,6 +1402,7 @@ static bool pdb_default_uid_to_sid(struct pdb_methods *methods, uid_t uid,
{
struct samu *sampw = NULL;
struct passwd *unix_pw;
fstring pw_name = { 0 };
bool ret;
unix_pw = getpwuid( uid );
@ -1412,14 +1413,23 @@ static bool pdb_default_uid_to_sid(struct pdb_methods *methods, uid_t uid,
return False;
}
if (unix_pw->pw_name == NULL) {
DBG_DEBUG("No pw_name for uid %d\n", (int)uid);
return false;
}
/*
* Make a copy, "unix_pw" might go away soon.
*/
fstrcpy(pw_name, unix_pw->pw_name);
if ( !(sampw = samu_new( NULL )) ) {
DEBUG(0,("pdb_default_uid_to_sid: samu_new() failed!\n"));
return False;
}
become_root();
ret = NT_STATUS_IS_OK(
methods->getsampwnam(methods, sampw, unix_pw->pw_name ));
ret = NT_STATUS_IS_OK(methods->getsampwnam(methods, sampw, pw_name));
unbecome_root();
if (!ret) {