in reply to How to change the userid of a running external process

I believe that changing the uid of a different process can only happen with some deep kernel voodooo. The way it is typically done (via su / sudo) is such:

  1. root process forks
  2. root process drops privileges
  3. now non-root process fork/execs to the new process

If the process is trusted, it may only do steps 1 and 2, and possibly retake privileges later.

See the $<, $>, $(, and $) variables in perlvar.

Update: added links

Update 2: This is not an endeavor to be take lightly. Test for success on everything involving dropping your privileges. Understand the implications of what you are attempting to do. Root escalations have occurred because assumptions made by an application were violated.

--MidLifeXis

  • Comment on Re: How to change the userid of a running external process

Replies are listed 'Best First'.
Re^2: How to change the userid of a running external process
by morgon (Priest) on Jul 21, 2010 at 20:18 UTC
    You describe a way for a root-process to fork a *NEW* process with a different effective UID.

    But the question was a bit weirder (if I understand if correctly) namely weather it is possible to change the id of a RUNNING process.

    And I believe the answer to that is no - at least not with normal syscalls and certainly not with Perl.