You are not logged in.
Well, the title explains my question for the most part. I'm trying to start a program when the computer boots as a non-root user, like apache uses the httpd user. i tried searching on multiple subjects, but have not found anything that works. could someone please help me out? thanks!
loading.... please wait....
Offline
You could always use sudo to do it.
I am a gated community.
Offline
Offline
Well, the title explains my question for the most part. I'm trying to start a program when the computer boots as a non-root user, like apache uses the httpd user. i tried searching on multiple subjects, but have not found anything that works. could someone please help me out? thanks!
You don't want to run Apache as httpd. It needs the root priveleges to bind to port 80 (normal user processes are restricted to ports at 1024 and higher). Don't worry though! Once it binds properly and is listening for incoming HTTP requests, it will drop all root priveleges.
If you really want to though:
$ man su
Hope that helps!
~Peter~
Offline
Well,
the program's start script is weird, and requires me to 'cd' to the directory and then run the `./program start`. i'm assuming the su with the -c flag could work on server bootup, but I want to get the command working manually first (ie. just using the su command from a shell before i try to put the command in something like rc.local or whatever).
edit: the -c flag wont' let me run more than one command, even with ';' between like you can in the shell.
i would have thought there would have been an easier way to start a program as another user on bootup...
loading.... please wait....
Offline
su rayzor -c "command 1 && command 2 && command 3"
should work, unless you're expecting one of the commands in the chain to fail.
Offline
Note that using su to get right privileges doesn't automatically setup the environment, variables, paths etc.
The following way is the only which I have found to provide full functionality, i.e. the same behaviour as if I login.
/bin/su USER -l -c "/bin/bash --login -c COMMAND"
where command is whatever you want. I use it in /etc/inittab to start X automatically with, you can surely put it in rc.local
You can also try it out on the command line if you want to.
#348498 +(4737)- [X]
<MasterG> .....................................................................
..................................
<judas> where's pacman when you need him?
Offline
Write an init script? Seriously.
Unthinking respect for authority is the greatest enemy of truth.
-Albert Einstein
Offline
rayzorblayde wrote:Well, the title explains my question for the most part. I'm trying to start a program when the computer boots as a non-root user, like apache uses the httpd user. i tried searching on multiple subjects, but have not found anything that works. could someone please help me out? thanks!
You don't want to run Apache as httpd. It needs the root priveleges to bind to port 80 (normal user processes are restricted to ports at 1024 and higher). Don't worry though! Once it binds properly and is listening for incoming HTTP requests, it will drop all root priveleges.
If you really want to though:
$ man su
Hope that helps!
Running Apache under root can be dangerous. There was an instance on my webserver where I had a non-root account running Apache, yet some malicious internet user was able to have certain controls to the webserver (through some insecurities in Apache.) Had I have Apache run as root, he/she would have TOTAL access to my server.
This signature just crossed the line.
Offline
Running Apache under root can be dangerous. There was an instance on my webserver where I had a non-root account running Apache, yet some malicious internet user was able to have certain controls to the webserver (through some insecurities in Apache.) Had I have Apache run as root, he/she would have TOTAL access to my server.
It seems as though you didn't even read what I wrote.
You don't want to run Apache as httpd. It needs the root priveleges to bind to port 80 (normal user processes are restricted to ports at 1024 and higher). Don't worry though! Once it binds properly and is listening for incoming HTTP requests, it will drop all root priveleges.
~Peter~
Offline
No, I read what you wrote.
I wasn't disagreeing with you or construing what you said was wrong. I was sharing my experience with something I had encountered (on a dedicated server that I'm renting) that was related to this subject. My main point was that security is very important and shouldn't be overlooked, especially running a busy webserver. And yes, I also agree with you on your previous statement; I also avoid running Apache under httpd. A normal not-so-obvious account is used to run Apache in my case. Hope that clarify things out.
This signature just crossed the line.
Offline
But running apache with just another user means no security enhancement. To put it into a (hardened) chroot prison would do.
Offline