8
8
# %
9
9
# % DESCRIPTION
10
10
# % This script installs a mandatory PolicyKit policy that either prevents
11
- # % the "user" or "lightdm" users from suspending the system,
12
- # % prevents the "user" or "lightdm" users from restarting/ shutting down
13
- # % the system or prevents both .
11
+ # % the "user" or "lightdm" users from suspending the system or
12
+ # % prevents the "user" or "lightdm" users from suspending, restarting or shutting down
13
+ # % the system.
14
14
# %
15
15
# % It takes two optional parameters: whether to prevent suspending the system
16
- # % and whether to prevent restart/shutdown.
16
+ # % and whether to also prevent restart/shutdown.
17
17
# % 1. Use a boolean to decide whether or not to prevent the "user" from
18
18
# % suspending the system. A checked box prevents suspend and an
19
19
# % unchecked box allows it
20
- # % 2. Use a boolean to decide whether or not to prevent the "user" from
20
+ # % 2. Use a boolean to decide whether or not to also prevent the "user" from
21
21
# % restarting/shutting down the system. A checked box prevents
22
- # % restart/shutdown and an unchecked box allows it
22
+ # % restart/shutdown and an unchecked box allows it.
23
+ # % Has no effect if input 1 is unchecked
23
24
# %
24
25
# ================================================================
25
26
# - IMPLEMENTATION
@@ -47,10 +48,10 @@ set -x
47
48
POLICY=" /etc/polkit-1/localauthority/90-mandatory.d/10-os2borgerpc-no-user-shutdown.pkla"
48
49
49
50
if [ ! -d " $( dirname " $POLICY " ) " ]; then
50
- mkdir " $( dirname " $POLICY " ) "
51
+ mkdir -p " $( dirname " $POLICY " ) "
51
52
fi
52
53
53
- if [ " $1 " = " False" ] && [ " $2 " = " False " ] ; then
54
+ if [ " $1 " = " False" ]; then
54
55
rm -f " $POLICY "
55
56
elif [ " $1 " = " True" ] && [ " $2 " = " False" ]; then
56
57
cat > " $POLICY " << END
@@ -61,15 +62,6 @@ ResultAny=no
61
62
ResultActive=no
62
63
ResultInactive=no
63
64
END
64
- elif [ " $1 " = " False" ] && [ " $2 " = " True" ]; then
65
- cat > " $POLICY " << END
66
- [Restrict system shutdown]
67
- Identity=unix-user:user;unix-user:lightdm
68
- Action=org.freedesktop.login1.power-off*;org.freedesktop.login1.reboot*;org.freedesktop.login1.lock-sessions;org.freedesktop.login1.set-reboot*
69
- ResultAny=no
70
- ResultActive=no
71
- ResultInactive=no
72
- END
73
65
else
74
66
cat > " $POLICY " << END
75
67
[Restrict system shutdown]
0 commit comments