netdata:检查当前是否是root权限运行
程序员文章站
2022-05-10 09:39:57
...
检查当前是否是root权限运行
static int am_i_running_as_root() {
uid_t uid = getuid(), euid = geteuid();
if(uid == 0 || euid == 0) {
printf("I am running with escalated privileges, uid = %u, euid = %u.\n", uid, euid);
return 1;
}
printf("I am not running with escalated privileges, uid = %u, euid = %u.\n", uid, euid);
return 0;
}
上一篇: Powershell运行脚本权限问题
下一篇: shell判断是否有root权限