(automatic) excution of a program in /usr/sbin as normal user
I have /usr/sbin/powertop (to minimize power consumption on my netbook) which I want to run automatically late during boot. It has set "-rwxr-xr-x". So I assumed "others" having set their "r-x" (e.g. users like me) can execute it. But I get the message:
Quote:
Any ideas what is causing this and how to change it without creating security holes? TIA. |
Quote:
|
Probably a stupid question but anyhow, why is it
Quote:
|
Notice the word 'may' in the msg; its just a warning.
Depending on how you call it, you may be able to suppress it. If you add it to the startup routines, worst case its just one extra msg amongst many, unless you reboot a lot(!) |
Well, no, it is not only a warning, since I'm thrown back to the prompt. "powertop" has a user interface which should otherwise be shown on the screen (sorry, I mixed two scenarios so as not to flood the forum with stupid questions).
|
In that case, its a badly written msg.
The boot process is run by root, so if its in there, you shouldn't get a problem unless you're trying to run it as someone else. If you want to run it as someone who is not root, try setting suid (as root) on the file. Code:
chmod u+s /usr/sbin/powertop |
Quote:
Quote:
Quote:
|
you could try a sym link to the executable in /usr/bin
|
I think it's hard coded into powertop to check that the user running it is root, at least that's what I get from the code here:
https://github.com/fenrus75/powertop...r/src/main.cpp Code:
static void checkroot() { |
Quote:
|
I'm afraid I don't, but would something like this help?
http://askubuntu.com/questions/11270...nges-permanent Not used it myself so can't vouch for it working. |
At least in post #9 the msg says 'must' be run as root; that's much clearer.
Wonder why OP gets a different msg; different version perhaps? Maybe you should contact the author. |
Quote:
|
Quote:
|
Well, that opened a whole new can of worms :rolleyes:.
I had (in part) already incorporated the procedure from your link, 273. I completed it now and thus have a script with all the desired commands. In principle I don't need to run "powertop" anymore, though I'd still like to know, whether these restrictions can be circumvented. Anyways. The normal user (myself) can run that script and it resides in KDE's Autostart directory. But it doesn't work :mad:. In the most cases access to the /proc and /sys directories (rather their subdirectories) is denied. Also commands like "hdparm", "ethtool" and "iw" are not found. When I "su" too root and run that script I get no error and everything is set as desired. So I'm back to step one. The same (i.e. nothing) happens, when I incorporate the commands from the script in the user's ".profile" or ".bashrc" files. Btw. chrism01, I checked with wikipedia, it says that most distributions disable the suid bit of script for security reasons. You also wrote that the init process is run by root. Thus I copied the script to /etc/init.d and created links at rc3.d and rc5.d. And lo and behold -- the script works as desired -- but only when I log in as root, and not so when I'm the normal user, even though "chkconfig" and YAST's runlevel editor show that the script is active and running. Seems that "systemd" is not always running as root?!? I don't understand this at all... |
Did you try adding the commands to /etc/rc.local as the link suggested? I'm not sure why that would be different to /etc/init.d/ scripts but it's worth a try?
|
SuSE hasn't got a rc.local, so I couldn't try that.
|
Re suid on scripts; I knew that but from post #9 it looked like powertop is a cpp thus binary exe.
Maybe its different for you, but normally the boot process has to run as root to do all the privileged things it needs to do, although some sub-processes may be run as a different user for their own reasons. On eg RHEL, you'd have have an entry in /etc/rc.d/rc.local like Code:
su - user -c "cmd args" |
I found out what SuSE did to rc.local ;), since Google is my friend :D. They created an "/etc/init.d/after.local", a "script with local commands to be executed from init after all scripts of a runlevel have been executed". I appended
Code:
su - root -c /etc/init.d/<my-script> Quote:
Quote:
Quote:
Code:
su - root -c "cmd >> /home/me/error.txt 2>&1" <edit2> Found out why: "su" is asking for a password. I created a test-script and ran that from console. [enter favourite expletives here]. What now? |
There is nothing "magical" about the /usr/sbin directory ...
|
Thanks for stating the obvious :). Do you also propose a solution for the Problem?
|
All times are GMT -5. The time now is 01:35 PM. |