You are not logged in.

#1 2008-06-09 16:39:12

synorgy
Member
From: $HOME
Registered: 2005-07-11
Posts: 272
Website

writing to /sys as a normal user without authentication

Okay - I know the title of this post is not quite descriptive enough etc. I just don't know what to call it...


I'm trying to get my backlight working fully on my Sony Vaio PCG-GRT390ZP. I can modprobe the sony_laptop module and then echo the different values to the respective files like this:

# echo 5 > /sys/class/backlight/sony/brightness

I'm trying to get some python scripts written to handle the above command. (I'm using python because I'm more comfortable in that than in plain bash  / sh, and I have the python packages already.) Because of the scripting, I need to have write access in /sys as a normal user. I'm looking for the safest way to achieve this, as I can't imagine that

chown -R <user> users /sys

is safe at all. Any suggestions? Thanks a lot.


"Unix is basically a simple operating system, but you have to be a genius to understand the simplicity." (Dennis Ritchie)

Offline

#2 2008-06-09 18:08:50

Garns
Member
Registered: 2008-05-28
Posts: 239

Re: writing to /sys as a normal user without authentication

You could set the suid flag for your script.

chmod u+s /path/to/yourScript

Or you could use sudo yikes

Offline

#3 2008-06-10 02:18:08

synorgy
Member
From: $HOME
Registered: 2005-07-11
Posts: 272
Website

Re: writing to /sys as a normal user without authentication

Setting the suid flag for the scripts didn't seem to work, I think because the suid flag only affects binaries (though I could certainly be wrong - that's just what I read)

So I went ahead and added the lines I needed to my sudoers to launch this script as root  without a password every time it's run (Since all this does is change the screen brightness I think I should be pretty safe. Unless others have differing opinions?)

Thanks again for the brain jog. Sometimes that's all you need. (Now I just need to set up xbindkeys to launch these scripts I just wrote)


"Unix is basically a simple operating system, but you have to be a genius to understand the simplicity." (Dennis Ritchie)

Offline

Board footer

Powered by FluxBB