Both glibc and musl provide getusershell(3). It's an API from 4.3BSD,
according to the manual page, so let's assume it exists everywhere that
we would care, even if it's not in POSIX.
Reported-by: Chris Hofstaedtler <zeha@debian.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
AC_CHECK_HEADER([shadow.h],,[AC_MSG_ERROR([You need a libc with shadow.h])])
AC_CHECK_FUNCS(arc4random_buf futimes \
- getentropy getrandom getusershell \
+ getentropy getrandom \
lckpwdf lutimes \
updwtmpx innetgr \
getspnam_r \
#define EXPIRE_VALS_SET /* If defined, 'normal' users can't change
* password expiry values (if running suid root) */
-#define HAVE_GETUSERSHELL /* FIXME: Isn't this defined in config.h too? */
#define LOGGING /* If we want to log various things to syslog */
#define MAX_USRNAME 8 /* Longer usernames seem to work on my system....
* But they're probably a poor idea */
{
char *sh;
int ok = 0;
-#ifdef HAVE_GETUSERSHELL
+
setusershell ();
while ((sh = getusershell ()) != NULL)
if (streq(shell, sh))
ok = 1;
endusershell ();
-#endif
+
if (!ok)
{
if (getuid () == 0)
static bool shell_is_listed (const char *sh)
{
bool found = false;
-
-#ifdef HAVE_GETUSERSHELL
char *cp;
+
setusershell ();
while ((cp = getusershell ())) {
if (streq(cp, sh)) {
}
}
endusershell ();
-#else
- char *buf = NULL;
- FILE *fp;
- size_t n = 0;
-
- fp = fopen (SHELLS_FILE, "r");
- if (NULL == fp) {
- return false;
- }
- while (getline (&buf, &n, fp) != -1) {
- if (buf[0] != '/') {
- continue;
- }
-
- if (streq(buf, sh)) {
- found = true;
- break;
- }
- }
-
- free(buf);
- fclose (fp);
-#endif
return found;
}
#endif /* with HAVE_VENDORDIR */