1 .\" Copyright (C), 1994, Graeme W. Wilford (Wilf).
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" Fri Jul 29th 12:56:44 BST 1994 Wilf. <G.Wilford@ee.surrey.ac.uk>
24 .\" Changes inspired by patch from Richard Kettlewell
25 .\" <richard@greenend.org.uk>, aeb 970616.
26 .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
27 .\" Added notes on capability requirements
28 .TH SETUID 2 2010-02-21 "Linux" "Linux Programmer's Manual"
30 setuid \- set user identity
32 .B #include <sys/types.h>
34 .B #include <unistd.h>
36 .BI "int setuid(uid_t " uid );
39 sets the effective user ID of the calling process.
40 If the effective UID of the caller is root,
41 the real UID and saved set-user-ID are also set.
45 is implemented like the POSIX version with the
48 This allows a set-user-ID (other than root) program to drop all of its user
49 privileges, do some un-privileged work, and then reengage the original
50 effective user ID in a secure manner.
52 If the user is root or the program is set-user-ID-root, special care must be
56 function checks the effective user ID of the caller and if it is
57 the superuser, all process-related user ID's are set to
59 After this has occurred, it is impossible for the program to regain root
62 Thus, a set-user-ID-root program wishing to temporarily drop root
63 privileges, assume the identity of an unprivileged user, and then regain
64 root privileges afterwards cannot use
66 You can accomplish this with
69 On success, zero is returned.
70 On error, \-1 is returned, and
78 does not match the current uid and
80 brings process over its
85 The user is not privileged (Linux: does not have the
89 does not match the real UID or saved set-user-ID of the calling process.
92 Not quite compatible with the 4.4BSD call, which
93 sets all of the real, saved, and effective user IDs.
94 .\" SVr4 documents an additional EINVAL error condition.
97 Linux has the concept of file system user ID, normally equal to the
101 call also sets the file system user ID of the calling process.
107 is different from the old effective uid, the process will
108 be forbidden from leaving core dumps.
114 .BR capabilities (7),