1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
|
.\" Hey Emacs! This file is -*- nroff -*- source.
.\"
.\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date. The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein. The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" Modified by Michael Haardt <michael@moria.de>
.\" Modified Wed Jul 21 22:47:01 1993 by Rik Faith (faith@cs.unc.edu)
.\" Modified 21 Aug 1994 by Michael Chastain (mec@shell.portal.com):
.\" Fixed typoes.
.\" Modified Fri Jan 31 16:24:28 1997 by Eric S. Raymond <esr@thyrsus.com>
.\" Modified Fri Nov 12 22:57:27 1999 by Urs Thuermann <urs@isnogud.escape.de>
.\"
.\" Japanese Version Copyright (c) 1996 TABATA Tomohira
.\" all rights reserved.
.\" Translated Thu Jul 4 22:15:20 JST 1996
.\" by TABATA Tomohira <loba@k2.t.u-tokyo.ac.jp>
.\" Modified Sun Dec 14 00:30:35 JST 1997
.\" by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Modified Fri Aug 17 20:15:01 JST 2001
.\" by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\"
.TH EXECVE 2 1997-09-03 "Linux 2.0.30" "Linux Programmer's Manual"
.SH ̾
execve \- ץ¹Ԥ
.SH
.B #include <unistd.h>
.sp
.BI "int execve(const char *" filename ", char *const " argv
.BI "[], char *const " envp []);
.SH
\fBexecve()\fP ϡ\fIfilename\fP ˤäƻꤵ줿ץ¹Ԥ롣
\fIfilename\fP ϡХʥ¹Է"\fB#! \fIinterpreter \fR[arg]"
ȤιԤǻϤޤ륹ץȤǤʤФʤʤ
Ԥξ硢interpreter Ŭڤʼ¹ԥեΥѥ̾ǤʤФʤ餺
켫ȤץȤǤäƤϤʤʤƤ
\fBinterpreter\fR [arg] \fIfilename\fR ηǸƤӽФ롣
\fIargv\fP ϿץϤʸǤ롣
\fIenvp\fP ʸǤꡢŪ \fBkey=value\fR η
ƤꡢץδĶѿȤϤ롣
\fIargv\fP \fIenvp\fP ξȤ NULL ݥǽäƤ
ɬפ롣ȴĶѿϸƤӽФ줿ץ main ؿ
\fBint main(int argc, char *argv[], char *envp[])\fR
Τ褦뤳Ȥˤäƥǽˤʤ롣
硢\fBexecve()\fP ֤ʤ
ơƤӽФΥץ text, data, bss, åϡɤ߹ޤ
ץˤäƾ롣
ƤӽФ줿ץϡƤӽФ PID
exec (close on exec)ꤵƤʤ٤Ƥ
ե롦ǥץѾ롣
ƤӽФץαʥϲ롣ƤӽФΥץ
ꤵ줿ʥͻưϥǥեưᤵ롣
SIGCHLD ʥ뤬 SIG_IGN ꤵƤ SIG_DFL ˥ꥻå
뤫⤷ʤʤ⤷ʤ
⤷Υץब ptrace Ƥȡ\fBexecve()\fP
ˤΥץ \fBSIGTRAP\fP 롣
⤷ \fIfilename\fP ǻꤵ줿ץե set-uid ӥåȤ
ꤵƤ硢ƤӽФץͭ(effective)桼 ID
ץեνͭ(owner)ѹ롣Ʊͤ˥ץե
set-gid ӥåȤꤵƤƤӽФץͭ롼 ID
ץեΥ롼(group)ѹ롣
¹ԥե뤬ͭ饤֥Υ֤ޤߥʥߥå
줿 a.out ¹Էä硢¹Ԥγϻ Linux
ʥߥå
.BR ld.so (8)
ƤӽФ졢ɬפʶͭ饤֥ɤ߹ǥԤ
¹ԥե뤬ʥߥå줿 ELF ¹Էä硢
PT_INTERP Ȥ˻ꤵ줿ץɬפ
ͭ饤֥(shared library)ɤ߹Τ˻Ѥ롣
̾Ѥ륤ץ Linux libc version 5 Хʥ
ξˤ \fI/lib/ld-linux.so.1\fR GNU libc version 2
Хʥξˤ \fI/lib/ld-linux.so.2\fR Ѥ롣
.SH ֤
\fBexecve()\fP ֤ʤ顼ξ \-1 ֤
.I errno
Ŭꤹ롣
.SH 顼
.TP
.B EACCES
ե뤫ץȤΥץ̤ΥեǤʤ
.TP
.B EACCES
ե뤫ץȤޤ ELF ץ˼¹Ե(execute permission)
ͿƤʤɬפʶͭ饤֥ޤϥץĤʤ
.TP
.B EPERM
ե롦ƥब
.I noexec
ǥޥȤƤ롣
.TP
.B EPERM
ե롦ƥब
.I nosuid
ǥޥȤ졢ե SUID 뤤 SGID ӥåȤꤵƤ롣
.TP
.B E2BIG
ꥹȤ礭롣
.TP
.B ENOEXEC
¹ԥե뤬ǤʤǤ뤫㤦ƥ㡼ΤΤ
¾Υեޥåȡ顼ˤ¹ԤǤʤä
.TP
.B EFAULT
.I filename
ǽʥɥ쥹֤γؤƤ롣
.TP
.B ENAMETOOLONG
.I filename
Ĺ롣
.TP
.B ENOENT
ե
.I filename
ץȤ ELF Υץ¸ߤʤ
.TP
.B ENOMEM
ͥ˽ʬʥ꤬ʤ
.TP
.B ENOTDIR
.I filename
䥹ץȤ ELF ΥץιǤǥ쥯ȥǤʤ
.TP
.B EACCES
.I filename
䥹ץȤ ELF ΥץιǤ˸(search permission)
ͿƤʤ
.TP
.B ELOOP
.I filename
䥹ץȤ ELF Υץ褹ݤ
ܥå¿롣
.TP
.B ETXTBSY
¹ԥեѤ˥ץƤץ롣
.TP
.B EIO
I/O 顼ȯ
.TP
.B ENFILE
ΥƥǥץǤեθ³ãä
.TP
.B EMFILE
ΥץץǤեξ¤ޤǴ˥ץƤ롣
.TP
.B EINVAL
ELF ¹Էʣ PT_INTERP Ȥ¸ߤ롣
(ʤʣΥץꤷ)
.TP
.B EISDIR
ELF ץǥ쥯ȥä
.TP
.B ELIBBAD
ELF ץǤեޥåȤǤʤä
.SH
SVr4, SVID, X/OPEN, BSD 4.3. POSIX ˤ #! ưˤĤƤεҤ
ʤ¾ϸߴ롣SVr4 ˤ¾ EAGAIN, EINTR, ELIBACC, ENOLINK,
EMULTIHOP ˤĤƤεҤ롣POSIX ˤ ETXTBSY, EPERM, EFAULT,
ELOOP, EIO, ENFILE, EMFILE, EINVAL, EISDIR, ELIBBAD 顼֤ˤĤ
εҤϤʤ
.SH
SUID ץ SGID ץ \fBptrace()\fP Ǥʤ
Linux ϥץȤ SUID SGID ӥåȤ̵뤹롣
ե륷ƥ
.I nosuid
ǥޥȤ SUID/SGID ¹ԥեɤͤ˰ϡ
Linux ͥΥСˤäưۤʤ:
СǤϡǤɬפʸ¤äƤơ
μ¹Ԥݤ( EPERM ֤)̤ΤСǤ
SUID/SGID ӥåȤΤߤ̵뤷Ƽ¹Ԥ롣
#! ¹ԷΥ롦ץȤΣܤˤϺ 127 ʸƤ롣
.\" .SH BUGS
.\" Some Linux versions have failed to check permissions on ELF
.\" interpreters. This is a security hole, because it allows users to
.\" open any file, such as a rewinding tape device, for reading. Some
.\" Linux versions have also had other security holes in \fBexecve()\fP,
.\" that could be exploited for denial of service by a suitably crafted
.\" ELF binary. There are no known problems with 2.0.34 or 2.2.15.
.SH Ϣ
.BR chmod (2),
.BR fork (2),
.BR execl (3),
.BR environ (5),
.BR ld.so (8).
|