diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2017-12-19 15:18:04 +1300 |
---|---|---|
committer | Robert Ancell <robert.ancell@canonical.com> | 2017-12-19 15:18:04 +1300 |
commit | 958a371cc6655614940f78781a6a8b8ef301b85a (patch) | |
tree | 4bcc25a24f62316939c80b727d2ab7fea1ea4b2b | |
parent | 88f9b6930304aaf3345153cbb9227c4f4e649aad (diff) | |
download | accountsservice-958a371cc6655614940f78781a6a8b8ef301b85a.tar.gz |
Simplify valid shell checking.
The existing code explicitly used /sbin/nologin which is not the name
used in Debian based systems. However, it only used the basename anyway
so the /sbin vs /usr/sbin part isn't relevant in this check.
-rw-r--r-- | src/user-classify.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/src/user-classify.c b/src/user-classify.c index 76d9f28..996d08e 100644 --- a/src/user-classify.c +++ b/src/user-classify.c @@ -76,9 +76,6 @@ user_classify_is_blacklisted (const char *username) return FALSE; } -#define PATH_NOLOGIN "/sbin/nologin" -#define PATH_FALSE "/bin/false" - #ifdef ENABLE_USER_HEURISTICS static gboolean user_classify_is_excluded_by_heuristics (const gchar *username, @@ -115,7 +112,7 @@ user_classify_is_excluded_by_heuristics (const gchar *username, static gboolean is_invalid_shell (const char *shell) { - char *basename, *nologin_basename, *false_basename; + char *basename; int ret = FALSE; #ifdef HAVE_GETUSERSHELL @@ -136,20 +133,15 @@ is_invalid_shell (const char *shell) /* always check for false and nologin since they are sometimes included by getusershell */ basename = g_path_get_basename (shell); - nologin_basename = g_path_get_basename (PATH_NOLOGIN); - false_basename = g_path_get_basename (PATH_FALSE); - if (shell[0] == '\0') { ret = TRUE; - } else if (g_strcmp0 (basename, nologin_basename) == 0) { + } else if (g_strcmp0 (basename, "nologin") == 0) { ret = TRUE; - } else if (g_strcmp0 (basename, false_basename) == 0) { + } else if (g_strcmp0 (basename, "false") == 0) { ret = TRUE; } g_free (basename); - g_free (nologin_basename); - g_free (false_basename); return ret; } |