I have a program which runs a bunch of tasks as root at launch. After that it needs to drop to a different user. How can that be done?
And just wondering, is it possible to reacquire root without relaunching the program?
I have a program which runs a bunch of tasks as root at launch. After that it needs to drop to a different user. How can that be done?
And just wondering, is it possible to reacquire root without relaunching the program?
The short answer is to use the setuid()
function.
It is not possible to reacquire root privileges after switching to a non-root user.