【发布时间】:2017-07-30 15:31:51
【问题描述】:
我使用的是 Ubuntu 16.10。
我跟着一本书,做这样的事情:
#include <stdio.h>
int main() {
printf("Real UID:\t%d\n", getuid());
printf("Effective UID:\t%d\n", geteuid());
}
为了在不使用 sudo 命令的情况下以 sudo 运行此文件,在使用 gcc 编译后,我将所有者和组更改为 root。
$ gcc -o test test.c
$ sudo chown root:root ./test
$ chmod u+s ./test
$ ls -l
-rwsr-xr-x 1 root root 8512 Mar 9 test
现在,这是我执行文件时得到的。我的 UID 是 1000。
$ ./test
Real UID: 1000
Effective UID: 1000
我正在看的书说结果应该是这样的:
$ ./test
Real UID: 1000
Effective UID: 0
root 的 UID 是 0,对吧?这是否意味着我正在运行一个 -rwsr-xr-x 文件,该文件由 root 拥有,具有我自己的用户权限?我不明白。
【问题讨论】:
-
我想知道这个问题是否更适合Ubuntu SE site。
-
@FredLarson 你是对的......
标签: c ubuntu permissions suid