Gentoo Archives: gentoo-user

From: Michael Jones <gentoo@×××××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] prevent users from shutting down while other users logged in
Date: Wed, 29 Apr 2020 16:33:21
Message-Id: CABfmKS+mfZ5S=UCo2P8pZU2+eSG0hiH=q5eOkV_sOboLbMREAg@mail.gmail.com
In Reply to: [gentoo-user] prevent users from shutting down while other users logged in by Raffaele BELARDI
1 On Wed, Apr 29, 2020 at 11:19 AM Raffaele BELARDI <raffaele.belardi@××.com>
2 wrote:
3
4 > I often have the kids working on my main ~amd64 PC (XFCE, OpenRC,
5 > -consolekit) while I ssh into it doing some maintenance from an old PC.
6 > Often they shut it down without telling me first, so I loose part of my
7 > stuff. Is there a way to tell XFCE/elogind/PAM/lightdm/whoever to not allow
8 > shutdown from a regular user while another user is logged in? I understand
9 > that logind/systemd provides the system-inhibit [1] user command just for
10 > that, but I don’t find the analogous for OpenRC/elogind.
11 >
12 >
13 >
14 > Basically I’d like that:
15 >
16 > - if there is more than one user logged in, either locally via lighdm or
17 > remotely via SSH, the shutdown XFCE button is grayed out. Once all users
18 > except one have logged out, the button is again available
19 >
20 > - from the ssh shell the command would be always available (root or normal
21 > user, I don’t care)
22 >
23 > - permanently disabling the shutdown for the kids is not optimal, they
24 > should be able to stop the machine if he/she is the only user
25 >
26 >
27 >
28 > Thanks,
29 >
30 >
31 >
32 > raffaele
33 >
34 >
35 >
36 > [1] https://www.freedesktop.org/software/systemd/man/systemd-inhibit.html
37 >
38 >
39 >
40
41 What's to stop them from shutdown via the physical power button? I know
42 that's almost always how I shut down a computer, and I tend not to even
43 think of using the menu.
44
45 As for how to inhibit, you'll probably need to combine something that reads
46 the currently active user sessions, with a patch to the XFCE menu to use
47 that information.