Skip to content

Commit

Permalink
auth: userdb passwd iteration now skips users not in first/last_valid…
Browse files Browse the repository at this point in the history
…_gid range

Patch by Michal Hlavinka / Red Hat
  • Loading branch information
sirainen authored and GitLab committed Jun 29, 2016
1 parent d080f54 commit ca5b3ec
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/auth/auth-settings.c
Expand Up @@ -264,6 +264,8 @@ static const struct setting_define auth_setting_defines[] = {
DEF_NOPREFIX(SET_BOOL, verbose_proctitle),
DEF_NOPREFIX(SET_UINT, first_valid_uid),
DEF_NOPREFIX(SET_UINT, last_valid_uid),
DEF_NOPREFIX(SET_UINT, first_valid_gid),
DEF_NOPREFIX(SET_UINT, last_valid_gid),

SETTING_DEFINE_LIST_END
};
Expand Down Expand Up @@ -313,6 +315,8 @@ static const struct auth_settings auth_default_settings = {
.verbose_proctitle = FALSE,
.first_valid_uid = 500,
.last_valid_uid = 0,
.first_valid_gid = 1,
.last_valid_gid = 0,
};

const struct setting_parser_info auth_setting_parser_info = {
Expand Down
2 changes: 2 additions & 0 deletions src/auth/auth-settings.h
Expand Up @@ -79,6 +79,8 @@ struct auth_settings {
bool verbose_proctitle;
unsigned int first_valid_uid;
unsigned int last_valid_uid;
unsigned int first_valid_gid;
unsigned int last_valid_gid;

/* generated: */
char username_chars_map[256];
Expand Down
4 changes: 4 additions & 0 deletions src/auth/userdb-passwd.c
Expand Up @@ -145,6 +145,10 @@ passwd_iterate_want_pw(struct passwd *pw, const struct auth_settings *set)
return FALSE;
if (pw->pw_uid > (uid_t)set->last_valid_uid && set->last_valid_uid != 0)
return FALSE;
if (pw->pw_gid < (gid_t)set->first_valid_gid)
return FALSE;
if (pw->pw_gid > (gid_t)set->last_valid_gid && set->last_valid_gid != 0)
return FALSE;
return TRUE;
}

Expand Down

0 comments on commit ca5b3ec

Please sign in to comment.