Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The program molly-guard is a brilliant little tool which will prompt you for a piece of information before you reboot or shut down a system. Usually it asks for the hostname. So when you work a lot via SSH, you won't end up taking down the wrong server, just because you were in the wrong tab or window.

Now, this works all fine when you say reboot on the command line while you are already root. However, it won't work if you do sudo reboot (i.e. it won't even ask). How can I get it to work with sudo as well?

System: Raspbian (latest, including updates), package molly-guard version 0.4.5-1.

share|improve this question
up vote 1 down vote accepted

Mollyguard basically works by placing scripts in /usr/sbin/*. These scripts call the actual shutdown/halt/reboot binaries that are stored in /sbin. Sudo or the root on your system is probably set with a PATH that has /sbin before /usr/sbin/ in the effective PATH. Adjust your path so that /usr/sbin/ is first.

share|improve this answer
    
Thanks, I'll give that a try. – 0xC0000022L Oct 30 '13 at 12:36

For me it was the combination of sudo and tmux that stopped it detecting the SSH session. (It also affects screen the same way - this is a known issue listed in man molly-guard.)

I solved it by adding this to the sudoers config file (using the visudo command):

Defaults env_keep += SSH_CONNECTION
share|improve this answer

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.