xref: /freebsd-13.1/lib/libc/sys/execve.2 (revision 7393eedb)
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
297f3dea24SPeter Wemm.\" $FreeBSD$
3058f0484fSRodney W. Grimes.\"
31*7393eedbSKyle Evans.Dd January 26, 2022
3258f0484fSRodney W. Grimes.Dt EXECVE 2
33a307d598SRuslan Ermilov.Os
3458f0484fSRodney W. Grimes.Sh NAME
35a141af69SKonstantin Belousov.Nm execve ,
36a141af69SKonstantin Belousov.Nm fexecve
3758f0484fSRodney W. Grimes.Nd execute a file
3825bb73e0SAlexey Zelkin.Sh LIBRARY
3925bb73e0SAlexey Zelkin.Lb libc
4058f0484fSRodney W. Grimes.Sh SYNOPSIS
4132eef9aeSRuslan Ermilov.In unistd.h
4258f0484fSRodney W. Grimes.Ft int
4358f0484fSRodney W. Grimes.Fn execve "const char *path" "char *const argv[]" "char *const envp[]"
44a141af69SKonstantin Belousov.Ft int
45a141af69SKonstantin Belousov.Fn fexecve "int fd" "char *const argv[]" "char *const envp[]"
4658f0484fSRodney W. Grimes.Sh DESCRIPTION
471f2cec10SGiorgos KeramidasThe
481f2cec10SGiorgos Keramidas.Fn execve
492faeeff4SRuslan Ermilovsystem call
5058f0484fSRodney W. Grimestransforms the calling process into a new process.
5158f0484fSRodney W. GrimesThe new process is constructed from an ordinary file,
5258f0484fSRodney W. Grimeswhose name is pointed to by
5358f0484fSRodney W. Grimes.Fa path ,
5458f0484fSRodney W. Grimescalled the
5558f0484fSRodney W. Grimes.Em new process file .
56a141af69SKonstantin BelousovThe
57a141af69SKonstantin Belousov.Fn fexecve
58a141af69SKonstantin Belousovsystem call is equivalent to
59a141af69SKonstantin Belousov.Fn execve
60a141af69SKonstantin Belousovexcept that the file to be executed is determined by the file
61a141af69SKonstantin Belousovdescriptor
62a141af69SKonstantin Belousov.Fa fd
63a141af69SKonstantin Belousovinstead of a
64a141af69SKonstantin Belousov.Fa path .
6558f0484fSRodney W. GrimesThis file is either an executable object file,
6658f0484fSRodney W. Grimesor a file of data for an interpreter.
6758f0484fSRodney W. GrimesAn executable object file consists of an identifying header,
6858f0484fSRodney W. Grimesfollowed by pages of data representing the initial program (text)
691a0a9345SRuslan Ermilovand initialized data pages.
701a0a9345SRuslan ErmilovAdditional pages may be specified
7158f0484fSRodney W. Grimesby the header to be initialized with zero data; see
7214477795SMaxim Sobolev.Xr elf 5
7314477795SMaxim Sobolevand
7458f0484fSRodney W. Grimes.Xr a.out 5 .
7558f0484fSRodney W. Grimes.Pp
7658f0484fSRodney W. GrimesAn interpreter file begins with a line of the form:
7758f0484fSRodney W. Grimes.Pp
7846eea498SRuslan Ermilov.Bd -ragged -offset indent -compact
7958f0484fSRodney W. Grimes.Sy \&#!
8058f0484fSRodney W. Grimes.Em interpreter
8158f0484fSRodney W. Grimes.Bq Em arg
8258f0484fSRodney W. Grimes.Ed
8358f0484fSRodney W. Grimes.Pp
8458f0484fSRodney W. GrimesWhen an interpreter file is
85ed1fa5e0SMike Pritchard.Sy execve Ap d ,
86ccb277deSAdam Davidthe system actually
87ed1fa5e0SMike Pritchard.Sy execve Ap s
88ccb277deSAdam Davidthe specified
8958f0484fSRodney W. Grimes.Em interpreter .
9058f0484fSRodney W. GrimesIf the optional
9158f0484fSRodney W. Grimes.Em arg
9258f0484fSRodney W. Grimesis specified, it becomes the first argument to the
9358f0484fSRodney W. Grimes.Em interpreter ,
9458f0484fSRodney W. Grimesand the name of the originally
95ed1fa5e0SMike Pritchard.Sy execve Ap d
9658f0484fSRodney W. Grimesfile becomes the second argument;
9758f0484fSRodney W. Grimesotherwise, the name of the originally
98ed1fa5e0SMike Pritchard.Sy execve Ap d
991a0a9345SRuslan Ermilovfile becomes the first argument.
1001a0a9345SRuslan ErmilovThe original arguments are shifted over to
101d9b1c37cSBen Smithurstbecome the subsequent arguments.
102d9b1c37cSBen SmithurstThe zeroth argument is set to the specified
103d9b1c37cSBen Smithurst.Em interpreter .
10458f0484fSRodney W. Grimes.Pp
10558f0484fSRodney W. GrimesThe argument
10658f0484fSRodney W. Grimes.Fa argv
10758f0484fSRodney W. Grimesis a pointer to a null-terminated array of
10858f0484fSRodney W. Grimescharacter pointers to null-terminated character strings.
10958f0484fSRodney W. GrimesThese strings construct the argument list to be made available to the new
1101a0a9345SRuslan Ermilovprocess.
1111a0a9345SRuslan ErmilovAt least one argument must be present in
11258f0484fSRodney W. Grimesthe array; by custom, the first element should be
11358f0484fSRodney W. Grimesthe name of the executed program (for example, the last component of
11458f0484fSRodney W. Grimes.Fa path ) .
11558f0484fSRodney W. Grimes.Pp
11658f0484fSRodney W. GrimesThe argument
11758f0484fSRodney W. Grimes.Fa envp
11858f0484fSRodney W. Grimesis also a pointer to a null-terminated array of
11958f0484fSRodney W. Grimescharacter pointers to null-terminated strings.
12058f0484fSRodney W. GrimesA pointer to this array is normally stored in the global variable
12158f0484fSRodney W. Grimes.Va environ .
12258f0484fSRodney W. GrimesThese strings pass information to the
12358f0484fSRodney W. Grimesnew process that is not directly an argument to the command (see
12458f0484fSRodney W. Grimes.Xr environ 7 ) .
12558f0484fSRodney W. Grimes.Pp
12658f0484fSRodney W. GrimesFile descriptors open in the calling process image remain open in
12758f0484fSRodney W. Grimesthe new process image, except for those for which the close-on-exec
12858f0484fSRodney W. Grimesflag is set (see
12958f0484fSRodney W. Grimes.Xr close 2
13058f0484fSRodney W. Grimesand
13158f0484fSRodney W. Grimes.Xr fcntl 2 ) .
13258f0484fSRodney W. GrimesDescriptors that remain open are unaffected by
13358f0484fSRodney W. Grimes.Fn execve .
13448797398SGarrett WollmanIf any of the standard descriptors (0, 1, and/or 2) are closed at the
13548797398SGarrett Wollmantime
13648797398SGarrett Wollman.Fn execve
13748797398SGarrett Wollmanis called, and the process will gain privilege as a result of set-id
13848797398SGarrett Wollmansemantics, those descriptors will be re-opened automatically.
13948797398SGarrett WollmanNo programs, whether privileged or not, should assume that these descriptors
14048797398SGarrett Wollmanwill remain closed across a call to
14148797398SGarrett Wollman.Fn execve .
14258f0484fSRodney W. Grimes.Pp
14358f0484fSRodney W. GrimesSignals set to be ignored in the calling process are set to be ignored in
14458f0484fSRodney W. Grimesthe
145c6ff3a1bSSheldon Hearnnew process.
146c6ff3a1bSSheldon HearnSignals which are set to be caught in the calling process image
14758f0484fSRodney W. Grimesare set to default action in the new process image.
14858f0484fSRodney W. GrimesBlocked signals remain blocked regardless of changes to the signal action.
14958f0484fSRodney W. GrimesThe signal stack is reset to be undefined (see
15058f0484fSRodney W. Grimes.Xr sigaction 2
15158f0484fSRodney W. Grimesfor more information).
15258f0484fSRodney W. Grimes.Pp
15358f0484fSRodney W. GrimesIf the set-user-ID mode bit of the new process image file is set
15458f0484fSRodney W. Grimes(see
15558f0484fSRodney W. Grimes.Xr chmod 2 ) ,
15658f0484fSRodney W. Grimesthe effective user ID of the new process image is set to the owner ID
15758f0484fSRodney W. Grimesof the new process image file.
15858f0484fSRodney W. GrimesIf the set-group-ID mode bit of the new process image file is set,
15958f0484fSRodney W. Grimesthe effective group ID of the new process image is set to the group ID
16058f0484fSRodney W. Grimesof the new process image file.
16158f0484fSRodney W. Grimes(The effective group ID is the first element of the group list.)
16258f0484fSRodney W. GrimesThe real user ID, real group ID and
16358f0484fSRodney W. Grimesother group IDs of the new process image remain the same as the calling
16458f0484fSRodney W. Grimesprocess image.
16558f0484fSRodney W. GrimesAfter any set-user-ID and set-group-ID processing,
16658f0484fSRodney W. Grimesthe effective user ID is recorded as the saved set-user-ID,
16758f0484fSRodney W. Grimesand the effective group ID is recorded as the saved set-group-ID.
16858f0484fSRodney W. GrimesThese values may be used in changing the effective IDs later (see
16958f0484fSRodney W. Grimes.Xr setuid 2 ) .
17058f0484fSRodney W. Grimes.Pp
171e21de373STim VanderhoekThe set-ID bits are not honored if the respective file system has the
1725c564baeSRuslan Ermilov.Cm nosuid
1731a0a9345SRuslan Ermilovoption enabled or if the new process file is an interpreter file.
1741a0a9345SRuslan ErmilovSyscall
175e21de373STim Vanderhoektracing is disabled if effective IDs are changed.
176e21de373STim Vanderhoek.Pp
17758f0484fSRodney W. GrimesThe new process also inherits the following attributes from
17858f0484fSRodney W. Grimesthe calling process:
17958f0484fSRodney W. Grimes.Pp
18058f0484fSRodney W. Grimes.Bl -column parent_process_ID -offset indent -compact
18158f0484fSRodney W. Grimes.It process ID Ta see Xr getpid 2
18258f0484fSRodney W. Grimes.It parent process ID Ta see Xr getppid 2
18358f0484fSRodney W. Grimes.It process group ID Ta see Xr getpgrp 2
18458f0484fSRodney W. Grimes.It access groups Ta see Xr getgroups 2
18558f0484fSRodney W. Grimes.It working directory Ta see Xr chdir 2
18658f0484fSRodney W. Grimes.It root directory Ta see Xr chroot 2
18758f0484fSRodney W. Grimes.It control terminal Ta see Xr termios 4
18858f0484fSRodney W. Grimes.It resource usages Ta see Xr getrusage 2
18958f0484fSRodney W. Grimes.It interval timers Ta see Xr getitimer 2
19058f0484fSRodney W. Grimes.It resource limits Ta see Xr getrlimit 2
19158f0484fSRodney W. Grimes.It file mode mask Ta see Xr umask 2
192c84cab56SJilles Tjoelker.It signal mask Ta see Xr sigaction 2 ,
193c84cab56SJilles Tjoelker.Xr sigprocmask 2
19458f0484fSRodney W. Grimes.El
19558f0484fSRodney W. Grimes.Pp
19658f0484fSRodney W. GrimesWhen a program is executed as a result of an
19758f0484fSRodney W. Grimes.Fn execve
1982faeeff4SRuslan Ermilovsystem call, it is entered as follows:
19958f0484fSRodney W. Grimes.Bd -literal -offset indent
20058f0484fSRodney W. Grimesmain(argc, argv, envp)
20158f0484fSRodney W. Grimesint argc;
20258f0484fSRodney W. Grimeschar **argv, **envp;
20358f0484fSRodney W. Grimes.Ed
20458f0484fSRodney W. Grimes.Pp
20558f0484fSRodney W. Grimeswhere
20658f0484fSRodney W. Grimes.Fa argc
20758f0484fSRodney W. Grimesis the number of elements in
20858f0484fSRodney W. Grimes.Fa argv
20958f0484fSRodney W. Grimes(the ``arg count'')
21058f0484fSRodney W. Grimesand
21158f0484fSRodney W. Grimes.Fa argv
21258f0484fSRodney W. Grimespoints to the array of character pointers
21358f0484fSRodney W. Grimesto the arguments themselves.
214a141af69SKonstantin Belousov.Pp
215a141af69SKonstantin BelousovThe
216a141af69SKonstantin Belousov.Fn fexecve
217a141af69SKonstantin Belousovignores the file offset of
218a141af69SKonstantin Belousov.Fa fd .
219a141af69SKonstantin BelousovSince execute permission is checked by
220a141af69SKonstantin Belousov.Fn fexecve ,
221a141af69SKonstantin Belousovthe file descriptor
222a141af69SKonstantin Belousov.Fa fd
22369a789b9SPawel Jakub Dawidekneed not have been opened with the
224a141af69SKonstantin Belousov.Dv O_EXEC
225a141af69SKonstantin Belousovflag.
22669a789b9SPawel Jakub DawidekHowever, if the file to be executed denies read permission for the process
22769a789b9SPawel Jakub Dawidekpreparing to do the exec, the only way to provide the
228a141af69SKonstantin Belousov.Fa fd
229a141af69SKonstantin Belousovto
230a141af69SKonstantin Belousov.Fn fexecve
231a141af69SKonstantin Belousovis to use the
232a141af69SKonstantin Belousov.Dv O_EXEC
233a141af69SKonstantin Belousovflag when opening
234a141af69SKonstantin Belousov.Fa fd .
23569a789b9SPawel Jakub DawidekNote that the file to be executed can not be open for writing.
23658f0484fSRodney W. Grimes.Sh RETURN VALUES
23758f0484fSRodney W. GrimesAs the
23858f0484fSRodney W. Grimes.Fn execve
2392faeeff4SRuslan Ermilovsystem call overlays the current process image
24058f0484fSRodney W. Grimeswith a new process image the successful call
24158f0484fSRodney W. Grimeshas no process to return to.
24258f0484fSRodney W. GrimesIf
24358f0484fSRodney W. Grimes.Fn execve
24458f0484fSRodney W. Grimesdoes return to the calling process an error has occurred; the
24558f0484fSRodney W. Grimesreturn value will be -1 and the global variable
24658f0484fSRodney W. Grimes.Va errno
24758f0484fSRodney W. Grimesis set to indicate the error.
24858f0484fSRodney W. Grimes.Sh ERRORS
2491f2cec10SGiorgos KeramidasThe
2501f2cec10SGiorgos Keramidas.Fn execve
2512faeeff4SRuslan Ermilovsystem call
25258f0484fSRodney W. Grimeswill fail and return to the calling process if:
2534f79a411SAlexey Zelkin.Bl -tag -width Er
25458f0484fSRodney W. Grimes.It Bq Er ENOTDIR
25558f0484fSRodney W. GrimesA component of the path prefix is not a directory.
25658f0484fSRodney W. Grimes.It Bq Er ENAMETOOLONG
25758f0484fSRodney W. GrimesA component of a pathname exceeded 255 characters,
25858f0484fSRodney W. Grimesor an entire path name exceeded 1023 characters.
2598f7f5a7fSAlan Cox.It Bq Er ENOEXEC
2608f7f5a7fSAlan CoxWhen invoking an interpreted script, the length of the first line,
2618f7f5a7fSAlan Coxinclusive of the
2628f7f5a7fSAlan Cox.Sy \&#!
2638f7f5a7fSAlan Coxprefix and terminating newline, exceeds
264dd98d57bSRuslan Ermilov.Dv MAXSHELLCMDLEN
265dd98d57bSRuslan Ermilovcharacters.
26658f0484fSRodney W. Grimes.It Bq Er ENOENT
26758f0484fSRodney W. GrimesThe new process file does not exist.
26858f0484fSRodney W. Grimes.It Bq Er ELOOP
26958f0484fSRodney W. GrimesToo many symbolic links were encountered in translating the pathname.
27058f0484fSRodney W. Grimes.It Bq Er EACCES
27158f0484fSRodney W. GrimesSearch permission is denied for a component of the path prefix.
27258f0484fSRodney W. Grimes.It Bq Er EACCES
27358f0484fSRodney W. GrimesThe new process file is not an ordinary file.
27458f0484fSRodney W. Grimes.It Bq Er EACCES
27558f0484fSRodney W. GrimesThe new process file mode denies execute permission.
276*7393eedbSKyle Evans.It Bq Er EINVAL
277*7393eedbSKyle Evans.Fa argv
278*7393eedbSKyle Evansdid not contain at least one element.
27958f0484fSRodney W. Grimes.It Bq Er ENOEXEC
28058f0484fSRodney W. GrimesThe new process file has the appropriate access
28158f0484fSRodney W. Grimespermission, but has an invalid magic number in its header.
28258f0484fSRodney W. Grimes.It Bq Er ETXTBSY
28358f0484fSRodney W. GrimesThe new process file is a pure procedure (shared text)
28469a789b9SPawel Jakub Dawidekfile that is currently open for writing by some process.
28558f0484fSRodney W. Grimes.It Bq Er ENOMEM
28658f0484fSRodney W. GrimesThe new process requires more virtual memory than
28758f0484fSRodney W. Grimesis allowed by the imposed maximum
28858f0484fSRodney W. Grimes.Pq Xr getrlimit 2 .
28958f0484fSRodney W. Grimes.It Bq Er E2BIG
2906eba99b0SAlexander LangerThe number of bytes in the new process' argument list
29158f0484fSRodney W. Grimesis larger than the system-imposed limit.
2926eba99b0SAlexander LangerThis limit is specified by the
2936eba99b0SAlexander Langer.Xr sysctl 3
2946eba99b0SAlexander LangerMIB variable
2956eba99b0SAlexander Langer.Dv KERN_ARGMAX .
29658f0484fSRodney W. Grimes.It Bq Er EFAULT
29758f0484fSRodney W. GrimesThe new process file is not as long as indicated by
29858f0484fSRodney W. Grimesthe size values in its header.
29958f0484fSRodney W. Grimes.It Bq Er EFAULT
3002efeeba5SRuslan ErmilovThe
3012efeeba5SRuslan Ermilov.Fa path ,
30258f0484fSRodney W. Grimes.Fa argv ,
30358f0484fSRodney W. Grimesor
30458f0484fSRodney W. Grimes.Fa envp
3052efeeba5SRuslan Ermilovarguments
30658f0484fSRodney W. Grimespoint
30758f0484fSRodney W. Grimesto an illegal address.
30858f0484fSRodney W. Grimes.It Bq Er EIO
30958f0484fSRodney W. GrimesAn I/O error occurred while reading from the file system.
310e42b0964SJohn Baldwin.It Bq Er EINTEGRITY
311e42b0964SJohn BaldwinCorrupted data was detected while reading from the file system.
31258f0484fSRodney W. Grimes.El
313a141af69SKonstantin Belousov.Pp
314a141af69SKonstantin BelousovIn addition, the
315a141af69SKonstantin Belousov.Fn fexecve
316a141af69SKonstantin Belousovwill fail and return to the calling process if:
317a141af69SKonstantin Belousov.Bl -tag -width Er
318a141af69SKonstantin Belousov.It Bq Er EBADF
319a141af69SKonstantin BelousovThe
320a141af69SKonstantin Belousov.Fa fd
321a141af69SKonstantin Belousovargument is not a valid file descriptor open for executing.
322a141af69SKonstantin Belousov.El
32358f0484fSRodney W. Grimes.Sh SEE ALSO
32474804d58SMike Pritchard.Xr ktrace 1 ,
3255521ff5aSRuslan Ermilov.Xr _exit 2 ,
3261c85060aSRuslan Ermilov.Xr fork 2 ,
327a141af69SKonstantin Belousov.Xr open 2 ,
32858f0484fSRodney W. Grimes.Xr execl 3 ,
32978b0b234SMike Pritchard.Xr exit 3 ,
3306eba99b0SAlexander Langer.Xr sysctl 3 ,
33114477795SMaxim Sobolev.Xr a.out 5 ,
33214477795SMaxim Sobolev.Xr elf 5 ,
333eaad1099SKonstantin Belousov.Xr fdescfs 5 ,
33474804d58SMike Pritchard.Xr environ 7 ,
33574804d58SMike Pritchard.Xr mount 8
33648797398SGarrett Wollman.Sh STANDARDS
33748797398SGarrett WollmanThe
33848797398SGarrett Wollman.Fn execve
3392faeeff4SRuslan Ermilovsystem call conforms to
34048797398SGarrett Wollman.St -p1003.1-2001 ,
34148797398SGarrett Wollmanwith the exception of reopening descriptors 0, 1, and/or 2 in certain
34248797398SGarrett Wollmancircumstances.
34348797398SGarrett WollmanA future update of the Standard is expected to require this behavior,
34448797398SGarrett Wollmanand it may become the default for non-privileged processes as well.
34548797398SGarrett Wollman.\" NB: update this caveat when TC1 is blessed.
34648797398SGarrett WollmanThe support for executing interpreted programs is an extension.
347a141af69SKonstantin BelousovThe
348a141af69SKonstantin Belousov.Fn fexecve
349a141af69SKonstantin Belousovsystem call conforms to The Open Group Extended API Set 2 specification.
35058f0484fSRodney W. Grimes.Sh HISTORY
35158f0484fSRodney W. GrimesThe
352bf5a138eSMike Pritchard.Fn execve
3532faeeff4SRuslan Ermilovsystem call appeared in
354f6d234d8SGordon Bergling.At v7 .
355a141af69SKonstantin BelousovThe
356a141af69SKonstantin Belousov.Fn fexecve
357a141af69SKonstantin Belousovsystem call appeared in
358a141af69SKonstantin Belousov.Fx 8.0 .
3590afc94c1SUlrich Spörlein.Sh CAVEATS
3600afc94c1SUlrich SpörleinIf a program is
3610afc94c1SUlrich Spörlein.Em setuid
3620afc94c1SUlrich Spörleinto a non-super-user, but is executed when
3630afc94c1SUlrich Spörleinthe real
3640afc94c1SUlrich Spörlein.Em uid
3650afc94c1SUlrich Spörleinis ``root'', then the program has some of the powers
3660afc94c1SUlrich Spörleinof a super-user as well.
3670afc94c1SUlrich Spörlein.Pp
3680afc94c1SUlrich SpörleinWhen executing an interpreted program through
3690afc94c1SUlrich Spörlein.Fn fexecve ,
3700afc94c1SUlrich Spörleinkernel supplies
3710afc94c1SUlrich Spörlein.Pa /dev/fd/n
3720afc94c1SUlrich Spörleinas a second argument to the interpreter,
3730afc94c1SUlrich Spörleinwhere
3740afc94c1SUlrich Spörlein.Ar n
3750afc94c1SUlrich Spörleinis the file descriptor passed in the
3760afc94c1SUlrich Spörlein.Fa fd
3770afc94c1SUlrich Spörleinargument to
3780afc94c1SUlrich Spörlein.Fn fexecve .
3790afc94c1SUlrich SpörleinFor this construction to work correctly, the
3800afc94c1SUlrich Spörlein.Xr fdescfs 5
3810afc94c1SUlrich Spörleinfilesystem shall be mounted on
3820afc94c1SUlrich Spörlein.Pa /dev/fd .
383