1 .\" Copyright (C), 1994, Graeme W. Wilford (Wilf).
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" Fri Jul 29th 12:56:44 BST 1994 Wilf. <G.Wilford@ee.surrey.ac.uk>
26 .\" Changes inspired by patch from Richard Kettlewell
27 .\" <richard@greenend.org.uk>, aeb 970616.
28 .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
29 .\" Added notes on capability requirements
30 .TH SETUID 2 2010-11-22 "Linux" "Linux Programmer's Manual"
32 setuid \- set user identity
34 .B #include <sys/types.h>
36 .B #include <unistd.h>
38 .BI "int setuid(uid_t " uid );
41 sets the effective user ID of the calling process.
42 If the effective UID of the caller is root,
43 the real UID and saved set-user-ID are also set.
47 is implemented like the POSIX version with the
50 This allows a set-user-ID (other than root) program to drop all of its user
51 privileges, do some un-privileged work, and then reengage the original
52 effective user ID in a secure manner.
54 If the user is root or the program is set-user-ID-root, special care must be
58 function checks the effective user ID of the caller and if it is
59 the superuser, all process-related user ID's are set to
61 After this has occurred, it is impossible for the program to regain root
64 Thus, a set-user-ID-root program wishing to temporarily drop root
65 privileges, assume the identity of an unprivileged user, and then regain
66 root privileges afterward cannot use
68 You can accomplish this with
71 On success, zero is returned.
72 On error, \-1 is returned, and
80 does not match the current uid and
82 brings process over its
87 The user is not privileged (Linux: does not have the
91 does not match the real UID or saved set-user-ID of the calling process.
94 Not quite compatible with the 4.4BSD call, which
95 sets all of the real, saved, and effective user IDs.
96 .\" SVr4 documents an additional EINVAL error condition.
98 Linux has the concept of the filesystem user ID, normally equal to the
102 call also sets the filesystem user ID of the calling process.
108 is different from the old effective UID, the process will
109 be forbidden from leaving core dumps.
113 system call supported only 16-bit user IDs.
114 Subsequently, Linux 2.4 added
116 supporting 32-bit IDs.
119 wrapper function transparently deals with the variation across kernel versions.
125 .BR capabilities (7),
128 This page is part of release 3.67 of the Linux
131 A description of the project,
132 information about reporting bugs,
133 and the latest version of this page,
135 \%http://www.kernel.org/doc/man\-pages/.