Give up root privilegies?

2020-04-10 04:37发布

问题:

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?

回答1:

The short answer is to use the setuid() function.

It is not possible to reacquire root privileges after switching to a non-root user.



标签: c++ root