Skip to content

Commit b78870e

Browse files
committed
add optional group check for dbus cache
1 parent 3b7d252 commit b78870e

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

defaults/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
---
22
nody_greeter_version: "1.5.2"
33

4+
# Specify where to download the codam-web-greeter from and which release
45
codam_web_greeter_git_repo: "https://github.com/codam-coding-college/codam-web-greeter"
56
codam_web_greeter_version: "1.0.10"
67
codam_web_greeter_release_zip_filename: "codam-web-greeter.zip"
8+
9+
# Define whether or not to check if the user is in a specific group when caching their user data with dbus
10+
dbus_cache_group_check_enabled: false
11+
dbus_cache_group_check_group: "student" # default ou=student,ou=groups,dc=42campus,dc=org

templates/usr/share/42/scripts/hook-greeter-setup.sh.j2

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ USER_SESSIONS=$(/usr/bin/loginctl list-sessions --no-legend | /usr/bin/awk '{pri
2222
# Loop over all active sessions and cache them with dbus-send
2323
# This is required for the codam-web-greeter and other lock screens to work properly (fetch the list of users)
2424
for USER in $USER_SESSIONS; do
25+
{% if dbus_cache_group_check_enabled == true %}
26+
# Check if the user is in the piscine group
27+
USER_GROUPS=$(/usr/bin/id -Gn "$USER")
28+
if /usr/bin/grep -q '{{ dbus_cache_group_check_group }}' <<<"$USERGROUPS"; then
29+
# If not, skip the user
30+
echo "Skipping user caching for $USER, not in {{ dbus_cache_group_check_group }} group ($USER_GROUPS)"
31+
continue
32+
fi
33+
{% endif %}
34+
2535
# Cache the user
2636
/usr/bin/dbus-send --system --print-reply --type=method_call --dest=org.freedesktop.Accounts /org/freedesktop/Accounts org.freedesktop.Accounts.CacheUser string:"$USER" || true
2737
echo "Cached user $USER"

0 commit comments

Comments
 (0)