1SETUID(2) System Calls Manual SETUID(2)
2
3
4
6 setuid, seteuid,setgid,setegid - set user and group ID
7
9 #include <sys/types.h>
10 #include <unistd.h>
11
12 int
13 setuid(uid)
14 uid_t uid
15
16 int
17 seteuid(euid)
18 uid_t euid
19
20 int
21 setgid(gid)
22 gid_t gid
23
24 int
25 setegid(egid)
26 gid_t egid
27
29 The setuid function sets the real and effective user IDs and the saved
30 set-user-ID of the current process to the specified value. The setuid
31 function is permitted if the specified ID is equal to the real user ID
32 of the process, or if the effective user ID is that of the super user.
33
34 The setgid function sets the real and effective group IDs and the saved
35 set-group-ID of the current process to the specified value. The setgid
36 function is permitted if the specified ID is equal to the real group ID
37 of the process, or if the effective user ID is that of the super user.
38
39 The seteuid function (setegid) sets the effective user ID (group ID) of
40 the current process. The effective user ID may be set to the value of
41 the real user ID or the saved set-user-ID (see intro(2) and execve(2);
42 in this way, the effective user ID of a set-user-ID executable may be
43 toggled by switching to the real user ID, then re-enabled by reverting
44 to the set-user-ID value. Similarly, the effective group ID may be set
45 to the value of the real group ID or the saved set-user-ID.
46
48 Upon success, these functions return 0; otherwise -1 is returned.
49
50 If the user is not the super user, or the uid specified is not the
51 real, effective ID, or saved ID, these functions return -1.
52
54 getuid(2), getgid(2)
55
57 The setuid and setgid functions are compliant with the IEEE Std
58 1003.1-1988 (``POSIX'') specification with _POSIX_SAVED_IDS not
59 defined. The seteuid and setegid functions are extensions based on the
60 POSIX concept of _POSIX_SAVED_IDS , and have been proposed for a future
61 revision of the standard.
62
63
64
654.2 Berkeley Distribution December 3, 1997 SETUID(2)