xref: /freebsd-14.2/lib/libc/sys/execve.2 (revision b2c76c41)
158f0484fSRodney W. Grimes.\" Copyright (c) 1980, 1991, 1993
258f0484fSRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
358f0484fSRodney W. Grimes.\"
458f0484fSRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
558f0484fSRodney W. Grimes.\" modification, are permitted provided that the following conditions
658f0484fSRodney W. Grimes.\" are met:
758f0484fSRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
858f0484fSRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
958f0484fSRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
1058f0484fSRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
1158f0484fSRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
12fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors
1358f0484fSRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
1458f0484fSRodney W. Grimes.\"    without specific prior written permission.
1558f0484fSRodney W. Grimes.\"
1658f0484fSRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1758f0484fSRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1858f0484fSRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1958f0484fSRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2058f0484fSRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2158f0484fSRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2258f0484fSRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2358f0484fSRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2458f0484fSRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2558f0484fSRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2658f0484fSRodney W. Grimes.\" SUCH DAMAGE.
2758f0484fSRodney W. Grimes.\"
285faf00b5SPeter Wemm.\"     @(#)execve.2	8.5 (Berkeley) 6/1/94
2958f0484fSRodney W. Grimes.\"
30*773fa8cdSKyle Evans.Dd January 26, 2022
3158f0484fSRodney W. Grimes.Dt EXECVE 2
32a307d598SRuslan Ermilov.Os
3358f0484fSRodney W. Grimes.Sh NAME
34a141af69SKonstantin Belousov.Nm execve ,
35a141af69SKonstantin Belousov.Nm fexecve
3658f0484fSRodney W. Grimes.Nd execute a file
3725bb73e0SAlexey Zelkin.Sh LIBRARY
3825bb73e0SAlexey Zelkin.Lb libc
3958f0484fSRodney W. Grimes.Sh SYNOPSIS
4032eef9aeSRuslan Ermilov.In unistd.h
4158f0484fSRodney W. Grimes.Ft int
4258f0484fSRodney W. Grimes.Fn execve "const char *path" "char *const argv[]" "char *const envp[]"
43a141af69SKonstantin Belousov.Ft int
44a141af69SKonstantin Belousov.Fn fexecve "int fd" "char *const argv[]" "char *const envp[]"
4558f0484fSRodney W. Grimes.Sh DESCRIPTION
461f2cec10SGiorgos KeramidasThe
471f2cec10SGiorgos Keramidas.Fn execve
482faeeff4SRuslan Ermilovsystem call
4958f0484fSRodney W. Grimestransforms the calling process into a new process.
5058f0484fSRodney W. GrimesThe new process is constructed from an ordinary file,
5158f0484fSRodney W. Grimeswhose name is pointed to by
5258f0484fSRodney W. Grimes.Fa path ,
5358f0484fSRodney W. Grimescalled the
5458f0484fSRodney W. Grimes.Em new process file .
55a141af69SKonstantin BelousovThe
56a141af69SKonstantin Belousov.Fn fexecve
57a141af69SKonstantin Belousovsystem call is equivalent to
58a141af69SKonstantin Belousov.Fn execve
59a141af69SKonstantin Belousovexcept that the file to be executed is determined by the file
60a141af69SKonstantin Belousovdescriptor
61a141af69SKonstantin Belousov.Fa fd
62a141af69SKonstantin Belousovinstead of a
63a141af69SKonstantin Belousov.Fa path .
6458f0484fSRodney W. GrimesThis file is either an executable object file,
6558f0484fSRodney W. Grimesor a file of data for an interpreter.
6658f0484fSRodney W. GrimesAn executable object file consists of an identifying header,
6758f0484fSRodney W. Grimesfollowed by pages of data representing the initial program (text)
681a0a9345SRuslan Ermilovand initialized data pages.
691a0a9345SRuslan ErmilovAdditional pages may be specified
7058f0484fSRodney W. Grimesby the header to be initialized with zero data; see
7114477795SMaxim Sobolev.Xr elf 5
7214477795SMaxim Sobolevand
7358f0484fSRodney W. Grimes.Xr a.out 5 .
7458f0484fSRodney W. Grimes.Pp
7558f0484fSRodney W. GrimesAn interpreter file begins with a line of the form:
7658f0484fSRodney W. Grimes.Pp
7746eea498SRuslan Ermilov.Bd -ragged -offset indent -compact
7858f0484fSRodney W. Grimes.Sy \&#!
7958f0484fSRodney W. Grimes.Em interpreter
8058f0484fSRodney W. Grimes.Bq Em arg
8158f0484fSRodney W. Grimes.Ed
8258f0484fSRodney W. Grimes.Pp
8358f0484fSRodney W. GrimesWhen an interpreter file is
84ed1fa5e0SMike Pritchard.Sy execve Ap d ,
85ccb277deSAdam Davidthe system actually
86ed1fa5e0SMike Pritchard.Sy execve Ap s
87ccb277deSAdam Davidthe specified
8858f0484fSRodney W. Grimes.Em interpreter .
8958f0484fSRodney W. GrimesIf the optional
9058f0484fSRodney W. Grimes.Em arg
9158f0484fSRodney W. Grimesis specified, it becomes the first argument to the
9258f0484fSRodney W. Grimes.Em interpreter ,
9358f0484fSRodney W. Grimesand the name of the originally
94ed1fa5e0SMike Pritchard.Sy execve Ap d
9558f0484fSRodney W. Grimesfile becomes the second argument;
9658f0484fSRodney W. Grimesotherwise, the name of the originally
97ed1fa5e0SMike Pritchard.Sy execve Ap d
981a0a9345SRuslan Ermilovfile becomes the first argument.
991a0a9345SRuslan ErmilovThe original arguments are shifted over to
100d9b1c37cSBen Smithurstbecome the subsequent arguments.
101d9b1c37cSBen SmithurstThe zeroth argument is set to the specified
102d9b1c37cSBen Smithurst.Em interpreter .
10358f0484fSRodney W. Grimes.Pp
10458f0484fSRodney W. GrimesThe argument
10558f0484fSRodney W. Grimes.Fa argv
10658f0484fSRodney W. Grimesis a pointer to a null-terminated array of
10758f0484fSRodney W. Grimescharacter pointers to null-terminated character strings.
10858f0484fSRodney W. GrimesThese strings construct the argument list to be made available to the new
1091a0a9345SRuslan Ermilovprocess.
1101a0a9345SRuslan ErmilovAt least one argument must be present in
11158f0484fSRodney W. Grimesthe array; by custom, the first element should be
11258f0484fSRodney W. Grimesthe name of the executed program (for example, the last component of
11358f0484fSRodney W. Grimes.Fa path ) .
11458f0484fSRodney W. Grimes.Pp
11558f0484fSRodney W. GrimesThe argument
11658f0484fSRodney W. Grimes.Fa envp
11758f0484fSRodney W. Grimesis also a pointer to a null-terminated array of
11858f0484fSRodney W. Grimescharacter pointers to null-terminated strings.
11958f0484fSRodney W. GrimesA pointer to this array is normally stored in the global variable
12058f0484fSRodney W. Grimes.Va environ .
12158f0484fSRodney W. GrimesThese strings pass information to the
12258f0484fSRodney W. Grimesnew process that is not directly an argument to the command (see
12358f0484fSRodney W. Grimes.Xr environ 7 ) .
12458f0484fSRodney W. Grimes.Pp
12558f0484fSRodney W. GrimesFile descriptors open in the calling process image remain open in
12658f0484fSRodney W. Grimesthe new process image, except for those for which the close-on-exec
12758f0484fSRodney W. Grimesflag is set (see
12858f0484fSRodney W. Grimes.Xr close 2
12958f0484fSRodney W. Grimesand
13058f0484fSRodney W. Grimes.Xr fcntl 2 ) .
13158f0484fSRodney W. GrimesDescriptors that remain open are unaffected by
13258f0484fSRodney W. Grimes.Fn execve .
13348797398SGarrett WollmanIf any of the standard descriptors (0, 1, and/or 2) are closed at the
13448797398SGarrett Wollmantime
13548797398SGarrett Wollman.Fn execve
13648797398SGarrett Wollmanis called, and the process will gain privilege as a result of set-id
13748797398SGarrett Wollmansemantics, those descriptors will be re-opened automatically.
13848797398SGarrett WollmanNo programs, whether privileged or not, should assume that these descriptors
13948797398SGarrett Wollmanwill remain closed across a call to
14048797398SGarrett Wollman.Fn execve .
14158f0484fSRodney W. Grimes.Pp
14258f0484fSRodney W. GrimesSignals set to be ignored in the calling process are set to be ignored in
14358f0484fSRodney W. Grimesthe
144c6ff3a1bSSheldon Hearnnew process.
145c6ff3a1bSSheldon HearnSignals which are set to be caught in the calling process image
14658f0484fSRodney W. Grimesare set to default action in the new process image.
14758f0484fSRodney W. GrimesBlocked signals remain blocked regardless of changes to the signal action.
14858f0484fSRodney W. GrimesThe signal stack is reset to be undefined (see
14958f0484fSRodney W. Grimes.Xr sigaction 2
15058f0484fSRodney W. Grimesfor more information).
15158f0484fSRodney W. Grimes.Pp
15258f0484fSRodney W. GrimesIf the set-user-ID mode bit of the new process image file is set
15358f0484fSRodney W. Grimes(see
15458f0484fSRodney W. Grimes.Xr chmod 2 ) ,
15558f0484fSRodney W. Grimesthe effective user ID of the new process image is set to the owner ID
15658f0484fSRodney W. Grimesof the new process image file.
15758f0484fSRodney W. GrimesIf the set-group-ID mode bit of the new process image file is set,
15858f0484fSRodney W. Grimesthe effective group ID of the new process image is set to the group ID
15958f0484fSRodney W. Grimesof the new process image file.
16058f0484fSRodney W. Grimes(The effective group ID is the first element of the group list.)
16158f0484fSRodney W. GrimesThe real user ID, real group ID and
16258f0484fSRodney W. Grimesother group IDs of the new process image remain the same as the calling
16358f0484fSRodney W. Grimesprocess image.
16458f0484fSRodney W. GrimesAfter any set-user-ID and set-group-ID processing,
16558f0484fSRodney W. Grimesthe effective user ID is recorded as the saved set-user-ID,
16658f0484fSRodney W. Grimesand the effective group ID is recorded as the saved set-group-ID.
16758f0484fSRodney W. GrimesThese values may be used in changing the effective IDs later (see
16858f0484fSRodney W. Grimes.Xr setuid 2 ) .
16958f0484fSRodney W. Grimes.Pp
170e21de373STim VanderhoekThe set-ID bits are not honored if the respective file system has the
1715c564baeSRuslan Ermilov.Cm nosuid
1721a0a9345SRuslan Ermilovoption enabled or if the new process file is an interpreter file.
1731a0a9345SRuslan ErmilovSyscall
174e21de373STim Vanderhoektracing is disabled if effective IDs are changed.
175e21de373STim Vanderhoek.Pp
17658f0484fSRodney W. GrimesThe new process also inherits the following attributes from
17758f0484fSRodney W. Grimesthe calling process:
17858f0484fSRodney W. Grimes.Pp
17958f0484fSRodney W. Grimes.Bl -column parent_process_ID -offset indent -compact
18058f0484fSRodney W. Grimes.It process ID Ta see Xr getpid 2
18158f0484fSRodney W. Grimes.It parent process ID Ta see Xr getppid 2
18258f0484fSRodney W. Grimes.It process group ID Ta see Xr getpgrp 2
18358f0484fSRodney W. Grimes.It access groups Ta see Xr getgroups 2
18458f0484fSRodney W. Grimes.It working directory Ta see Xr chdir 2
18558f0484fSRodney W. Grimes.It root directory Ta see Xr chroot 2
18658f0484fSRodney W. Grimes.It control terminal Ta see Xr termios 4
18758f0484fSRodney W. Grimes.It resource usages Ta see Xr getrusage 2
18858f0484fSRodney W. Grimes.It interval timers Ta see Xr getitimer 2
18958f0484fSRodney W. Grimes.It resource limits Ta see Xr getrlimit 2
19058f0484fSRodney W. Grimes.It file mode mask Ta see Xr umask 2
191c84cab56SJilles Tjoelker.It signal mask Ta see Xr sigaction 2 ,
192c84cab56SJilles Tjoelker.Xr sigprocmask 2
19358f0484fSRodney W. Grimes.El
19458f0484fSRodney W. Grimes.Pp
19558f0484fSRodney W. GrimesWhen a program is executed as a result of an
19658f0484fSRodney W. Grimes.Fn execve
1972faeeff4SRuslan Ermilovsystem call, it is entered as follows:
19858f0484fSRodney W. Grimes.Bd -literal -offset indent
19958f0484fSRodney W. Grimesmain(argc, argv, envp)
20058f0484fSRodney W. Grimesint argc;
20158f0484fSRodney W. Grimeschar **argv, **envp;
20258f0484fSRodney W. Grimes.Ed
20358f0484fSRodney W. Grimes.Pp
20458f0484fSRodney W. Grimeswhere
20558f0484fSRodney W. Grimes.Fa argc
20658f0484fSRodney W. Grimesis the number of elements in
20758f0484fSRodney W. Grimes.Fa argv
20858f0484fSRodney W. Grimes(the ``arg count'')
20958f0484fSRodney W. Grimesand
21058f0484fSRodney W. Grimes.Fa argv
21158f0484fSRodney W. Grimespoints to the array of character pointers
21258f0484fSRodney W. Grimesto the arguments themselves.
213a141af69SKonstantin Belousov.Pp
214a141af69SKonstantin BelousovThe
215a141af69SKonstantin Belousov.Fn fexecve
216a141af69SKonstantin Belousovignores the file offset of
217a141af69SKonstantin Belousov.Fa fd .
218a141af69SKonstantin BelousovSince execute permission is checked by
219a141af69SKonstantin Belousov.Fn fexecve ,
220a141af69SKonstantin Belousovthe file descriptor
221a141af69SKonstantin Belousov.Fa fd
22269a789b9SPawel Jakub Dawidekneed not have been opened with the
223a141af69SKonstantin Belousov.Dv O_EXEC
224a141af69SKonstantin Belousovflag.
22569a789b9SPawel Jakub DawidekHowever, if the file to be executed denies read permission for the process
22669a789b9SPawel Jakub Dawidekpreparing to do the exec, the only way to provide the
227a141af69SKonstantin Belousov.Fa fd
228a141af69SKonstantin Belousovto
229a141af69SKonstantin Belousov.Fn fexecve
230a141af69SKonstantin Belousovis to use the
231a141af69SKonstantin Belousov.Dv O_EXEC
232a141af69SKonstantin Belousovflag when opening
233a141af69SKonstantin Belousov.Fa fd .
23469a789b9SPawel Jakub DawidekNote that the file to be executed can not be open for writing.
23558f0484fSRodney W. Grimes.Sh RETURN VALUES
23658f0484fSRodney W. GrimesAs the
23758f0484fSRodney W. Grimes.Fn execve
2382faeeff4SRuslan Ermilovsystem call overlays the current process image
23958f0484fSRodney W. Grimeswith a new process image the successful call
24058f0484fSRodney W. Grimeshas no process to return to.
24158f0484fSRodney W. GrimesIf
24258f0484fSRodney W. Grimes.Fn execve
24358f0484fSRodney W. Grimesdoes return to the calling process an error has occurred; the
24458f0484fSRodney W. Grimesreturn value will be -1 and the global variable
24558f0484fSRodney W. Grimes.Va errno
24658f0484fSRodney W. Grimesis set to indicate the error.
24758f0484fSRodney W. Grimes.Sh ERRORS
2481f2cec10SGiorgos KeramidasThe
2491f2cec10SGiorgos Keramidas.Fn execve
2502faeeff4SRuslan Ermilovsystem call
25158f0484fSRodney W. Grimeswill fail and return to the calling process if:
2524f79a411SAlexey Zelkin.Bl -tag -width Er
25358f0484fSRodney W. Grimes.It Bq Er ENOTDIR
25458f0484fSRodney W. GrimesA component of the path prefix is not a directory.
25558f0484fSRodney W. Grimes.It Bq Er ENAMETOOLONG
25658f0484fSRodney W. GrimesA component of a pathname exceeded 255 characters,
25758f0484fSRodney W. Grimesor an entire path name exceeded 1023 characters.
2588f7f5a7fSAlan Cox.It Bq Er ENOEXEC
2598f7f5a7fSAlan CoxWhen invoking an interpreted script, the length of the first line,
2608f7f5a7fSAlan Coxinclusive of the
2618f7f5a7fSAlan Cox.Sy \&#!
2628f7f5a7fSAlan Coxprefix and terminating newline, exceeds
263dd98d57bSRuslan Ermilov.Dv MAXSHELLCMDLEN
264dd98d57bSRuslan Ermilovcharacters.
26558f0484fSRodney W. Grimes.It Bq Er ENOENT
26658f0484fSRodney W. GrimesThe new process file does not exist.
26758f0484fSRodney W. Grimes.It Bq Er ELOOP
26858f0484fSRodney W. GrimesToo many symbolic links were encountered in translating the pathname.
26958f0484fSRodney W. Grimes.It Bq Er EACCES
27058f0484fSRodney W. GrimesSearch permission is denied for a component of the path prefix.
27158f0484fSRodney W. Grimes.It Bq Er EACCES
27258f0484fSRodney W. GrimesThe new process file is not an ordinary file.
27358f0484fSRodney W. Grimes.It Bq Er EACCES
27458f0484fSRodney W. GrimesThe new process file mode denies execute permission.
275*773fa8cdSKyle Evans.It Bq Er EINVAL
276*773fa8cdSKyle Evans.Fa argv
277*773fa8cdSKyle Evansdid not contain at least one element.
27858f0484fSRodney W. Grimes.It Bq Er ENOEXEC
27958f0484fSRodney W. GrimesThe new process file has the appropriate access
28058f0484fSRodney W. Grimespermission, but has an invalid magic number in its header.
28158f0484fSRodney W. Grimes.It Bq Er ETXTBSY
28258f0484fSRodney W. GrimesThe new process file is a pure procedure (shared text)
28369a789b9SPawel Jakub Dawidekfile that is currently open for writing by some process.
28458f0484fSRodney W. Grimes.It Bq Er ENOMEM
28558f0484fSRodney W. GrimesThe new process requires more virtual memory than
28658f0484fSRodney W. Grimesis allowed by the imposed maximum
28758f0484fSRodney W. Grimes.Pq Xr getrlimit 2 .
28858f0484fSRodney W. Grimes.It Bq Er E2BIG
2896eba99b0SAlexander LangerThe number of bytes in the new process' argument list
29058f0484fSRodney W. Grimesis larger than the system-imposed limit.
2916eba99b0SAlexander LangerThis limit is specified by the
2926eba99b0SAlexander Langer.Xr sysctl 3
2936eba99b0SAlexander LangerMIB variable
2946eba99b0SAlexander Langer.Dv KERN_ARGMAX .
29558f0484fSRodney W. Grimes.It Bq Er EFAULT
29658f0484fSRodney W. GrimesThe new process file is not as long as indicated by
29758f0484fSRodney W. Grimesthe size values in its header.
29858f0484fSRodney W. Grimes.It Bq Er EFAULT
2992efeeba5SRuslan ErmilovThe
3002efeeba5SRuslan Ermilov.Fa path ,
30158f0484fSRodney W. Grimes.Fa argv ,
30258f0484fSRodney W. Grimesor
30358f0484fSRodney W. Grimes.Fa envp
3042efeeba5SRuslan Ermilovarguments
30558f0484fSRodney W. Grimespoint
30658f0484fSRodney W. Grimesto an illegal address.
30758f0484fSRodney W. Grimes.It Bq Er EIO
30858f0484fSRodney W. GrimesAn I/O error occurred while reading from the file system.
309e42b0964SJohn Baldwin.It Bq Er EINTEGRITY
310e42b0964SJohn BaldwinCorrupted data was detected while reading from the file system.
31158f0484fSRodney W. Grimes.El
312a141af69SKonstantin Belousov.Pp
313a141af69SKonstantin BelousovIn addition, the
314a141af69SKonstantin Belousov.Fn fexecve
315a141af69SKonstantin Belousovwill fail and return to the calling process if:
316a141af69SKonstantin Belousov.Bl -tag -width Er
317a141af69SKonstantin Belousov.It Bq Er EBADF
318a141af69SKonstantin BelousovThe
319a141af69SKonstantin Belousov.Fa fd
320a141af69SKonstantin Belousovargument is not a valid file descriptor open for executing.
321a141af69SKonstantin Belousov.El
32258f0484fSRodney W. Grimes.Sh SEE ALSO
32374804d58SMike Pritchard.Xr ktrace 1 ,
3245521ff5aSRuslan Ermilov.Xr _exit 2 ,
3251c85060aSRuslan Ermilov.Xr fork 2 ,
326a141af69SKonstantin Belousov.Xr open 2 ,
32758f0484fSRodney W. Grimes.Xr execl 3 ,
32878b0b234SMike Pritchard.Xr exit 3 ,
3296eba99b0SAlexander Langer.Xr sysctl 3 ,
33014477795SMaxim Sobolev.Xr a.out 5 ,
33114477795SMaxim Sobolev.Xr elf 5 ,
332eaad1099SKonstantin Belousov.Xr fdescfs 5 ,
33374804d58SMike Pritchard.Xr environ 7 ,
33474804d58SMike Pritchard.Xr mount 8
33548797398SGarrett Wollman.Sh STANDARDS
33648797398SGarrett WollmanThe
33748797398SGarrett Wollman.Fn execve
3382faeeff4SRuslan Ermilovsystem call conforms to
33948797398SGarrett Wollman.St -p1003.1-2001 ,
34048797398SGarrett Wollmanwith the exception of reopening descriptors 0, 1, and/or 2 in certain
34148797398SGarrett Wollmancircumstances.
34248797398SGarrett WollmanA future update of the Standard is expected to require this behavior,
34348797398SGarrett Wollmanand it may become the default for non-privileged processes as well.
34448797398SGarrett Wollman.\" NB: update this caveat when TC1 is blessed.
34548797398SGarrett WollmanThe support for executing interpreted programs is an extension.
346a141af69SKonstantin BelousovThe
347a141af69SKonstantin Belousov.Fn fexecve
348a141af69SKonstantin Belousovsystem call conforms to The Open Group Extended API Set 2 specification.
34958f0484fSRodney W. Grimes.Sh HISTORY
35058f0484fSRodney W. GrimesThe
351bf5a138eSMike Pritchard.Fn execve
3522faeeff4SRuslan Ermilovsystem call appeared in
353f6d234d8SGordon Bergling.At v7 .
354a141af69SKonstantin BelousovThe
355a141af69SKonstantin Belousov.Fn fexecve
356a141af69SKonstantin Belousovsystem call appeared in
357a141af69SKonstantin Belousov.Fx 8.0 .
3580afc94c1SUlrich Spörlein.Sh CAVEATS
3590afc94c1SUlrich SpörleinIf a program is
3600afc94c1SUlrich Spörlein.Em setuid
3610afc94c1SUlrich Spörleinto a non-super-user, but is executed when
3620afc94c1SUlrich Spörleinthe real
3630afc94c1SUlrich Spörlein.Em uid
3640afc94c1SUlrich Spörleinis ``root'', then the program has some of the powers
3650afc94c1SUlrich Spörleinof a super-user as well.
3660afc94c1SUlrich Spörlein.Pp
3670afc94c1SUlrich SpörleinWhen executing an interpreted program through
3680afc94c1SUlrich Spörlein.Fn fexecve ,
3690afc94c1SUlrich Spörleinkernel supplies
3700afc94c1SUlrich Spörlein.Pa /dev/fd/n
3710afc94c1SUlrich Spörleinas a second argument to the interpreter,
3720afc94c1SUlrich Spörleinwhere
3730afc94c1SUlrich Spörlein.Ar n
3740afc94c1SUlrich Spörleinis the file descriptor passed in the
3750afc94c1SUlrich Spörlein.Fa fd
3760afc94c1SUlrich Spörleinargument to
3770afc94c1SUlrich Spörlein.Fn fexecve .
3780afc94c1SUlrich SpörleinFor this construction to work correctly, the
3790afc94c1SUlrich Spörlein.Xr fdescfs 5
3800afc94c1SUlrich Spörleinfilesystem shall be mounted on
3810afc94c1SUlrich Spörlein.Pa /dev/fd .
382