2

I have a computer running Ubuntu that is used by multiple people. It spends a lot of time powered off. On occasion, I would like to start it up using Wake-On-Lan, connect via ssh and start a job in the background. I do not want the PC to shutdown while this job is running.

However, since there are multiple people who might use this PC, someone could walk up to the machine, log in, check their email or whatever and then shut the PC down. Alternatively, someone might notice that it is switched on and showing the GDM log-in screen and decide to shut it down.

Is there a way to prevent this from happening? It doesn't have to make it completely impossible: just making the computer pop up a window saying "Are you really sure (jobs are running in the background)?" would do perfectly well. However, it must work both from the Gnome menu after log-in and from the GDM screen.

2 Answers 2

2

You can disable it for both GDM and from the menu when logged in.

Edit /usr/share/polkit-1/actions/org.freedesktop.consolekit.policy and where ever it says

<allow_active>yes</allow_active>

change that to

<allow_active>auth_admin_keep</allow_active>

So the file will look like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
 "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">

<!--
Policy definitions for ConsoleKit
-->

<policyconfig>

  <action id="org.freedesktop.consolekit.system.stop">
    <description>Stop the system</description>
    <message>System policy prevents stopping the system</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>no</allow_active>
    </defaults>
  </action>

  <action id="org.freedesktop.consolekit.system.stop-multiple-users">
    <description>Stop the system when multiple users are logged in</description>
    <message>System policy prevents stopping the system when other users are logged in</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>no</allow_active>
    </defaults>
  </action>

  <action id="org.freedesktop.consolekit.system.restart">
    <description>Restart the system</description>
    <message>System policy prevents restarting the system</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>
  </action>

  <action id="org.freedesktop.consolekit.system.restart-multiple-users">
    <description>Restart the system when multiple users are logged in</description>
    <message>System policy prevents restarting the system when other users are logged in</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>
  </action>

</policyconfig>

Note: You don't have to change the last two sections (they affect restarting), but I'm assuming if you don't want someone shutting down the computer, you don't want them restarting it either.

To do this faster, you could create two version of this file (one that allows normal users to shut down the computer, and one that doesn't) somewhere in your home directory and have a script that copies one of them to /usr/share/polkit-1/actions/.

0

For gdm, i think there is a way to disable system controls but i don't know how. For gnome, you can make a launcher with the commande "gksudo halt". It will ask the password if you want to shutdown the computer.

1
  • If I make a launcher like that, will the normal menu way of shutting down use it? I don't want to have to reconfigure everyone's Gnome session settings. I don't see how it will let people know that processing is in progress either: if they have to enter a password regardless of whether there's something going on in the background, it won't help at all.
    – DrAl
    Dec 16, 2010 at 14:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .