IPB
>  Man Pages > Unix > FreeBSD 6.2 > Section 2 > setuid man page

setuid man page

Section 2 - FreeBSD 6.2 Man Pages

Other operating system man pages available here


Advanced Search

Hopefully, this page is exactly what you are looking for, but if not, you can always find further assistance on Unix/Linux Forum!


SETUID(2)                 FreeBSD System Calls Manual                SETUID(2)


NAME

     setuid, seteuid, setgid, setegid -- set user and group ID


LIBRARY

     Standard C Library (libc, -lc)


SYNOPSIS

     #include <sys/types.h>
     #include <unistd.h>

     int
     setuid(uid_t uid);

     int
     seteuid(uid_t euid);

     int
     setgid(gid_t gid);

     int
     setegid(gid_t egid);


DESCRIPTION

     The setuid() system call sets the real and effective user IDs and the
     saved set-user-ID of the current process to the specified value.  The
     setuid() system call is permitted if the specified ID is equal to the
     real user ID or the effective user ID of the process, or if the effective
     user ID is that of the super user.

     The setgid() system call sets the real and effective group IDs and the
     saved set-group-ID of the current process to the specified value.  The
     setgid() system call is permitted if the specified ID is equal to the
     real group ID or the effective group ID of the process, or if the effec-
     tive user ID is that of the super user.

     The seteuid() system call (setegid()) sets the effective user ID (group
     ID) of the current process.  The effective user ID may be set to the
     value of the real user ID or the saved set-user-ID (see intro(2) and
     execve(2)); in this way, the effective user ID of a set-user-ID exe-
     cutable may be toggled by switching to the real user ID, then re-enabled
     by reverting to the set-user-ID value.  Similarly, the effective group ID
     may be set to the value of the real group ID or the saved set-group-ID.


RETURN VALUES

     Upon successful completion, the value 0 is returned; otherwise the
     value -1 is returned and the global variable errno is set to indicate the
     error.


ERRORS

     The system calls will fail if:

     [EPERM]            The user is not the super user and the ID specified is
                        not the real, effective ID, or saved ID.


SECURITY CONSIDERATIONS

     Read and write permissions to files are determined upon a call to
     open(2).  Once a file descriptor is open, dropping privilege does not
     affect the process's read/write permissions, even if the user ID speci-
     fied has no read or write permissions to the file.  These files normally
     remain open in any new process executed, resulting in a user being able
     to read or modify potentially sensitive data.

     To prevent these files from remaining open after an exec(3) call, be sure
     to set the close-on-exec flag is set:

     void
     pseudocode(void)
     {
             int fd;
             /* ... */

             fd = open("/path/to/sensitive/data", O_RDWR);
             if (fd == -1)
                     err(1, "open");

             /*
              * Set close-on-exec flag; see fcntl(2) for more information.
              */
             if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
                     err(1, "fcntl(F_SETFD)");
             /* ... */
             execve(path, argv, environ);
     }


SEE ALSO

     getgid(2), getuid(2), issetugid(2), setregid(2), setreuid(2)


STANDARDS

     The setuid() and setgid() system calls are compliant with the ISO/IEC
     9945-1:1990 (``POSIX.1'') specification with _POSIX_SAVED_IDS not defined
     with the permitted extensions from Appendix B.4.2.2.  The seteuid() and
     setegid() system calls are extensions based on the POSIX concept of
     _POSIX_SAVED_IDS, and have been proposed for a future revision of the
     standard.


HISTORY

     The setuid() and setgid() functions appeared in Version 7 AT&T UNIX.

FreeBSD 6.2                      June 4, 1993                      FreeBSD 6.2


Man(1) output converted with man2html and wrapped by fishsponge

This page was generated on Wed Sep 19 20:04:01 BST 2007

Your favourite pages:

No pages logged yet.
Trying to save cookie...

Top 10 most popular pages:

sqlite3 man page (5327 hits)
(openSUSE 10.2)

svn man page (5200 hits)
(FreeBSD 6.2)

adv_cap_autoneg man page (4869 hits)
(Solaris 10 11_06)

CPAN man page (4604 hits)
(Suse Linux 10.1)

ssh man page (4341 hits)
(Suse Linux 10.1)

ssh-socks5-proxy-connect man page (2863 hits)
(Solaris 10 11_06)

netcat man page (2705 hits)
(Suse Linux 10.1)

pprosetup man page (2480 hits)
(Solaris 10 11_06)

startproc man page (2470 hits)
(Suse Linux 10.1)

signal man page (2400 hits)
(Suse Linux 10.1)

Useful Links

Go Back

Visitor Statistics


Valid XHTML 1.0 Transitional     Valid CSS!

Partners: Cambridge Plus :: PYRENEES ACTIVITY HOLIDAYS :: USB Temperature Monitor :: <Link Available>
Unix Man Pages / Linux Man Pages :: HiFi Forum :: SIP VoIP Phone & Provider Reviews :: UNIX/Linux Forum Archives

More info on advertising on Unix/Linux Forum