Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I remember that in versions of ubuntu around 9.04 was possible to disable user to shutdown ( and maybe suspend too ) system if there was other user logged in.Something like policykit or similar.

Is it possible to do in 11.04 ?

Thanks

edit:

if someone needs ( for own risk ), little change in /usr/lib/pm-utils/bin/pm-action will allow user to suspend machine if he is only user logged in or when user will run sudo pm-suspend. Probably not best piece of code, but for now works.

diff -r 805887c5c0f6 pm-action
--- a/pm-action Wed Jun 29 23:32:01 2011 +0200
+++ b/pm-action Wed Jun 29 23:37:23 2011 +0200
@@ -47,6 +47,14 @@
    exit 1
 fi

+if [ "$(id -u )" == 0 -o `w -h | cut -f 1 -d " " | sort | uniq | wc -l` -eq 1 ]; then
+                echo "either youre root or root isnt here and youre only user, continuing" 1>&2
+                else
+                echo "Not suspending, root is here or there is more users" 1>&2
+                exit 2
+                fi
+
+
 remove_suspend_lock()
 {
    release_lock "${STASHNAME}.lock"

Question still stands, is it possible to forbid shutdown or suspend when there is more than one user logged in ( without rewriting pm-suspend or halt ( or other hack ) )?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted
+50

Update (thanks to enzotib):

The files I listed in the original answer should not be edited, as a package update can overwrite your changes.

PolicyKit should instead be configured using configuration files placed in /var/lib/polkit-1/localauthority/, as detailed in the pklocalauthority manual page.

Original answer:

With the deprecation of HAL, this is now controlled in /usr/share/polkit-1/actions/org.freedesktop.consolekit.policy

Set allow_active in the two action sections shown below to no (they are set to auth_admin_keep by default):

  <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-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>no</allow_active>
    </defaults>
  </action>
share|improve this answer
1  
You should set your policy file in one of your /var/lib/polkit-1/localauthority/*.d directories, as explained in pklocalauthority manual page. Avoid to modify files installed by packages (as /usr/share/polkit-1/actions/org.freedesktop.consolekit.policy), other that configuration files in /etc/. –  enzotib Jul 26 '11 at 7:39
    
@scottl Can you edit your answer to read correctly? As it reads now it's totally confusing. –  Jorge Castro Jul 27 '11 at 1:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.