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'd like to know what I need to do to enable a user to modify values in /sys. As it's a sysfs, changing file permissions is not an option (and I don't like to do it on every boot).

share|improve this question
    
I don't think it can be done, cpufreq does not change it with a regular user, it communicates with a power daemon (which runs as root) via DBUS, it's the root process doing the change, not an user process. –  João Pinto Jan 7 '11 at 12:05
    
True, but in the end the user has (indirect) write access to /sys without providing a password (in case of the cpufreq example) - which is what I want. So I guess the key here seems to be PolicyKit. –  htorque Jan 7 '11 at 13:36

3 Answers 3

You need to use sudo. If you only want to give them permission to modify a specific value without general sudo access, then you can write a script that updates that particular value, and configure your sudoers file to allow the user permission ONLY to run that script as root.

share|improve this answer
    
I guess that's basically the same as my PolicyKit solution, which I prefer as I don't have to modify ´/etc/sudoers´. –  htorque Jan 8 '11 at 11:23

You should clarify what do you want to obtain. Maybe you want to modify /etc/sysctl.conf, see man sysctl and man sysctl.conf

share|improve this answer
    
Well, I'd like to change a value on-the-fly as user. This has to be possible, as the cpufreq gnome applet does the same using a D-Bus service and a PolicyKit policy - how exactly (well, a rough outline) is what I'd like to know, not being good at reading code. :P –  htorque Jan 7 '11 at 10:36
    
If you read the first man page, you saw that you can do it at runtime. As user you should use sudo. –  enzotib Jan 7 '11 at 10:43
    
I don't want to use sudo. –  htorque Jan 7 '11 at 10:56
    
I don't think you can modify system parameters as a user. –  enzotib Jan 7 '11 at 11:15
up vote 2 down vote accepted

I found a simple python/dbus/polkit example on the Ubuntuforums and changed the PolicyKit policy file defaults from

<defaults>
  <allow_any>auth_admin_keep</allow_any>
  <allow_inactive>auth_admin_keep</allow_inactive>
  <allow_active>auth_admin_keep</allow_active>
</defaults>

to

<defaults>
  <allow_any>no</allow_any>
  <allow_inactive>no</allow_inactive>
  <allow_active>yes</allow_active>
</defaults>

With this change, an unprivileged user now can communicate with the service (running as root, thus being able to write to /sys) without having to type a password (possible risks?).

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.