Setting userID on a running process


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Setting userID on a running process
# 1  
Old 05-20-2013
Setting userID on a running process

Hi Gurus
I have a process that starts as root then changes to nobody.
Its on a headless Arm5 pogoplug, and everything is running as root.
so it cant use mailx, and strangely login to a remote site.

I can get the PID, but I cant find anywhere an example of how to use setuid or set setgid to change the owner of the running process to root, so that if I :-
Code:
[root@Pogopig ~]# ps aux | grep noip2
nobody     262  0.0  0.3   1940   788 ?        Ss   14:31   0:00 /usr/bin/noip2 -c /etc/no-ip2.conf
root       314  0.0  0.3   4588   956 pts/0    S+   14:49   0:00 grep noip2

what I want to get is
Code:
[root@Pogopig ~]# ps aux | grep noip2
root    262  0.0  0.3   1940   788 ?        Ss   14:31   0:00 /usr/bin/noip2 -c /etc/no-ip2.conf
root       314  0.0  0.3   4588   956 pts/0    S+   14:49   0:00 grep noip2

I'm stuck on the syntax for
setuid root > PID of process
can someone help please
TIA
Richard
# 2  
Old 05-24-2013
The setgid and setuid bits work fine, but you must compile the command with -R (well, some option that says find dynamic libs by the compile-time dynamic library full paths, only) or entirely static linked, as the environment is cleared of $PATH and $LD_LIBRARY_PATH when changing IDs. This also tends to mess up all script interpreters, even if your script starts with a good #! line and has execute permissions and immediately resets environment. I would expect it is described in the exec() man pages. Man Page for execvp (opensolaris Section 2) - The UNIX and Linux Forums Man Page for setuid (opensolaris Section 2) - The UNIX and Linux Forums
# 3  
Old 05-27-2013
I understand you start it as root but it switches to nobody by means of setuid() and seteuid() calls.
I think you cannot undo that; there is no setuid that works on other processes, and a change of the user in /proc will fail.
# 4  
Old 05-28-2013
Well, I suppose you could code setuid(0) but how to get permission to re-enter root? I guess if you are still uid root, you should be able to change euid back. Otherwise, you need to exec a setuid executable to get the proc back to root.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Command to get exact tomcat process I am running ignoring other java process

Team, I have multiple batchjobs running in VM, if I do ps -ef |grep java or tomcat I am getting multiple process list. How do I get my exact tomcat process running and that is unique? via shell script? (4 Replies)
Discussion started by: Ghanshyam Ratho
4 Replies

2. UNIX for Advanced & Expert Users

Process remians in Running state causing other similar process to sleep and results to system hang

Hi Experts, I am facing one problem here which is one process always stuck in running state which causes the other similar process to sleep state . This causes my system in hanged state. On doing cat /proc/<pid>wchan showing the "__init_begin" in the output. Can you please help me here... (6 Replies)
Discussion started by: naveeng
6 Replies

3. UNIX for Advanced & Expert Users

Process remians in Running state causing other similar process to sleep and results to system hang

Hi Experts, I am facing one problem here which is one process always stuck in running state which causes the other similar process to sleep state . This causes my system in hanged state. On doing cat /proc/<pid>wchan showing the "__init_begin" in the output. Can you please help me here... (1 Reply)
Discussion started by: naveeng
1 Replies

4. BSD

Process remians in Running state causing other similar process to sleep and results to system hang

Hi Experts, I am facing one problem here which is one process always stuck in running state which causes the other similar process to sleep state . This causes my system in hanged state. On doing cat /proc/<pid>wchan showing the "__init_begin" in the output. Can you please help me here... (0 Replies)
Discussion started by: naveeng
0 Replies

5. Shell Programming and Scripting

Setting time for running of the script

Dear all, I wonder if it is possible that we can run the script from time to time..I meant, it should repeat the sourcing of the script by itself? In my case, I need to source this script manually from time to time, like once in every 10 minutes. emily, (2 Replies)
Discussion started by: emily
2 Replies

6. UNIX for Dummies Questions & Answers

How a process can check if a particular process is running on different machine?

I have process1 running on one machine and generating some log file. Now another process which can be launched on any machine wants to know if process1 is running or not and also in case it is running it wants to stream the logs file generated by process1 on terminal from which process2 is... (2 Replies)
Discussion started by: saurabhnsit2001
2 Replies

7. UNIX for Dummies Questions & Answers

Running different process from current process?

I have been having some trouble trying to get some code working, so I was wondering...what system calls are required to execute a different program from an already running process? (1 Reply)
Discussion started by: Midwest Product
1 Replies

8. Shell Programming and Scripting

script to monitor process running on server and posting a mail if any process is dead

Hello all, I would be happy if any one could help me with a shell script that would determine all the processes running on a Unix server and post a mail if any of the process is not running or aborted. Thanks in advance Regards, pradeep kulkarni. :mad: (13 Replies)
Discussion started by: pradeepmacha
13 Replies

9. UNIX for Advanced & Expert Users

How to create a dummy process of a process already running?

Hi Everybody, I want to create a shell script named as say "jip" and it is runned. And i want that when i do ps + grep for the process than this jip should be shown as process. Infact there might be process with name jip which is already running. (3 Replies)
Discussion started by: shambhu
3 Replies

10. Shell Programming and Scripting

How to kill a process and its childs given pid and userid

I need to write a shell script which would take 2 arguments pid , userid. Then it should kill all the child process under it. If a child process is not killed then it should wait for 1 minute and should kill. can anybody give me the idea to write it? (0 Replies)
Discussion started by: nani_g
0 Replies
Login or Register to Ask a Question