disable shutdown/suspend if there is other user logged in via ssh
- by Denwerko
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 system file )?