Change owner of a currently running process
You cannot do that, there's no such syscall. However, depending on how you want to affect the process, you could try some hack if the process is not critical to your system.
(gdb) attach process_id (gdb) call putenv ("UID=1234") (gdb) call putenv ("EUID=1234") (gdb) call putenv ("GID=1234") (gdb) detach
Note that this WILL NOT WORK:
(gdb) call setuid(1234)
This does not really answer to your question (change the owner of a running process), but considering that you may want to change the owner to affect something about the process, maybe this hack help.
Remember that it's very likely that this breaks your process.
(based on this: Is there a way to change another process's environment variables?)
I am not, therefore I do not think.Updated on June 04, 2022
Skam 8 months
I have a process that is currently running with pid,
$PID, and owned by the user
foowhich is not root. I want to transfer the ownership of this process to another user
barwhich is also not root.
Is there a shell command that changes the owner of a process? I'm thinking of a
chownbut for processes that looks something like.
chownproc [option] PID
This question and this question are similar, but not quite what I'm looking for and
chownman pages doesn't say anything about processes, only files.
If there isn't, is there a reason why this hasn't been done or isn't possible?