Skip to content

Commit 24351bd

Browse files
committed
sudo_set_grlist and sudo_set_gidlist: set auth registry based on username
Previously we used the global registry but since we have the user's passwd info we should use that when storing the group and gid lists.
1 parent 2ffcda8 commit 24351bd

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

plugins/sudoers/pwutil.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,9 @@ sudo_set_grlist(struct passwd *pw, char * const *groups)
959959
struct cache_item key, *item;
960960
debug_decl(sudo_set_grlist, SUDOERS_DEBUG_NSS);
961961

962+
sudo_debug_printf(SUDO_DEBUG_DEBUG, "%s: setting group names for %s",
963+
__func__, pw->pw_name);
964+
962965
sudo_debug_group_list(pw->pw_name, groups, SUDO_DEBUG_DEBUG);
963966

964967
if (grlist_cache == NULL) {
@@ -973,7 +976,7 @@ sudo_set_grlist(struct passwd *pw, char * const *groups)
973976
* Cache group db entry if it doesn't already exist
974977
*/
975978
key.k.name = pw->pw_name;
976-
getauthregistry(NULL, key.registry);
979+
getauthregistry(pw->pw_name, key.registry);
977980
if (rbfind(grlist_cache, &key) == NULL) {
978981
if ((item = make_grlist_item(pw, groups)) == NULL) {
979982
sudo_warnx(U_("unable to parse groups for %s"), pw->pw_name);
@@ -1067,6 +1070,9 @@ sudo_set_gidlist(struct passwd *pw, int ngids, GETGROUPS_T *gids,
10671070
struct cache_item key, *item;
10681071
debug_decl(sudo_set_gidlist, SUDOERS_DEBUG_NSS);
10691072

1073+
sudo_debug_printf(SUDO_DEBUG_DEBUG, "%s: setting group-IDs for %s",
1074+
__func__, pw->pw_name);
1075+
10701076
/* XXX - ngids/gids too */
10711077
sudo_debug_group_list(pw->pw_name, gidstrs, SUDO_DEBUG_DEBUG);
10721078

@@ -1083,7 +1089,7 @@ sudo_set_gidlist(struct passwd *pw, int ngids, GETGROUPS_T *gids,
10831089
*/
10841090
key.k.name = pw->pw_name;
10851091
key.type = type;
1086-
getauthregistry(NULL, key.registry);
1092+
getauthregistry(pw->pw_name, key.registry);
10871093
if (rbfind(gidlist_cache, &key) == NULL) {
10881094
if ((item = make_gidlist_item(pw, ngids, gids, gidstrs, type)) == NULL) {
10891095
sudo_warnx(U_("unable to parse gids for %s"), pw->pw_name);

0 commit comments

Comments
 (0)