Search code examples
linuxunixrootsetuid

Linux, the only way to GAIN root access is executing a setuid-root file?


Is my assumption true, that on Unix/Linux, the only way to GAIN root access is to execute a setuid-root file?

In other words, the system calls setuid(), setgid() are all about DROPPING privileges?

Please note that my question is not about exploits.


Solution

  • That's true. The only way for a non-root process (assuming it's running a non-setuid program) to become root is to exec a setuid program. If it's running a set-uid root program, then its effective uid is root and real uid is whoever ran it. It can then do setuid(0) to make its real uid 0.