LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to change a process running in root-user to non-root user ???????????????????? (http://www.linuxquestions.org/questions/linux-software-2/how-to-change-a-process-running-in-root-user-to-non-root-user-764951/)

narendra1310 10-28-2009 02:58 AM

How to change a process running in root-user to non-root user ????????????????????
 
Hi

Is It possible to change a process running in root-user to non-root-user by setting suid / uid / euid / gid etc...

I so please instruct how, when and wat to set in order to change a process running in root-user to non-root user ?

Thanks in Advance

acid_kewpie 10-28-2009 03:09 AM

you can't *change* the owner, but you can start it running as whoever you want during a boot up. If there is no automatic handling of this via the program itself (many programs will pull levers internally to become unpriviledged users once they no longer needs roots powers) then you can run a command via su, e.g. "su -l myotheruser -c runthiscommand" in your /etc/rc.local script for example.

narendra1310 10-28-2009 04:20 AM

My daemon is in "/etc/init.d/"

For verfication purpose
I run your command "su -l myotheruser -c runthiscommand". manually as a root-user shown below.

[root@lin4 storage]# su -l test -c "chroot /home/test/builds/server/schroot /apache/bin/httpd -k start"

I faced this error
chroot: cannot change root directory to /home/test/builds/server/schroot: Operation not permitted

wheather I need to run the command as a non-root user ????

for your reference
ls -l /home/test/builds/server/
drwxrwxrwx 12 test test 4096 2009-10-27 20:34 schroot





Quote:

Originally Posted by acid_kewpie (Post 3735023)
you can't *change* the owner, but you can start it running as whoever you want during a boot up. If there is no automatic handling of this via the program itself (many programs will pull levers internally to become unpriviledged users once they no longer needs roots powers) then you can run a command via su, e.g. "su -l myotheruser -c runthiscommand" in your /etc/rc.local script for example.


narendra1310 10-28-2009 04:27 AM

if i run directly chroot as a root-user, then it is working
as shown below

[root@lin4 storage]# chroot /home/test/builds/server/schroot /apache/bin/httpd -k start


For your reference
[root@lin4 Storage]# ps aux |grep httpd
root 28251 0.8 0.3 17072 6744 ? Ss 14:58 0:00 /apache/bin/httpd -k start

acid_kewpie 10-29-2009 02:11 AM

Well apache is really not a good example for using this, esp wil chroot. httpd will normally run as a different user, e.g. web or httpd or nobody, so there's no need to externally fudge something like this, in the same way there are proper ways to chroot it too.
http://www.securityfocus.com/infocus/1694


All times are GMT -5. The time now is 05:42 AM.