summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2012-03-07 12:36:44 +0100
committerRay Strode <rstrode@redhat.com>2012-03-26 15:21:58 -0400
commit552a0c856a6e3a7c2e6450ab80e79f4204062281 (patch)
treeea9a24fc630954a39672169d86e445639d7f4509
parent1fd8d981d134257e1d18ef356f5aa08a6f2d7f28 (diff)
Filter users on nologin rather than minimal UID
https://bugs.freedesktop.org/show_bug.cgi?id=44408
-rw-r--r--src/daemon.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/daemon.c b/src/daemon.c
index 170f1c9..5fe6aed 100644
--- a/src/daemon.c
+++ b/src/daemon.c
@@ -48,6 +48,7 @@
#define PATH_PASSWD "/etc/passwd"
#define PATH_SHADOW "/etc/shadow"
+#define PATH_NOLOGIN "/sbin/nologin"
#define PATH_GDM_CUSTOM "/etc/gdm/custom.conf"
#define USERDIR LOCALSTATEDIR "/lib/AccountsService/users"
@@ -152,8 +153,11 @@ error_get_type (void)
}
gboolean
-daemon_local_user_is_excluded (Daemon *daemon, const gchar *username, uid_t uid)
+daemon_local_user_is_excluded (Daemon *daemon, const gchar *username, const gchar *shell)
{
+ if (g_strcmp0 (shell, PATH_NOLOGIN) == 0) {
+ return TRUE;
+ }
if (g_hash_table_lookup (daemon->priv->exclusions, username)) {
return TRUE;
}
@@ -189,7 +193,7 @@ reload_wtmp_history (Daemon *daemon)
if (daemon_local_user_is_excluded (daemon,
wtmp_entry->ut_user,
- daemon->priv->minimal_uid)) {
+ NULL)) {
g_debug ("excluding user '%s'", wtmp_entry->ut_user);
continue;
}
@@ -285,8 +289,8 @@ reload_passwd (Daemon *daemon)
#else
while ((pwent = getpwent ()) != NULL) {
#endif
- /* Skip users below MINIMAL_UID... */
- if (daemon_local_user_is_excluded (daemon, pwent->pw_name, pwent->pw_uid)) {
+ /* Skip system users... */
+ if (daemon_local_user_is_excluded (daemon, pwent->pw_name, pwent->pw_shell)) {
g_debug ("skipping user: %s", pwent->pw_name);
continue;
}
@@ -814,7 +818,7 @@ finish_list_cached_users (gpointer user_data)
g_hash_table_iter_init (&iter, data->daemon->priv->users);
while (g_hash_table_iter_next (&iter, (gpointer *)&name, (gpointer *)&user)) {
uid = user_local_get_uid (user);
- if (!daemon_local_user_is_excluded (data->daemon, name, uid)) {
+ if (!daemon_local_user_is_excluded (data->daemon, name, NULL)) {
g_debug ("user %s %ld not excluded\n", name, (long) uid);
g_ptr_array_add (object_paths, (gpointer) user_local_get_object_path (user));
}