summaryrefslogtreecommitdiffstats
path: root/core/modules/pam-slx-plug/data/opt/openslx/pam/exec_session
blob: 8e7b7bff49dd8eb7b15257992c191b57b162ab87 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/ash

# PAM_TYPE will be "open_session" or "close_session"

# Needed as pam_script clears PATH
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/openslx/sbin:/opt/openslx/bin"

# can only work if script is run as root
[ "x$(whoami)" = "xroot" ] || exit 0

# just exit for greeter sessions
[ "x${PAM_SERVICE%greeter}" != "x${PAM_SERVICE}" ] && exit 0

if [ "$PAM_TYPE" = "open_session" ]; then
	# OPEN OPEN OPEN
	# source the stuff in pam_script_ses_open.d, if it exists
	for HOOK in /opt/openslx/scripts/pam_script_ses_open.d/*; do
		[ -f "$HOOK" ] || continue
		# source it, in case of failure do nothing since these scripts are non-critical
		( . "$HOOK" ) || slxlog "pam-hooks-ses-open" "Could not source '$HOOK'."
	done
	#
elif [ "$PAM_TYPE" = "close_session" ]; then
	# CLOSE CLOSE CLOSE
	# source hooks if there are any
	for HOOK in /opt/openslx/scripts/pam_script_ses_close.d/*; do
		[ -f "$HOOK" ] || continue
		# failure is non-critical
		( . "$HOOK" ) || slxlog "pam-hooks-ses-close" "Could not source '$HOOK'."
	done
	#
fi

exit 0