diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2015-09-16 08:58:28 -0400 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2015-10-27 17:02:38 +0100 |
commit | a18ab60939f72eb4c4b4c057790d14bcdeb3ec56 (patch) | |
tree | 008617ef2cb63b45ba50e966fccc712a58c5ed37 /src/user-list.vala | |
parent | a9369a5919842e6118f90333ddc150e6230f37ec (diff) | |
download | arctica-greeter-a18ab60939f72eb4c4b4c057790d14bcdeb3ec56.tar.gz arctica-greeter-a18ab60939f72eb4c4b4c057790d14bcdeb3ec56.tar.bz2 arctica-greeter-a18ab60939f72eb4c4b4c057790d14bcdeb3ec56.zip |
Add an option to only show users in a list of specified groups
Ported to ArcticaGreeter: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
Diffstat (limited to 'src/user-list.vala')
-rw-r--r-- | src/user-list.vala | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/user-list.vala b/src/user-list.vala index 4805956..a4e4099 100644 --- a/src/user-list.vala +++ b/src/user-list.vala @@ -1044,6 +1044,9 @@ public class UserList : GreeterList return; } + if (!filter_group (user.name)) + return; + var label = user.real_name; if (user.real_name == "") label = user.name; @@ -1051,6 +1054,34 @@ public class UserList : GreeterList add_user (user.name, label, user.background, user.logged_in, user.has_messages, user.session); } + private bool filter_group (string user_name) + { + var group_filter = UGSettings.get_strv (UGSettings.KEY_GROUP_FILTER); + + /* Empty list means do not filter by group */ + if (group_filter.length == 0) + return true; + + foreach (var group_name in group_filter) + if (in_group (group_name, user_name)) + return true; + + return false; + } + + private bool in_group (string group_name, string user_name) + { + unowned Posix.Group? group = Posix.getgrnam (group_name); + if (group == null) + return false; + + foreach (var name in group.gr_mem) + if (name == user_name) + return true; + + return false; + } + private void user_removed_cb (LightDM.User user) { debug ("Removing user %s", user.name); |