本文介绍了放弃root权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个程序,它在启动时以 root 身份运行一堆任务.之后它需要下降到不同的用户.怎么做?
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?
只是想知道,是否可以在不重新启动程序的情况下重新获取 root 权限?
And just wondering, is it possible to reacquire root without relaunching the program?
推荐答案
简短的回答是使用 setuid()
函数.
The short answer is to use the setuid()
function.
切换到非root用户后无法重新获取root权限.
It is not possible to reacquire root privileges after switching to a non-root user.
这篇关于放弃root权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!