
When terminating screen lock, pam_exec is called in the context of the corresponding user. Non-root users don't have the permission to start/stop firewalld. So exit immediately.
10 lines
304 B
Bash
10 lines
304 B
Bash
#!/usr/bin/bash
|
|
|
|
# exit if not running as root. Because other user don't have privileges to start/stop firewalld.
|
|
[[ "${UID}" -eq "0" ]] || exit 0
|
|
|
|
if [[ "${PAM_USER}" =~ -exam$ ]]; then
|
|
systemctl start firewalld.service
|
|
elif ! (users | grep -q -- "-exam"); then
|
|
systemctl stop firewalld.service
|
|
fi
|