From 741b4d814cd8838b89e17719714ebc21530991cc Mon Sep 17 00:00:00 2001 From: Alexander Ried Date: Wed, 5 Oct 2016 15:24:42 +0200 Subject: [PATCH] user-classify: fix logic with getusershell Previously the code block with HAVE_GETUSRSHELL did nothing but waste time. --- configure.ac | 2 +- src/user-classify.c | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index 2bd1dc1..8670026 100644 --- a/configure.ac +++ b/configure.ac @@ -215,7 +215,7 @@ AC_DEFINE_UNQUOTED([PATH_WTMP], [$wtmpx_found], [Path to wtmpx file]) AC_CHECK_LIB(c, getusershell, have_getusershell=yes, have_getusershell=no) if test x$have_getusershell = xyes; then - AC_DEFINE(HAVE_GETUSERSHELL, 1, [Define i getusershell() is available]) + AC_DEFINE(HAVE_GETUSERSHELL, 1, [Define if getusershell() is available]) fi dnl --------------------------------------------------------------------------- diff --git a/src/user-classify.c b/src/user-classify.c index b79a35f..e42eb91 100644 --- a/src/user-classify.c +++ b/src/user-classify.c @@ -118,20 +118,21 @@ user_classify_is_excluded_by_heuristics (const gchar *username, static gboolean is_invalid_shell (const char *shell) { - char *basename, *nologin_basename, *false_basename; - int ret = FALSE; - #ifdef HAVE_GETUSERSHELL char *valid_shell; + int ret = TRUE; setusershell (); while ((valid_shell = getusershell ()) != NULL) { - if (g_strcmp0 (shell, valid_shell) != 0) - continue; - ret = FALSE; + if (g_strcmp0 (shell, valid_shell) != 0) { + ret = TRUE; + break; + } } endusershell (); -#endif +#elif + char *basename, *nologin_basename, *false_basename; + int ret = FALSE; basename = g_path_get_basename (shell); nologin_basename = g_path_get_basename (PATH_NOLOGIN); @@ -148,7 +149,7 @@ is_invalid_shell (const char *shell) g_free (basename); g_free (nologin_basename); g_free (false_basename); - +#endif return ret; } -- 2.9.3