Skip to content

Commit

Permalink
configure.ac, lib/: Assume initgroups(3) exists
Browse files Browse the repository at this point in the history
It's available in every system I checked: glibc,musl,{Free,Net,Open}BSD.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
  • Loading branch information
alejandro-colomar committed Dec 5, 2024
1 parent d4be5ef commit 8919d4a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ AC_CHECK_HEADER([shadow.h],,[AC_MSG_ERROR([You need a libc with shadow.h])])

AC_CHECK_FUNCS(arc4random_buf futimes \
getentropy getrandom getspnam getusershell \
initgroups lckpwdf lutimes \
lckpwdf lutimes \
updwtmpx innetgr \
getspnam_r \
rpmatch \
Expand Down
2 changes: 1 addition & 1 deletion lib/age.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ int expire (const struct passwd *pw, /*@null@*/const struct spwd *sp)
* passwd to work just like it would had they executed
* it from the command line while logged in.
*/
#if defined(HAVE_INITGROUPS) && ! defined(USE_PAM)
#if !defined(USE_PAM)
if (setup_uid_gid (pw, false) != 0)
#else
if (setup_uid_gid (pw) != 0)
Expand Down
2 changes: 1 addition & 1 deletion lib/prototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ extern int del_seuser(const char *login_name);
/* setugid.c */
extern int setup_groups (const struct passwd *info);
extern int change_uid (const struct passwd *info);
#if (defined HAVE_INITGROUPS) && (! defined USE_PAM)
#if !defined(USE_PAM)
extern int setup_uid_gid (const struct passwd *info, bool is_console);
#else
extern int setup_uid_gid (const struct passwd *info);
Expand Down
10 changes: 5 additions & 5 deletions lib/setugid.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int setup_groups (const struct passwd *info)
closelog ();
return -1;
}
#ifdef HAVE_INITGROUPS

/*
* For systems which support multiple concurrent groups, go get
* the group set from the /etc/group file.
Expand All @@ -60,7 +60,7 @@ int setup_groups (const struct passwd *info)
closelog ();
return -1;
}
#endif

return 0;
}

Expand Down Expand Up @@ -96,7 +96,7 @@ int change_uid (const struct passwd *info)
* Returns 0 on success, or -1 on failure.
*/

#if defined (HAVE_INITGROUPS) && ! (defined USE_PAM)
#if !defined(USE_PAM)
int setup_uid_gid (const struct passwd *info, bool is_console)
#else
int setup_uid_gid (const struct passwd *info)
Expand All @@ -106,15 +106,15 @@ int setup_uid_gid (const struct passwd *info)
return -1;
}

#if defined (HAVE_INITGROUPS) && ! defined (USE_PAM)
#if !defined(USE_PAM)
if (is_console) {
const char *cp = getdef_str ("CONSOLE_GROUPS");

if ((NULL != cp) && (add_groups (cp) != 0)) {
perror ("Warning: add_groups");
}
}
#endif /* HAVE_INITGROUPS && !USE_PAM*/
#endif // !USE_PAM

if (change_uid (info) < 0) {
return -1;
Expand Down

0 comments on commit 8919d4a

Please sign in to comment.