2016-11-22 160 views
3

迄今为止我所读到的所有文献都在setuid中,以暗示它是系统调用的方式谈论seteuid。第2节man页面从不会说功能是否是系统调用,所以seteuid(2)没有帮助。如果它不是系统调用,意味着内核不提供该功能,那么如何实现“设置有效的UID”?在Linux上seteuid系统调用?

回答

6

第2节手册页是全部系统调用 - 这是第2节的用途。第3节手册页都是库调用,因为这是第3节的目的。对于部分名单见人(1)(手册页man本身)和他们是什么:

1 Executable programs or shell commands 
    2 System calls (functions provided by the kernel) 
    3 Library calls (functions within program libraries) 
    4 Special files (usually found in /dev) 
    5 File formats and conventions eg /etc/passwd 
    6 Games 
    7 Miscellaneous (including macro packages and conventions), e.g. 
     man(7), groff(7) 
    8 System administration commands (usually only for root) 
    9 Kernel routines [Non standard] 
0

您可以轻松地或验证,如果它是一个系统调用,如果它是在libc中编写一个定义小程序和运行strace就可以了。例如,

int main() { 
    seteuid(); 
} 
gcc -o main main.c 
-bash-4.2$ strace ./main 2>&1 | grep set 
setresuid(-1, 1, -1)     = -1 EPERM (Operation not permitted) 

所以在这种情况下,seteuid是在libc中实现的。实施​​