[SOLVED] Standby-Mode as passwordless Sleep-key!


Kosmos

Member
Joined
Apr 10, 2012
Messages
228
Ok I have been trying to get this working. I thought I DID under beta 3 but now (under beta4) it is not working. And I do not know what I forgot because its not in the forums.


Standby Mode requires password [shouldn't]. I should be able to assign a hotkey to run op_standby or add a menu item. I have done both and they both work - BUT ONLY if I first enter the sudo password in terminal.


HOw do I get this to run without a password.?


I added this to /etc/sudoers but although I can su to root without a password I can not sudo. And op_standby really should be something free of permissions.


I have tried both in My sudoers:


username ALL=(ALL) NOPASSWD: ALL


username LOCAL=(root) NOPASSWD: ALL


op_standby.sh has the following and runs fine after password.


sudo "/usr/pandora/scripts/op_power.sh" 0
 
Last edited by a moderator:
I'll try to help, though it's been a while that i fiddled around with sudoers - and that only for a short time.


In general I wouldn't recommend to be able to switch to root "su" without a password. You open a big gate in your system-protection there.


Be sure that the files in /etc/sudoers.d/ have the right permission. They only flag that must be set is the read-able-flag, not the execute- and write-able-flag. So if you do a ls -l /etc/sudoers.d/ all file-permissions should look like this:


"-r--r-----"


In order to edit the files you of course must make them writeable for the time of editing and after that unwrite-able again afterwards. Use "chmod" for that. Search for "man chmod" for a detailed description.


Next - as far as I can say you shouldn't have to make op_power.sh sudo-able without a password. Instead make the standby-script executable by the user (if it isn't already) and specify all the commands that the script contains and that are being called with "sudo" in front of it into a seperate-sudoers file (so you easily can find your modifications).


Since I am still running the old OS, I'm not sure if the format for a sudoers-file changed in the new OS, but for me a line within looks like this:



Code:
%wheel ALL=(ALL) NOPASSWD: /usr/pandora/scripts/op_cpuspeed.sh


Something like this should work as long as your user is in the "wheel"-group, which he/she/it should be by default.


While I'm not 100% sure what the first two sudoers-lines, which you posted, do, I would leave them out. They might open too much.


Last but not least an explanation: The daemon that triggers the lid is run as root, thus the standby-script also is run as root and works. If you assign it to a shortkey, it's run as user, which is why it doesn't work. Maybe you already got that, though. ;)


I hope this helps you fix it, although - as mentioned - I'm not that firm in sudo-related things.
 
Last edited by a moderator:
OK, here we go. I had no idea that wheel was a real group. I thought it was like a generic sample. As far as I knew, I was part of myusername group.


Also, /etc/sudoers seemed to be getting usurped by some other "more important" file. Here is the solution as a Bash Script. Which once created & Setup - WORKS as a Sleep Key!


Follow these instructions and then make a keyboard shortcut that calls:


/usr/bin/op_standby.


#!/bin/bash


# op_Standby.sh


# Assign this to a hotkey combo for instant SLEEP


sudo "/usr/pandora/scripts/op_power.sh" 0


# ======================================


# To make it a act as a standard command


# $ sudo cp ./bin/op_Standby.sh /usr/bin/op_standby


# PowerSettings require a password, therefore


# Edit the Sudoers list in nano or you'll break the file


#


# $ sudo nano \etc\sudoers.d\50_openpandora


# "Add the following to the top of the file"


# %wheel ALL=(ALL) NOPASSWD: /usr/pandora/scripts/op_power.sh
 
Last edited by a moderator:
Back
Top