On Linux, how can I change EUID of running process from command line (provided I have root access)?
|
feedback
|
|
If the process is running with root-privileges, you could attach gdb to the process and call seteuid from within that process. Example:
| |||||||
feedback
|
|
If you are talking about a process changing its own EUID, there are a bunch of ways to do that.
Depending on the effective UID of the program, and whether there is a saved UID, you may be able to switch between two EUID values in a non-root program. With a root privileged program, you have to be careful - you have to decide whether the change should be irreversible, and use the correct function for the job. (Using setuid() as root is irreversible.) If you are trying to change a process that's already running from a separate process, then there is no standard way to do it - and I'm not sure there are many non-standard ways, either. You might be able to dink some information in /dev/kmem, but the expression 'thin ice' springs to mind. | ||||
|
feedback
|
|
You must have a goal in mind. What is it? What is the purpose of the existing running process? Since you say you have root access it is not to get around security issue. | |||
|
feedback
|
|
There's no way to do this "from the commandline" to just any running process. I can say that with some sureness; the only "maybe" was /proc and I poked around in there (literally and via google) and ran into a dead-end regarding anything in /proc allowing for changing the EUID. You can LEARN what the UID and GID settings are in /proc/{pid}/status - but you can't change them using anything in /proc, at least as far as I can tell. But it's easy enough to make something like that work -- a way to change the EUID of a process, from the commandline -- if you control the source code of the process you want to change. You can implement a signal handler for say SIGUSR1 and have the process change its own EUID however you need when it receives that signal. Then you would simply send the process that SIGUSR1 signal, via "kill" ...from the commandline, as you've asked... and it would change its EUID for you. This might not be what you were thinking of, but... it's an answer to your question of how to do it... and it's the only answer I can think of. | |||
|
feedback
|