2016-11-22 50 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中實現的。實施​​