If the invoking user cannot be resolved by uid fake the struct
passwd and store it in the cache so we can delref it on exit.
This commit is contained in:
@@ -312,10 +312,10 @@ done:
|
||||
}
|
||||
|
||||
/*
|
||||
* Take a uid in string form "#123" and return a faked up passwd struct.
|
||||
* Take a user, uid and gid and return a faked up passwd struct.
|
||||
*/
|
||||
struct passwd *
|
||||
sudo_fakepwnam(const char *user, gid_t gid)
|
||||
sudo_fakepwnamid(const char *user, uid_t uid, gid_t gid)
|
||||
{
|
||||
struct cache_item *item;
|
||||
struct passwd *pw;
|
||||
@@ -332,7 +332,7 @@ sudo_fakepwnam(const char *user, gid_t gid)
|
||||
item = emalloc(len);
|
||||
zero_bytes(item, sizeof(*item) + sizeof(*pw));
|
||||
pw = (struct passwd *) ((char *)item + sizeof(*item));
|
||||
pw->pw_uid = (uid_t) atoi(user + 1);
|
||||
pw->pw_uid = uid;
|
||||
pw->pw_gid = gid;
|
||||
pw->pw_name = (char *)pw + sizeof(struct passwd);
|
||||
memcpy(pw->pw_name, user, namelen + 1);
|
||||
@@ -367,6 +367,18 @@ sudo_fakepwnam(const char *user, gid_t gid)
|
||||
return pw;
|
||||
}
|
||||
|
||||
/*
|
||||
* Take a uid in string form "#123" and return a faked up passwd struct.
|
||||
*/
|
||||
struct passwd *
|
||||
sudo_fakepwnam(const char *user, gid_t gid)
|
||||
{
|
||||
uid_t uid;
|
||||
|
||||
uid = (uid_t) atoi(user + 1);
|
||||
return sudo_fakepwnamid(user, uid, gid);
|
||||
}
|
||||
|
||||
void
|
||||
sudo_setpwent(void)
|
||||
{
|
||||
|
Reference in New Issue
Block a user