Skip to content

Commit 5983bf9

Browse files
author
Andreas Poulsen
committed
Merge branch 'feature/adjust_polkit_policy_shutdown' into 'master'
Remove option to disable poweroff/reboot but not suspend See merge request os2borgerpc/os2borgerpc-scripts!166
2 parents ac408c6 + 9f30fae commit 5983bf9

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

os2borgerpc/desktop/polkit_policy_shutdown.sh renamed to os2borgerpc/desktop/polkit_policy_shutdown_suspend.sh

+9-17
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@
88
#%
99
#% DESCRIPTION
1010
#% 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.
1414
#%
1515
#% 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.
1717
#% 1. Use a boolean to decide whether or not to prevent the "user" from
1818
#% suspending the system. A checked box prevents suspend and an
1919
#% 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
2121
#% 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
2324
#%
2425
#================================================================
2526
#- IMPLEMENTATION
@@ -47,10 +48,10 @@ set -x
4748
POLICY="/etc/polkit-1/localauthority/90-mandatory.d/10-os2borgerpc-no-user-shutdown.pkla"
4849

4950
if [ ! -d "$(dirname "$POLICY")" ]; then
50-
mkdir "$(dirname "$POLICY")"
51+
mkdir -p "$(dirname "$POLICY")"
5152
fi
5253

53-
if [ "$1" = "False" ] && [ "$2" = "False" ]; then
54+
if [ "$1" = "False" ]; then
5455
rm -f "$POLICY"
5556
elif [ "$1" = "True" ] && [ "$2" = "False" ]; then
5657
cat > "$POLICY" <<END
@@ -61,15 +62,6 @@ ResultAny=no
6162
ResultActive=no
6263
ResultInactive=no
6364
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
7365
else
7466
cat > "$POLICY" <<END
7567
[Restrict system shutdown]

0 commit comments

Comments
 (0)