1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
4 .\" and Copyright (c) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date. The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein. The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
26 .\" Modified by Michael Haardt <michael@moria.de>
27 .\" Modified 1993-07-21 by Rik Faith <faith@cs.unc.edu>
28 .\" Modified 1994-08-21 by Michael Chastain <mec@shell.portal.com>:
29 .\" Modified 1997-01-31 by Eric S. Raymond <esr@thyrsus.com>
30 .\" Modified 1999-11-12 by Urs Thuermann <urs@isnogud.escape.de>
31 .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
32 .\" 2006-09-04 Michael Kerrisk <mtk.manpages@gmail.com>
33 .\" Added list of process attributes that are not preserved on exec().
34 .\" 2007-09-14 Ollie Wild <aaw@google.com>, mtk
35 .\" Add text describing limits on command-line arguments + environment
37 .\" Japanese Version Copyright (c) 1996 TABATA Tomohira
38 .\" all rights reserved.
39 .\" Translated 1996-07-04, TABATA Tomohira <loba@k2.t.u-tokyo.ac.jp>
40 .\" Updated 1997-12-14, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
41 .\" Updated 2001-08-17, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
42 .\" Updated 2005-02-05, Yuichi SATO <ysato444@yahoo.co.jp>
43 .\" Updated 2005-09-06, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
44 .\" Updated 2005-11-19, Akihiro MOTOKI
45 .\" Updated 2006-08-13, Akihiro MOTOKI, LDP v2.39
46 .\" Updated 2007-01-09, Akihiro MOTOKI, LDP v2.43
47 .\" Updated 2007-06-03, Akihiro MOTOKI, LDP v2.51
48 .\" Updated 2007-10-12, Akihiro MOTOKI, LDP v2.66
49 .\" Updated 2008-04-04, Akihiro MOTOKI, LDP v2.79
50 .\" Updated 2008-11-05, Akihiro MOTOKI, LDP v3.12
52 .TH EXECVE 2 2010-01-06 "Linux" "Linux Programmer's Manual"
55 .\"O execve \- execute program
56 execve \- ¥×¥í¥°¥é¥à¤ò¼Â¹Ô¤¹¤ë
59 .B #include <unistd.h>
61 .BI "int execve(const char *" filename ", char *const " argv "[], "
63 .BI " char *const " envp []);
67 .\"O executes the program pointed to by \fIfilename\fP.
68 .\"O \fIfilename\fP must be either a binary executable, or a script
69 .\"O starting with a line of the form:
71 ¤Ï¡¢\fIfilename\fP ¤Ë¤è¤Ã¤Æ»ØÄꤵ¤ì¤¿¥×¥í¥°¥é¥à¤ò¼Â¹Ô¤¹¤ë¡£
72 \fIfilename\fP ¤Ï¡¢¥Ð¥¤¥Ê¥ê¼Â¹Ô·Á¼°¤«¡¢
73 °Ê²¼¤Î·Á¼°¤Î¹Ô¤Ç»Ï¤Þ¤ë¥¹¥¯¥ê¥×¥È¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
77 \fB#!\fP \fIinterpreter \fP[optional-arg]
81 .\"O For details of the latter case, see "Interpreter scripts" below.
82 ¸å¼Ô¤Î¾ÜºÙ¤Ï¡¢¸å¤í¤Î¡Ö¥¤¥ó¥¿¥×¥ê¥¿¡¦¥¹¥¯¥ê¥×¥È¡×¤ÎÀá¤ò»²¾È¤Î¤³¤È¡£
84 .\"O \fIargv\fP is an array of argument strings passed to the new program.
85 .\"O \fIenvp\fP is an array of strings, conventionally of the form
86 .\"O \fBkey=value\fP, which are passed as environment to the new program.
87 .\"O Both \fIargv\fP and \fIenvp\fP must be terminated by a null pointer.
88 .\"O The argument vector and environment can be accessed by the
89 .\"O called program's main function, when it is defined as:
90 \fIargv\fP ¤Ï¿·¤·¤¤¥×¥í¥°¥é¥à¤ËÅϤµ¤ì¤ë°ú¤¿ôʸ»úÎó¤ÎÇÛÎó¤Ç¤¢¤ë¡£
91 \fIenvp\fP ¤Ïʸ»úÎó¤ÎÇÛÎó¤Ç¤¢¤ê¡¢ÅÁÅýŪ¤Ë \fBkey=value\fP ¤Î·Á¼°¤ò
92 ¤·¤Æ¤ª¤ê¡¢¿·¤·¤¤¥×¥í¥°¥é¥à¤Î´Ä¶ÊÑ¿ô¤È¤·¤ÆÅϤµ¤ì¤ë¡£
93 \fIargv\fP ¤È \fIenvp\fP ¤Ï¤¤¤º¤ì¤â¤Î NULL ¥Ý¥¤¥ó¥¿¤Ç½ª¤ï¤Ã¤Æ¤¤¤ë
94 ɬÍפ¬¤¢¤ë¡£°ú¤¿ôÇÛÎó¤È´Ä¶ÊÑ¿ô¤Ï¡¢¸Æ¤Ó½Ð¤µ¤ì¤¿¥×¥í¥°¥é¥à¤Î main ´Ø¿ô¤ò
95 °Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤¹¤ë¤³¤È¤Ë¤è¤Ã¤Æ¥¢¥¯¥»¥¹²Äǽ¤Ë¤Ê¤ë¡£
99 int main(int argc, char *argv[], char *envp[])
104 .\"O does not return on success, and the text, data, bss, and
105 .\"O stack of the calling process are overwritten by that of the program
110 ¤½¤·¤Æ¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î text, data, bss, ¥¹¥¿¥Ã¥¯¤Ï¡¢
111 Æɤ߹þ¤Þ¤ì¤¿¥×¥í¥°¥é¥à¤Ë¤è¤Ã¤Æ¾å½ñ¤¤µ¤ì¤ë¡£
113 .\"O If the current program is being ptraced, a \fBSIGTRAP\fP is sent to it
114 .\"O after a successful
116 ¸µ¤Î¥×¥í¥°¥é¥à¤¬ ptrace ¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢
119 ¤½¤Î¥×¥í¥°¥é¥à¤Ë \fBSIGTRAP\fP ¤¬Á÷¤é¤ì¤ë¡£
121 .\"O If the set-user-ID bit is set on the program file pointed to by
123 .\"O and the underlying file system is not mounted
129 .\"O and the calling process is not being ptraced,
130 .\"O then the effective user ID of the calling process is changed
131 .\"O to that of the owner of the program file.
132 .\"O Similarly, when the set-group-ID
133 .\"O bit of the program file is set the effective group ID of the calling
134 .\"O process is set to the group of the program file.
136 ¤Ç»ØÄꤵ¤ì¤¿¥×¥í¥°¥é¥à¥Õ¥¡¥¤¥ë¤Ë set-user-ID ¥Ó¥Ã¥È¤¬ÀßÄꤵ¤ì¤Æ¤ª¤ê¡¢
137 ¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤¹¤ë¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤¬
142 ¥Õ¥é¥°) ¤Ç¥Þ¥¦¥ó¥È¤µ¤ì¤Æ¤ª¤é¤º¡¢
143 ¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤¬ ptrace ¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
144 ¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤Î¼Â¸ú (effective) ¥æ¡¼¥¶ ID ¤Ï
145 ¥×¥í¥°¥é¥à¥Õ¥¡¥¤¥ë¤Î½êÍ¼Ô (owner) ¤ËÊѹ¹¤µ¤ì¤ë¡£
146 ƱÍͤˡ¢¥×¥í¥°¥é¥à¥Õ¥¡¥¤¥ë¤Ë set-group-ID ¥Ó¥Ã¥È¤¬ÀßÄꤵ¤ì¤Æ¤¤¤¿¾ì¹ç¡¢
147 ¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤Î͸ú¥°¥ë¡¼¥× ID ¤Ï
148 ¥×¥í¥°¥é¥à¥Õ¥¡¥¤¥ë¤Î¥°¥ë¡¼¥×¤ËÊѹ¹¤µ¤ì¤ë¡£
150 .\"O The effective user ID of the process is copied to the saved set-user-ID;
151 .\"O similarly, the effective group ID is copied to the saved set-group-ID.
152 .\"O This copying takes place after any effective ID changes that occur
153 .\"O because of the set-user-ID and set-group-ID permission bits.
154 ¥×¥í¥»¥¹¤Î¼Â¸ú¥æ¡¼¥¶ ID ¤ÏÊݸ (saved) set-user-ID ¤Ë¥³¥Ô¡¼¤µ¤ì¤ë¡£
155 ƱÍͤˡ¢¼Â¸ú¥°¥ë¡¼¥× ID ¤ÏÊݸ set-group-ID ¤Ë¥³¥Ô¡¼¤µ¤ì¤ë¡£
156 ¤³¤Î¥³¥Ô¡¼¤Ï¡¢set-user-ID / set-group-ID µö²Ä¥Ó¥Ã¥È¤Ë¤è¤êȯÀ¸¤¹¤ë
157 ¼Â¸ú ID ¤ÎÊѹ¹¸å¤Ë¹Ô¤ï¤ì¤ë¡£
159 .\"O If the executable is an a.out dynamically linked
160 .\"O binary executable containing
161 .\"O shared-library stubs, the Linux dynamic linker
163 .\"O is called at the start of execution to bring
164 .\"O needed shared libraries into memory
165 .\"O and link the executable with them.
166 ¼Â¹Ô¥Õ¥¡¥¤¥ë¤¬Æ°Åª¥ê¥ó¥¯¤µ¤ì¤¿ a.out ¼Â¹Ô·Á¼°¤Ç¡¢¶¦Í¥é¥¤¥Ö¥é¥ê¤Î
167 ¥¹¥¿¥Ö¤ò´Þ¤à¤â¤Î¤À¤Ã¤¿¾ì¹ç¡¢¼Â¹Ô¤Î³«»Ï»þ¤Ë Linux ¤Î
170 ¤¬¸Æ¤Ó½Ð¤µ¤ì¡¢É¬Íפʶ¦Í¥é¥¤¥Ö¥é¥ê¤ò¥á¥â¥ê¤ËÆɤ߹þ¤ó¤Ç¥ê¥ó¥¯¤ò¹Ô¤¦¡£
172 .\"O If the executable is a dynamically linked ELF executable, the
173 .\"O interpreter named in the PT_INTERP segment is used to load the needed
174 .\"O shared libraries.
175 .\"O This interpreter is typically
176 .\"O \fI/lib/ld-linux.so.1\fP for binaries linked with the
177 .\"O Linux libc 5, or \fI/lib/ld-linux.so.2\fP for binaries linked with the
179 ¼Â¹Ô¥Õ¥¡¥¤¥ë¤¬¥À¥¤¥Ê¥ß¥Ã¥¯¡¦¥ê¥ó¥¯¤µ¤ì¤¿ ELF ¼Â¹Ô·Á¼°¤À¤Ã¤¿¾ì¹ç¡¢
180 PT_INTERP ¥»¥°¥á¥ó¥È¤Ë»ØÄꤵ¤ì¤¿¥¤¥ó¥¿¥×¥ê¥¿¤¬É¬ÍפÊ
181 ¶¦Í¥é¥¤¥Ö¥é¥ê (shared library) ¤òÆɤ߹þ¤à¤Î¤Ë»ÈÍѤµ¤ì¤ë¡£
182 Ä̾¥¤¥ó¥¿¥×¥ê¥¿¤È¤·¤Æ¤Ï¡¢
183 Linux libc 5 ¤ò¥ê¥ó¥¯¤·¤¿¥Ð¥¤¥Ê¥ê¤Î¾ì¹ç¤Ë¤Ï
184 \fI/lib/ld-linux.so.1\fP ¤¬¡¢
185 glibc 2 ¤ò¥ê¥ó¥¯¤·¤¿¥Ð¥¤¥Ê¥ê¤Î¾ì¹ç¤Ë¤Ï
186 \fI/lib/ld-linux.so.2\fP ¤¬»ÈÍѤµ¤ì¤ë¡£
188 .\"O All process attributes are preserved during an
190 .\"O except the following:
191 °Ê²¼¤Ë¼¨¤¹°Ê³°¤Î¤¹¤Ù¤Æ¤Î¥×¥í¥»¥¹Â°À¤Ï
195 .\"O The dispositions of any signals that are being caught are
196 .\"O reset to the default
197 .\"O .RB ( signal (7)).
198 Ê᪤µ¤ì¤¿¥·¥°¥Ê¥ë¤Î½èÍýÊýË¡ (disposition) ¤Ï
199 ¥Ç¥Õ¥©¥ë¥ÈÆ°ºî¤Ë¥ê¥»¥Ã¥È¤µ¤ì¤ë
202 .\"O Any alternate signal stack is not preserved
203 .\"O .RB ( sigaltstack (2)).
204 ÂåÂØ¥·¥°¥Ê¥ë¥¹¥¿¥Ã¥¯¤Ï¤É¤ì¤âÊÝ»ý¤µ¤ì¤Ê¤¤
205 .RB ( sigaltstack (2))¡£
207 .\"O Memory mappings are not preserved
208 .\"O .RB ( mmap (2)).
209 ¥á¥â¥ê¥Þ¥Ã¥Ô¥ó¥°¤ÏÊÝ»ý¤µ¤ì¤Ê¤¤
212 .\"O Attached System V shared memory segments are detached
213 .\"O .RB ( shmat (2)).
214 Éղ䵤줿 (attached) System V ¶¦Í¥á¥â¥ê¥»¥°¥á¥ó¥È¤ÏʬΥ¤µ¤ì¤ë
217 .\"O POSIX shared memory regions are unmapped
218 .\"O .RB ( shm_open (3)).
219 POSIX ¶¦Í¥á¥â¥êÎΰè¤Ï¥Þ¥Ã¥Ô¥ó¥°¤ò²ò½ü¤µ¤ì¤ë
220 .RB ( shm_open (3))¡£
222 .\"O Open POSIX message queue descriptors are closed
223 .\"O .RB ( mq_overview (7)).
224 ¥ª¡¼¥×¥ó¤µ¤ì¤¿ POSIX ¥á¥Ã¥»¡¼¥¸¥¥å¡¼¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï¥¯¥í¡¼¥º¤µ¤ì¤ë
225 .RB ( mq_overview (7))¡£
227 .\"O Any open POSIX named semaphores are closed
228 .\"O .RB ( sem_overview (7)).
229 ¥ª¡¼¥×¥ó¤µ¤ì¤¿ POSIX ̾Á°ÉÕ¤¥»¥Þ¥Õ¥©¤Ï¤¤¤º¤ì¤â¥¯¥í¡¼¥º¤µ¤ì¤ë
230 .RB ( sem_overview (7))¡£
232 .\"O POSIX timers are not preserved
233 .\"O .RB ( timer_create (2)).
234 POSIX ¥¿¥¤¥Þ¤ÏÊÝ»ý¤µ¤ì¤Ê¤¤
235 .RB ( timer_create (2))¡£
237 .\"O Any open directory streams are closed
238 .\"O .RB ( opendir (3)).
239 ¥ª¡¼¥×¥ó¤µ¤ì¤¿¥Ç¥£¥ì¥¯¥È¥ê¥¹¥È¥ê¡¼¥à¤Ï¤¤¤º¤ì¤â¥¯¥í¡¼¥º¤µ¤ì¤ë
242 .\"O Memory locks are not preserved
243 .\"O .RB ( mlock (2),
244 .\"O .BR mlockall (2)).
245 ¥á¥â¥ê¥í¥Ã¥¯¤ÏÊÝ»ý¤µ¤ì¤Ê¤¤
249 .\"O Exit handlers are not preserved
250 .\"O .RB ( atexit (3),
251 .\"O .BR on_exit (3)).
252 ½ªÎ» (exit) ¥Ï¥ó¥É¥é¤ÏÊÝ»ý¤µ¤ì¤Ê¤¤
256 .\"O The floating-point environment is reset to the default (see
258 ÉâÆ°¾®¿ôÅÀ´ØÏ¢¤Î´Ä¶¤Ï¥Ç¥Õ¥©¥ë¥È¤Ë¥ê¥»¥Ã¥È¤µ¤ì¤ë
262 .\"O The process attributes in the preceding list are all specified
263 .\"O in POSIX.1-2001.
264 .\"O The following Linux-specific process attributes are also
265 .\"O not preserved during an
267 ¾åµ¤Î¥ê¥¹¥È¤Î¥×¥í¥»¥¹Â°À¤Ï¤¤¤º¤ì¤â POSIX.1-2001 ¤Çµ¬Äꤵ¤ì¤Æ¤¤¤ë¡£
268 °Ê²¼¤Ë¼¨¤¹ Linux ¸ÇÍ¤Î¥×¥í¥»¥¹Â°À¤â
270 ¤ÎÁ°¸å¤ÇÊÝ»ý¤µ¤ì¤Ê¤¤¡£
274 .\"O .B PR_SET_DUMPABLE
276 .\"O unless a set-user-ID or set-group ID program is being executed,
277 .\"O in which case it is cleared.
278 set-user-ID ¤« set-group-ID ¤µ¤ì¤¿¥×¥í¥°¥é¥à¤¬¼Â¹Ô¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢
282 ¥Õ¥é¥°¤Ï¥¯¥ê¥¢¤µ¤ì¤ë¡£¤½¤ì°Ê³°¤Î¾ì¹ç¡¢¤³¤Î¥Õ¥é¥°¤Ï¥»¥Ã¥È¤µ¤ì¤ë¡£
286 .\"O .B PR_SET_KEEPCAPS
287 .\"O flag is cleared.
291 ¥Õ¥é¥°¤Ï¥¯¥ê¥¢¤µ¤ì¤ë¡£
293 .\"O The process name, as set by
296 .\"O (and displayed by
297 .\"O .IR "ps\ \-o comm" ),
298 .\"O is reset to the name of the new executable file.
299 ¥×¥í¥»¥¹Ì¾¤Ï¿·¤·¤¤¼Â¹Ô¥Õ¥¡¥¤¥ë¤Î̾Á°¤Ë¥ê¥»¥Ã¥È¤µ¤ì¤ë¡£
308 .\"O The termination signal is reset to
312 ½ªÎ»¥·¥°¥Ê¥ë (termination signal) ¤Ï
318 .\"O Note the following further points:
319 °Ê²¼¤ÎÅÀ¤Ë¤Ä¤¤¤Æ¤âÃí°Õ¤¹¤ë¤³¤È:
321 .\"O All threads other than the calling thread are destroyed during an
323 .\"O Mutexes, condition variables, and other pthreads objects are not preserved.
324 ¸Æ¤Ó½Ð¤·¸µ¥¹¥ì¥Ã¥É°Ê³°¤ÎÁ´¤Æ¤Î¥¹¥ì¥Ã¥É¤Ï
327 mutex¡¢¾ò·ïÊÑ¿ô¡¢¤½¤Î¾¤Î pthread ¥ª¥Ö¥¸¥§¥¯¥È¤ÏÊÝ»ý¤µ¤ì¤Ê¤¤¡£
329 .\"O The equivalent of \fIsetlocale(LC_ALL, "C")\fP
330 .\"O is executed at program start-up.
331 \fIsetlocale(LC_ALL, "C")\fP ÁêÅö¤Î½èÍý¤¬¥×¥í¥°¥é¥à³«»Ï»þ¤Ë¼Â¹Ô¤µ¤ì¤ë¡£
333 .\"O POSIX.1-2001 specifies that the dispositions of any signals that
334 .\"O are ignored or set to the default are left unchanged.
335 .\"O POSIX.1-2001 specifies one exception: if
337 .\"O is being ignored,
338 .\"O then an implementation may leave the disposition unchanged or
339 .\"O reset it to the default; Linux does the former.
340 POSIX.1-2001 ¤Ï¡¢Æ°ºî¤¬Ìµ»ë¤«¥Ç¥Õ¥©¥ë¥È¤ËÀßÄꤵ¤ì¤Æ¤¤¤ëÁ´¤Æ¤Î¥·¥°¥Ê¥ë
341 ¤Î½èÍýÊýË¡¤ÏÊѹ¹¤»¤º¤½¤Î¤Þ¤Þ¤Ë¤¹¤ë¡¢¤Èµ¬Äꤷ¤Æ¤¤¤ë¡£
342 ⤷¡¢POSIX.1-2001 ¤Ë¤Ï°ì¤ÄÎã³°¤¬¤¢¤ê¡¢
344 ¤¬Ìµ»ë¤Ë¤Ê¤Ã¤Æ¤¤¤ë¾ì¹ç¡¢
345 ¤½¤Î½èÍýÊýË¡¤òÊѹ¹¤»¤º¤Ë¤½¤Î¤Þ¤Þ¤Ë¤¹¤ë¤«¡¢¥Ç¥Õ¥©¥ë¥ÈÆ°ºî¤Ë¥ê¥»¥Ã¥È¤¹¤ë¤«¤Ï
346 ¼ÂÁõ°Í¸¤È¤Ê¤Ã¤Æ¤¤¤ë¡£
347 Linux ¤Ç¤ÏÁ°¼Ô (Êѹ¹¤·¤Ê¤¤) ¤È¤Ê¤Ã¤Æ¤¤¤ë¡£
349 .\"O Any outstanding asynchronous I/O operations are canceled
350 .\"O .RB ( aio_read (3),
351 .\"O .BR aio_write (3)).
352 ´°Î»¤·¤Æ¤¤¤Ê¤¤ÈóƱ´ü I/O Áàºî¤Ï¥¥ã¥ó¥»¥ë¤µ¤ì¤ë
356 .\"O For the handling of capabilities during
359 .\"O .BR capabilities (7).
361 »þ¤Î¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£¤Î°·¤¤¤Ë¤Ä¤¤¤Æ¤Ï¡¢
365 .\"O By default, file descriptors remain open across an
367 .\"O File descriptors that are marked close-on-exec are closed;
368 .\"O see the description of
372 .\"O (If a file descriptor is closed, this will cause the release
373 .\"O of all record locks obtained on the underlying file by this process.
377 ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï
379 ¤ò¹Ô¤Ã¤¿¸å¤Ç¤â¥ª¡¼¥×¥ó¤µ¤ì¤¿¤Þ¤Þ¤Ç¤¢¤ë¡£
380 close-on-exec ¤Î°õ¤¬ÉÕ¤¤¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï¥¯¥í¡¼¥º¤µ¤ì¤ë¡£
385 (¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬¥¯¥í¡¼¥º¤µ¤ì¤ë¤È¡¢¤³¤Î¥×¥í¥»¥¹¤¬
386 ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ËÂбþ¤¹¤ë¥Õ¥¡¥¤¥ë¤ËÂФ·¤Æ³ÍÆÀ¤·¤Æ¤¤¤¿
387 ¥ì¥³¡¼¥É¤Î¥í¥Ã¥¯¤¬Á´¤Æ²òÊü¤µ¤ì¤ë¤³¤È¤Ë¤Ê¤ë¡£)
388 .\"O POSIX.1-2001 says that if file descriptors 0, 1, and 2 would
389 .\"O otherwise be closed after a successful
391 .\"O and the process would gain privilege because the set-user_ID or
392 .\"O set-group_ID permission bit was set on the executed file,
393 .\"O then the system may open an unspecified file for each of these
394 .\"O file descriptors.
395 .\"O As a general principle, no portable program, whether privileged or not,
396 .\"O can assume that these three file descriptors will remain
397 .\"O closed across an
400 ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿ 0, 1, 2 ¤¬
402 À®¸ù¸å¤Ë¤É¤³¤«¤Ç¥¯¥í¡¼¥º¤µ¤ì¡¢¤«¤Ä
403 ¼Â¹Ô¤µ¤ì¤ë¥Õ¥¡¥¤¥ë¤Ë set-user_ID ¤« set-group_ID ¤Îµö²Ä¥Ó¥Ã¥È¤¬
404 ¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤Æ¥×¥í¥»¥¹¤¬Æø¢¤ò³ÍÆÀ¤·¤¿¾ì¹ç¡¢
405 ¥·¥¹¥Æ¥à¤Ï²¿¤é¤«¤Î¥Õ¥¡¥¤¥ë¤ò¥ª¡¼¥×¥ó¤¹¤ëºÝ¤Ë
406 ¤³¤ì¤é¤ÎÈÖ¹æ¤Î¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î¤É¤ì¤«¤ò»È¤¦¤³¤È¤¬¤¢¤ë¡¢
408 ¸¶Â§¤È¤·¤Æ¡¢°Ü¿¢À¤¬É¬Í×¤Ê¥×¥í¥°¥é¥à¤Ç¤Ï¡¢
409 Æø¢¤ÎÍ̵¤Ë´Ø¤ï¤é¤º¡¢
411 ¤ÎÁ°¸å¤Ç¤³¤ì¤é 3¤Ä¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬¥¯¥í¡¼¥º¤µ¤ì¤¿¤Þ¤Þ¤Ç
412 ¤¢¤ë¤³¤È¤òÁ°Äó¤Ë¤¹¤ë¤³¤È¤Ï¤Ç¤¤Ê¤¤¡£
413 .\" On Linux it appears that these file descriptors are
414 .\" always open after an execve(), and it looks like
415 .\" Solaris 8 and FreeBSD 6.1 are the same. -- mtk, 30 Apr 2007
416 .\"O .SS Interpreter scripts
417 .SS ¥¤¥ó¥¿¥×¥ê¥¿¡¦¥¹¥¯¥ê¥×¥È
418 .\"O An interpreter script is a text file that has execute
419 .\"O permission enabled and whose first line is of the form:
420 ¥¤¥ó¥¿¥×¥ê¥¿¡¦¥¹¥¯¥ê¥×¥È¤È¤Ï¡¢¼Â¹Ôµö²Ä¤¬Í¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Æ¡¢
421 ºÇ½é¤Î¹Ô¤¬°Ê²¼¤Î·Á¤Ë¤Ê¤Ã¤Æ¤¤¤ë¥Æ¥¥¹¥È¥Õ¥¡¥¤¥ë¤Î¤³¤È¤Ç¤¢¤ë¡£
425 \fB#!\fP \fIinterpreter \fP[optional-arg]
431 .\"O must be a valid pathname for an
432 .\"O executable which is not itself a script.
434 ¤Ï͸ú¤Ê¼Â¹Ô¥Õ¥¡¥¤¥ë¤Î¥Ñ¥¹Ì¾¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤º¡¢
435 ¤½¤ì¼«¿È¤¬¥¹¥¯¥ê¥×¥È¤Ç¤¢¤Ã¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
440 .\"O specifies an interpreter script, then
442 .\"O will be invoked with the following arguments:
446 °ú¤¿ô¤¬¥¤¥ó¥¿¥×¥ê¥¿¥¹¥¯¥ê¥×¥È¤ò»ØÄꤷ¤Æ¤¤¤ë¾ì¹ç¡¢
448 ¤Ï°Ê²¼¤Î°ú¤¿ô¤Çµ¯Æ°¤µ¤ì¤ë¡£
452 \fIinterpreter\fP [optional-arg] \fIfilename\fP arg...
458 .\"O is the series of words pointed to by the
467 °ú¤¿ô¤¬»Ø¤¹¥ï¡¼¥ÉÎó¤Ç¤¢¤ë¡£
469 .\"O For portable use,
471 .\"O should either be absent, or be specified as a single word (i.e., it
472 .\"O should not contain white space); see NOTES below.
475 ¤Ï¶õ¤« 1¥ï¡¼¥É¤À¤±¤Ë¤¹¤Ù¤¤Ç¤¢¤ë
476 (¤Ä¤Þ¤ê¡¢¥Û¥ï¥¤¥È¡¦¥¹¥Ú¡¼¥¹¤ò´Þ¤á¤ë¤Ù¤¤Ç¤Ï¤Ê¤¤)¡£
477 ²¼µ¤Î¡ÖÃí°Õ¡×¤ÎÀá¤ò»²¾È¡£
478 .\"O .SS "Limits on size of arguments and environment"
479 .SS "°ú¤¿ô¤È´Ä¶ÊÑ¿ô¤Î¹ç·×¥µ¥¤¥º¤Î¾å¸Â"
480 .\"O Most Unix implementations impose some limit on the total size
481 .\"O of the command-line argument
485 .\"O strings that may be passed to a new program.
486 .\"O POSIX.1 allows an implementation to advertise this limit using the
488 .\"O constant (either defined in
490 .\"O or available at run time using the call
491 .\"O .IR "sysconf(_SC_ARG_MAX)" ).
492 ¤Û¤È¤ó¤É¤Î Unix ¤Î¼ÂÁõ¤Ï¡¢¿·¤·¤¤¥×¥í¥°¥é¥à¤ËÅϤ¹¤³¤È¤¬¤Ç¤¤ë
497 ¤Îʸ»úÎ󷲤ιç·×¥µ¥¤¥º¤Ë²¿¤é¤«¤Î¾å¸Â¤òÀߤ±¤Æ¤¤¤ë¡£
500 Äê¿ô¤ò»È¤Ã¤Æ¤³¤Î¾å¸Â¤ò·è¤á¤ë¼ÂÁõ¤òǧ¤á¤Æ¤¤¤ë
504 ¤ÇÄêµÁ¤µ¤ì¤ë¤«¡¢¼Â¹Ô»þ¤Ë
505 .I "sysconf(_SC_ARG_MAX)"
506 ¤Î¸Æ¤Ó½Ð¤·¤ÇÆþ¼ê¤Ç¤¤ë¤«¤Î¤¤¤º¤ì¤«¤Ç¤¢¤ë)¡£
508 .\"O On Linux prior to kernel 2.6.23, the memory used to store the
509 .\"O environment and argument strings was limited to 32 pages
510 .\"O (defined by the kernel constant
511 .\"O .BR MAX_ARG_PAGES ).
512 .\"O On architectures with a 4-kB page size,
513 .\"O this yields a maximum size of 128 kB.
514 ¥«¡¼¥Í¥ë 2.6.23 ¤è¤êÁ°¤Î Linux ¤Ç¤Ï¡¢´Ä¶ÊÑ¿ô¤È°ú¤¿ô¤Îʸ»úÎ󷲤ò
515 ³ÊǼ¤¹¤ë¤Î¤Ë»ÈÍѤµ¤ì¤ë¥á¥â¥ê¤Ï 32 ¥Ú¡¼¥¸¤ËÀ©¸Â¤µ¤ì¤Æ¤¤¤¿
516 (32 ¥Ú¡¼¥¸¤È¤¤¤¦¤Î¤Ï¥«¡¼¥Í¥ëÄê¿ô
518 ¤ÇÄêµÁ¤µ¤ì¤ë)¡£¤·¤¿¤¬¤Ã¤Æ¡¢
519 ¥Ú¡¼¥¸¥µ¥¤¥º¤¬ 4 kB ¤Î¥¢¡¼¥¥Æ¥¯¥Á¥ã¤Ç¤Ï¡¢
520 ºÇÂ祵¥¤¥º¤Ï 128 kB ¤È¤¤¤¦¤³¤È¤Ë¤Ê¤ë¡£
522 .\"O On kernel 2.6.23 and later, most architectures support a size limit
523 .\"O derived from the soft
525 .\"O resource limit (see
526 .\"O .BR getrlimit (2))
527 .\"O that is in force at the time of the
530 ¥«¡¼¥Í¥ë 2.6.23 °Ê¹ß¤Ç¤Ï¡¢¤Û¤È¤ó¤É¤Î¥¢¡¼¥¥Æ¥¯¥Á¥ã¤Ë¤ª¤¤¤Æ¡¢
532 ¤¬¸Æ¤Ó½Ð¤µ¤ì¤¿»þÅÀ¤ÇŬÍѤµ¤ì¤Æ¤¤¤ë¥ê¥½¡¼¥¹¤Î¥½¥Õ¥È¾å¸Â
534 ¤Ë´ð¤Å¤¤¤¿¥µ¥¤¥º¾å¸Â¤¬»È¤ï¤ì¤ë
535 .\"O (Architectures with no memory management unit are excepted:
536 .\"O they maintain the limit that was in effect before kernel 2.6.23.)
537 .\"O This change allows programs to have a much larger
538 .\"O argument and/or environment list.
539 (¥á¥â¥ê´ÉÍý¥æ¥Ë¥Ã¥È (MMU) ¤ò»ý¤¿¤Ê¤¤¥¢¡¼¥¥Æ¥¯¥Á¥ã¤Ï¾åµ¤ÎÊѹ¹¤Î
540 Îã³°¤Ç¤¢¤ê¡¢¤³¤ì¤é¤Î¥¢¡¼¥¥Æ¥¯¥Á¥ã¤Ç¤Ï¥«¡¼¥Í¥ë 2.6.23 ¤è¤êÁ°¤È
541 Ʊ¤¸¾å¸Â¤¬¤½¤Î¤Þ¤Þ»ÈÍѤµ¤ì¤ë)¡£
542 .\" For some background on the changes to ARG_MAX in kernels 2.6.23 and
544 .\" http://sourceware.org/bugzilla/show_bug.cgi?id=5786
545 .\" http://bugzilla.kernel.org/show_bug.cgi?id=10095
546 .\" http://thread.gmane.org/gmane.linux.kernel/646709/focus=648101,
547 .\" checked into 2.6.25 as commit a64e715fc74b1a7dcc5944f848acc38b2c4d4ee2.
548 .\"O For these architectures, the total size is limited to 1/4 of the allowed
550 .\"O (Imposing the 1/4-limit
551 .\"O ensures that the new program always has some stack space.)
552 ¤³¤ì¤é¤Î¥¢¡¼¥¥Æ¥¯¥Á¥ã¤Ç¤Ï¡¢¹ç·×¥µ¥¤¥º¤Ïµö²Ä¤µ¤ì¤¿¥¹¥¿¥Ã¥¯¥µ¥¤¥º¤Î
554 (1/4 ¤Î¾å¸Â¤òÀߤ±¤Æ¤¤¤ë¤Î¤Ï¡¢¿·¤·¤¤¥×¥í¥°¥é¥à¤¬É¬¤º¤¢¤ëÄøÅÙ¤Î
555 ¥¹¥¿¥Ã¥¯¶õ´Ö¤ò»ý¤Æ¤ë¤³¤È¤òÊݾڤ¹¤ë¤¿¤á¤Ç¤¢¤ë)¡£
556 .\" Ollie: That doesn't include the lists of pointers, though,
557 .\" so the actual usage is a bit higher (1 pointer per argument).
558 .\"O Since Linux 2.6.25,
559 .\"O the kernel places a floor of 32 pages on this size limit,
560 .\"O so that, even when
561 .\"O .BR RLIMIT_STACK
562 .\"O is set very low,
563 .\"O applications are guaranteed to have at least as much argument and
564 .\"O environment space as was provided by Linux 2.6.23 and earlier.
565 .\"O (This guarantee was not provided in Linux 2.6.23 and 2.6.24.)
566 Linux 2.6.25 °Ê¹ß¤Ç¤Ï¡¢¥«¡¼¥Í¥ë¤Ï¤³¤Î¥µ¥¤¥º¾å¸Â¤Ë 32 ¥Ú¡¼¥¸¤Î²¼¸Â¤ò
567 Àߤ±¤Æ¤¤¤ë¡£¤³¤ì¤Ë¤è¤ê¡¢
569 ¤¬Èó¾ï¤Ë¾®¤µ¤¯ÀßÄꤵ¤ì¤¿¾ì¹ç¤Ç¤â¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬¾¯¤Ê¤¯¤È¤â
570 Linux 2.6.23 °ÊÁ°¤ÇÄ󶡤µ¤ì¤Æ¤¤¤¿¤Î¤ÈƱ¤¸Â礤µ¤Î°ú¤¿ô¤È´Ä¶ÊÑ¿ô¤Î¶õ´Ö
571 ¤ÈƱ¤¸¤À¤±¤Ï³ÎÊݤǤ¤ë¤³¤È¤¬Êݾڤµ¤ì¤Æ¤¤¤ë
572 (¤³¤ÎºÇÄã¸Â¤ÎÊÝ¾Ú¤Ï Linux 2.6.23 ¤È 2.6.24 ¤Ç¤ÏÄ󶡤µ¤ì¤Æ¤¤¤Ê¤¤)¡£
573 .\"O Additionally, the limit per string is 32 pages (the kernel constant
574 .\"O .BR MAX_ARG_STRLEN ),
575 .\"O and the maximum number of strings is 0x7FFFFFFF.
576 ¤Þ¤¿¡¢³Æʸ»úÎó¤Î¾å¸Â¤Ï 32 ¥Ú¡¼¥¸ (¥«¡¼¥Í¥ëÄê¿ô
578 ¤Ç¡¢Ê¸»úÎó¿ô¤ÎºÇÂçÃÍ¤Ï 0x7FFFFFFF ¤Ç¤¢¤ë¡£
579 .\"O .SH "RETURN VALUE"
583 .\"O does not return, on error \-1 is returned, and
585 .\"O is set appropriately.
588 ¤ÏÊÖ¤é¤Ê¤¤¡£¥¨¥é¡¼¤Î¾ì¹ç¤Ï \-1 ¤òÊÖ¤·¡¢
595 .\"O The total number of bytes in the environment
597 .\"O and argument list
604 ¤Î¹ç·×¥Ð¥¤¥È¿ô¤¬Â礲᤮¤ë¡£
607 .\"O Search permission is denied on a component of the path prefix of
609 .\"O or the name of a script interpreter.
611 .\"O .BR path_resolution (7).)
613 ¤ä¥¹¥¯¥ê¥×¥È¥¤¥ó¥¿¥×¥ê¥¿Ì¾¤Î¹½À®Í×ÁǤ˸¡º÷µö²Ä (search permission)
615 .RB ( path_resolution (7)
619 .\"O The file or a script interpreter is not a regular file.
620 ¥Õ¥¡¥¤¥ë¤â¤·¤¯¤Ï¥¹¥¯¥ê¥×¥È¤Î¥¤¥ó¥¿¥×¥ê¥¿¤¬Ä̾ï¥Õ¥¡¥¤¥ë (regular file)
624 .\"O Execute permission is denied for the file or a script or ELF interpreter.
625 ¥Õ¥¡¥¤¥ë¤ä¥¹¥¯¥ê¥×¥È¤ä ELF ¥¤¥ó¥¿¥×¥ê¥¿¤Ë
626 ¼Â¹Ôµö²Ä (execute permission) ¤¬Í¿¤¨¤é¤ì¤Æ¤¤¤Ê¤¤¡£
629 .\"O The file system is mounted
633 ¤Ç¥Þ¥¦¥ó¥È¤µ¤ì¤Æ¤¤¤ë¡£
637 .\"O points outside your accessible address space.
639 ¤¬¥¢¥¯¥»¥¹²Äǽ¤Ê¥¢¥É¥ì¥¹¶õ´Ö¤Î³°¤ò»Ø¤·¤Æ¤¤¤ë¡£
642 .\"O An ELF executable had more than one PT_INTERP segment (i.e., tried to
643 .\"O name more than one interpreter).
644 ELF ¼Â¹Ô·Á¼°¤ÇÊ£¿ô¤Î PT_INTERP ¥»¥°¥á¥ó¥È¤¬Â¸ºß¤¹¤ë¡£
645 (¤¹¤Ê¤ï¤ÁÊ£¿ô¤Î¥¤¥ó¥¿¥×¥ê¥¿¤ò»ØÄꤷ¤¿¡£)
648 .\"O An I/O error occurred.
649 I/O ¥¨¥é¡¼¤¬È¯À¸¤·¤¿¡£
652 .\"O An ELF interpreter was a directory.
653 ELF ¥¤¥ó¥¿¥×¥ê¥¿¤¬¥Ç¥£¥ì¥¯¥È¥ê¤À¤Ã¤¿¡£
656 .\"O An ELF interpreter was not in a recognized format.
657 ELF ¥¤¥ó¥¿¥×¥ê¥¿¤¬Íý²ò¤Ç¤¤ë¥Õ¥©¡¼¥Þ¥Ã¥È¤Ç¤Ê¤«¤Ã¤¿¡£
660 .\"O Too many symbolic links were encountered in resolving
662 .\"O or the name of a script or ELF interpreter.
664 ¤ä¥¹¥¯¥ê¥×¥È¤ä ELF ¤Î¥¤¥ó¥¿¥×¥ê¥¿¤ò²ò·è¤¹¤ëºÝ¤ËÁø¶ø¤·¤¿
665 ¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯¤¬Â¿²á¤®¤ë¡£
668 .\"O The process has the maximum number of files open.
669 ¤½¤Î¥×¥í¥»¥¹¤¬¥ª¡¼¥×¥ó¤Ç¤¤ë¥Õ¥¡¥¤¥ë¿ô¤Î¾å¸Â¤Þ¤Ç´û¤Ë¥ª¡¼¥×¥ó¤·¤Æ¤¤¤ë¡£
678 .\"O The system limit on the total number of open files has been reached.
679 ¤½¤Î¥·¥¹¥Æ¥à¤Ç¥ª¡¼¥×¥ó¤Ç¤¤ë¥Õ¥¡¥¤¥ë¿ô¤ÎÀ©¸Â¤Ë㤷¤¿¡£
684 .\"O or a script or ELF interpreter does not exist, or a shared library
685 .\"O needed for file or interpreter cannot be found.
688 ¤«¥¹¥¯¥ê¥×¥È¤ä ELF ¤Î¥¤¥ó¥¿¥×¥ê¥¿¤¬Â¸ºß¤·¤Ê¤¤¡£
691 .\"O An executable is not in a recognized format, is for the wrong
692 .\"O architecture, or has some other format error that means it cannot be
694 ¼Â¹Ô¥Õ¥¡¥¤¥ë¤¬Íý²ò¤Ç¤¤Ê¤¤·Á¼°¤Ç¤¢¤ë¤«¡¢°ã¤¦¥¢¡¼¥¥Æ¥¯¥Á¥ã¤Î¤â¤Î¤«¡¢
695 ¤½¤Î¾¤Î¥Õ¥©¡¼¥Þ¥Ã¥È¡¦¥¨¥é¡¼¤Ë¤è¤ê¼Â¹Ô¤¬¤Ç¤¤Ê¤«¤Ã¤¿¡£
698 .\"O Insufficient kernel memory was available.
699 ¥«¡¼¥Í¥ë¤Ë½½Ê¬¤Ê¥á¥â¥ê¤¬¤Ê¤¤¡£
702 .\"O A component of the path prefix of
704 .\"O or a script or ELF interpreter is not a directory.
706 ¤ä¥¹¥¯¥ê¥×¥È¤ä ELF ¤Î¥¤¥ó¥¿¥×¥ê¥¿¤Î¹½À®Í×ÁǤ¬¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤Ê¤¤¡£
709 .\"O The file system is mounted
711 .\"O the user is not the superuser,
712 .\"O and the file has the set-user-ID or set-group-ID bit set.
715 ¤Ç¥Þ¥¦¥ó¥È¤µ¤ì¡¢¥æ¡¼¥¶¤¬¥¹¡¼¥Ñ¡¼¥æ¡¼¥¶¤Ç¤Ê¤¯¡¢
716 ¥Õ¥¡¥¤¥ë¤Ë set-user-ID ¤¢¤ë¤¤¤Ï set-group-ID ¥Ó¥Ã¥È¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¡£
719 .\"O The process is being traced, the user is not the superuser and the
720 .\"O file has the set-user-ID or set-group-ID bit set.
721 ¥×¥í¥»¥¹¤¬¥È¥ì¡¼¥¹¤µ¤ì¡¢¥æ¡¼¥¶¤¬¥¹¡¼¥Ñ¡¼¥æ¡¼¥¶¤Ç¤Ê¤¯¡¢
722 ¥Õ¥¡¥¤¥ë¤Ë set-user-ID ¤¢¤ë¤¤¤Ï set-group-ID ¥Ó¥Ã¥È¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¡£
725 .\"O Executable was open for writing by one or more processes.
726 ¼Â¹Ô¥Õ¥¡¥¤¥ë¤ò½ñ¤¹þ¤ßÍѤ˥ª¡¼¥×¥ó¤·¤Æ¤¤¤ë¥×¥í¥»¥¹¤¬¤¢¤ë¡£
727 .\"O .SH "CONFORMING TO"
729 .\"O SVr4, 4.3BSD, POSIX.1-2001.
730 .\"O POSIX.1-2001 does not document the #! behavior
731 .\"O but is otherwise compatible.
732 .\"O .\" SVr4 documents additional error
733 .\"O .\" conditions EAGAIN, EINTR, ELIBACC, ENOLINK, EMULTIHOP; POSIX does not
734 .\"O .\" document ETXTBSY, EPERM, EFAULT, ELOOP, EIO, ENFILE, EMFILE, EINVAL,
735 .\"O .\" EISDIR or ELIBBAD error conditions.
736 SVr4, 4.3BSD, POSIX.1-2001.
737 POSIX.1-2001 ¤Ë¤Ï #! Æ°ºî¤Ë¤Ä¤¤¤Æ¤Îµ½Ò¤Ï¤Ê¤¤¤¬¡¢
739 .\" SVr4 ¤Ë¤Ï¾¤Ë EAGAIN, EINTR, ELIBACC, ENOLINK, EMULTIHOP
740 .\" ¤Ë¤Ä¤¤¤Æ¤Îµ½Ò¤¬¤¢¤ë¡£
741 .\" POSIX ¤Ë¤Ï ETXTBSY, EPERM, EFAULT, ELOOP, EIO, ENFILE, EMFILE,
742 .\" EINVAL, EISDIR, ELIBBAD ¥¨¥é¡¼¾õÂ֤ˤĤ¤¤Æ¤Îµ½Ò¤Ï¤Ê¤¤¡£
745 .\"O Set-user-ID and set-group-ID processes can not be
746 .\"O .BR ptrace (2)d.
747 set-user-id ¥×¥í¥»¥¹¤È set-group-ID ¥×¥í¥»¥¹¤Ï
751 .\"O Linux ignores the set-user-ID and set-group-ID bits on scripts.
752 Linux ¤Ï¥¹¥¯¥ê¥×¥È¤Î set-user-ID ¤È set-group-ID ¥Ó¥Ã¥È¤ò̵»ë¤¹¤ë¡£
754 .\"O The result of mounting a file system
756 .\"O varies across Linux kernel versions:
757 .\"O some will refuse execution of set-user-ID and set-group-ID
758 .\"O executables when this would
759 .\"O give the user powers she did not have already (and return
761 .\"O some will just ignore the set-user-ID and set-group-ID bits and
766 ¤Ç¥Þ¥¦¥ó¥È¤·¤¿¾ì¹ç¤Ë set-user-ID/set-group-ID ¤Î¼Â¹Ô¥Õ¥¡¥¤¥ë¤ò
767 ¤É¤ÎÍͤ˰·¤¦¤«¤Ï¡¢Linux ¥«¡¼¥Í¥ë¤Î¥Ð¡¼¥¸¥ç¥ó¤Ë¤è¤Ã¤Æ°Û¤Ê¤ë:
768 ¤¢¤ë¥Ð¡¼¥¸¥ç¥ó¤Ç¤Ï¡¢¤¹¤Ç¤ËɬÍפʸ¢¸Â¤ò»ý¤Ã¤Æ¤¤¤ë¾ì¹ç¤ò½ü¤¤¤Æ¡¢
769 ¤½¤Î¼Â¹Ô¤òµñÈݤ¹¤ë (¤½¤·¤Æ
771 ¤òÊÖ¤¹)¡£Ê̤Τ¢¤ë¥Ð¡¼¥¸¥ç¥ó¤Ç¤Ï
772 set-user-ID/set-group-ID ¥Ó¥Ã¥È¤Î¤ß¤ò̵»ë¤·
776 .\"O A maximum line length of 127 characters is allowed for the first line in
777 .\"O a #! executable shell script.
778 #! ¼Â¹Ô·Á¼°¤Î¥·¥§¥ë¡¦¥¹¥¯¥ê¥×¥È¤Î 1¹ÔÌܤ˵ö¤µ¤ì¤Æ¤¤¤ëʸ»ú¿ô¤Ï¡¢
779 ºÇÂç 127 ʸ»ú¤Ç¤¢¤ë¡£
781 .\"O The semantics of the
783 .\"O argument of an interpreter script vary across implementations.
784 .\"O On Linux, the entire string following the
786 .\"O name is passed as a single argument to the interpreter,
787 .\"O and this string can include white space.
788 .\"O However, behavior differs on some other systems.
790 .\"O .\" e.g., Solaris 8
791 .\"O use the first white space to terminate
792 .\"O .IR optional-arg .
793 .\"O On some systems,
794 .\"O .\" e.g., FreeBSD before 6.0, but not FreeBSD 6.0 onwards
795 .\"O an interpreter script can have multiple arguments,
796 .\"O and white spaces in
798 .\"O are used to delimit the arguments.
799 ¥¤¥ó¥¿¥×¥ê¥¿¡¦¥¹¥¯¥ê¥×¥È¤Î
801 °ú¤¿ô¤Î²ò¼áÊýË¡¤Ï¼ÂÁõ¤Ë¤è¤ê°Û¤Ê¤ë¡£
802 Linux ¤Ç¤Ï¡¢¥¤¥ó¥¿¥×¥ê¥¿Ì¾
804 ¤Ë³¤¯Ê¸»úÎóÁ´ÂΤ¬¥¤¥ó¥¿¥×¥ê¥¿¤Ë 1¸Ä¤Î°ú¤¿ô¤È¤·¤ÆÅϤµ¤ì¤ë¡£
805 ¤·¤«¤·¡¢Æ°ºî¤¬°Û¤Ê¤ë¥·¥¹¥Æ¥à¤â¤¢¤ë¡£
807 .\" Î㤨¤Ð¡¢Solaris 8
809 ¤Î¤¦¤ÁºÇ½é¤Î¥Û¥ï¥¤¥È¡¦¥¹¥Ú¡¼¥¹¤Þ¤Ç¤¬
810 °ú¤¿ô¤È¤·¤ÆÅϤµ¤ì¤ë¡£
811 ¤Þ¤¿¡¢Ê̤Υ·¥¹¥Æ¥à¤Ç¤Ï
812 .\" Î㤨¤Ð¡¢6.0 ¤è¤êÁ°¤Î FreeBSD (FreeBSD 6.0 °Ê¹ß¤Ï°ã¤¦)
813 ¥¤¥ó¥¿¥×¥ê¥¿¡¦¥¹¥¯¥ê¥×¥È¤ÏÊ£¿ô¤Î°ú¤¿ô¤ò»ý¤Ä¤³¤È¤¬¤Ç¤¡¢
815 Æâ¤Î¥Û¥ï¥¤¥È¡¦¥¹¥Ú¡¼¥¹¤¬°ú¤¿ô¤Î¶èÀÚ¤ê¤È¤Ê¤ë¡£
819 .\"O can be specified as NULL,
820 .\"O which has the same effect as specifying this argument
821 .\"O as a pointer to a list containing a single NULL pointer.
822 .\"O .B "Do not take advantage of this misfeature!"
823 .\"O It is nonstandard and nonportable:
824 .\"O on most other Unix systems doing this will result in an error
828 ¤Ë NULL ¤ò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤¤ë¡£¤³¤ì¤Ï¡¢¤³¤Î°ú¤¿ô¤Ë NULL ¥Ý¥¤¥ó¥¿
829 1¸Ä¤À¤±¤ò´Þ¤à¥ê¥¹¥È¤Ø¤Î¥Ý¥¤¥ó¥¿¤ò»ØÄꤷ¤¿¤Î¤ÈƱ¤¸¸ú²Ì¤ò»ý¤Ä¡£
830 .BR ¡Ö¤³¤Î´Ö°ã¤Ã¤¿µ¡Ç½¤òÍøÍѤ·¤Ê¤¤¤³¤È¡× ¡£
831 ¤³¤ì¤ÏÈóɸ½à¤Ç¡¢°Ü¿¢À¤â¤Ê¤¤¡£
832 ¾¤Î¤Û¤È¤ó¤É¤Î Unix ¥·¥¹¥Æ¥à¤Ç¤Ï¡¢¤³¤ì¤ò¹Ô¤¦¤È¥¨¥é¡¼
835 .\" e.g., EFAULT on Solaris 8 and FreeBSD 6.1; but
836 .\" HP-UX 11 is like Linux -- mtk, Apr 2007
837 .\" Bug filed 30 Apr 2007: http://bugzilla.kernel.org/show_bug.cgi?id=8408
838 .\" Bug rejected (because fix would constitute an ABI change).
841 .\"O POSIX.1-2001 says that values returned by
843 .\"O should be invariant over the lifetime of a process.
844 .\"O However, since Linux 2.6.23, if the
845 .\"O .BR RLIMIT_STACK
846 .\"O resource limit changes, then the value reported by
848 .\"O will also change,
849 .\"O to reflect the fact that the limit on space for holding
850 .\"O command-line arguments and environment variables has changed.
853 ¤¬ÊÖ¤¹ÃÍ¤Ï¥×¥í¥»¥¹¤ÎÀ¸Â¸Ãæ¤ÏÊѲ½¤·¤Ê¤¤¤Ù¤¤À¤È¤·¤Æ¤¤¤ë¡£
854 ¤·¤«¤·¤Ê¤¬¤é¡¢Linux 2.6.23 °Ê¹ß¤Ç¤Ï¡¢¥ê¥½¡¼¥¹¾å¸Â
857 ¥³¥Þ¥ó¥É¥é¥¤¥ó°ú¤¿ô¤È´Ä¶ÊÑ¿ô¤òÊÝ»ý¤¹¤ë¤¿¤á¤Î¶õ´Ö¤ËÂФ¹¤ë¾å¸Â¤¬
858 ÊѲ½¤·¤¿¤³¤È¤òÈ¿±Ç¤·¤Æ¡¢
863 .\"O .\" Some Linux versions have failed to check permissions on ELF
864 .\"O .\" interpreters. This is a security hole, because it allows users to
865 .\"O .\" open any file, such as a rewinding tape device, for reading. Some
866 .\"O .\" Linux versions have also had other security holes in
867 .\"O .\" .BR execve ()
868 .\"O .\" that could be exploited for denial of service by a suitably crafted
869 .\"O .\" ELF binary. There are no known problems with 2.0.34 or 2.2.15.
871 .\" Linux ÈǤÎÃæ¤Ë¤Ï¡¢ELF ¥¤¥ó¥¿¥×¥ê¥¿¤Ë¤ª¤±¤ë
872 .\" ¸¢¸Â¤Î¥Á¥§¥Ã¥¯¤Ë¼ºÇÔ¤¹¤ë¤â¤Î¤¬¤¢¤ë¡£
873 .\" ¤³¤ì¤Ï¥»¥¥å¥ê¥Æ¥£¥Û¡¼¥ë¤Ç¤¢¤ë¡£
874 .\" ¤Ê¤¼¤Ê¤é¡¢¥æ¡¼¥¶¤ËǤ°Õ¤Î¥Õ¥¡¥¤¥ë¤ò¥ª¡¼¥×¥ó¤òµö²Ä¤·¤¿¤ê¡¢
875 .\" Æɤ߹þ¤ß¤Î¤¿¤á¤Ë¥Æ¡¼¥×¥Ç¥Ð¥¤¥¹¤ò´¬¤Ìᤷ¤òµö²Ä¤·¤¿¤ê¤¹¤ë¡£
878 .\" ¤Ë¾¤Î¥»¥¥å¥ê¥Æ¥£¥Û¡¼¥ë¤¬
879 .\" ¸ºß¤¹¤ë¤â¤Î¤â¤¢¤ê¡¢¹ªÌ¯¤ËºÙ¹©¤µ¤ì¤¿ ELF ¥Ð¥¤¥Ê¥ê¤Ë¤è¤Ã¤Æ
880 .\" ¥µ¡¼¥Ó¥¹µñÈÝ (denial of service) ¤ËÍøÍѤµ¤ì¤Æ¤·¤Þ¤¦¡£
881 .\" 2.0.34 ¤Þ¤¿ 2.2.15 ¤Ë¤Ï¡¢ÃΤé¤ì¤Æ¤¤¤ëÌäÂê¤Ï¤Ê¤¤¡£
884 .\"O With Unix V6 the argument list of an
886 .\"O call was ended by 0,
887 .\"O while the argument list of
889 .\"O was ended by \-1.
890 .\"O Thus, this argument list was not directly usable in a further
893 .\"O Since Unix V7 both are NULL.
896 ¥³¡¼¥ë¤Î°ú¤¿ô¥ê¥¹¥È¤Ï 0 ¤Ç½ªÃ¼¤µ¤ì¡¢
898 ¤Î°ú¤¿ô¥ê¥¹¥È¤Ï \-1 ¤Ç½ªÃ¼¤µ¤ì¤Æ¤¤¤¿¡£
901 ¤Î°ú¤¿ô¥ê¥¹¥È¤Ï¡¢¤½¤Î¸å¤Î
903 ¥³¡¼¥ë¤Ë¤ÏľÀÜ»ÈÍѤǤ¤Ê¤«¤Ã¤¿¡£
904 Unix V7 °Ê¹ß¤Ç¤Ï¡¢¤È¤â¤Ë NULL ¤Ç½ªÃ¼¤µ¤ì¤ë¡£
907 .\"O The following program is designed to be execed by the second program below.
908 .\"O It just echoes its command-line one per line.
909 ¤³¤Î¥×¥í¥°¥é¥à¤Ï¡¢°Ê²¼¤ÎÆó¤ÄÌÜ¤Î¥×¥í¥°¥é¥à¤«¤é¼Â¹Ô¤¹¤ë¤¿¤á¤Î¤â¤Î¤Ç¤¢¤ë¡£
910 ¥³¥Þ¥ó¥É¥é¥¤¥ó¤ò 1¹Ô¤Ë 1¸Ä¤º¤Äɽ¼¨¤¹¤ë¤À¤±¤Î¥×¥í¥°¥é¥à¤Ç¤¢¤ë¡£
920 main(int argc, char *argv[])
924 for (j = 0; j < argc; j++)
925 printf("argv[%d]: %s\\n", j, argv[j]);
932 .\"O This program can be used to exec the program named in its command-line
934 °Ê²¼¤Î¥×¥í¥°¥é¥à¤Ï¡¢¥³¥Þ¥ó¥É¥é¥¤¥ó°ú¤¿ô¤Ç»ØÄꤷ¤¿Ì¾Á°¤Î¥×¥í¥°¥é¥à¤ò
946 main(int argc, char *argv[])
948 char *newargv[] = { NULL, "hello", "world", NULL };
949 char *newenviron[] = { NULL };
952 fprintf(stderr, "Usage: %s <file-to-exec>\\n", argv[0]);
956 newargv[0] = argv[1];
958 execve(argv[1], newargv, newenviron);
959 perror("execve"); /* execve() only returns on error */
965 .\"O We can use the second program to exec the first as follows:
966 Æó¤ÄÌÜ¤Î¥×¥í¥°¥é¥à¤ò»È¤Ã¤Æ°ì¤ÄÌÜ¤Î¥×¥í¥°¥é¥à¤ò¼Â¹Ô¤¹¤ë¤Ë¤Ï
971 .RB "$" " cc myecho.c \-o myecho"
972 .RB "$" " cc execve.c \-o execve"
973 .RB "$" " ./execve ./myecho"
980 .\"O We can also use these programs to demonstrate the use of a script
982 .\"O To do this we create a script whose "interpreter" is our
985 ¤µ¤é¤Ë¡¢¤³¤ì¤é¤Î¥×¥í¥°¥é¥à¤ò»È¤Ã¤Æ¡¢¥¹¥¯¥ê¥×¥È¡¦¥¤¥ó¥¿¥×¥ê¥¿¤ÎÎã¤ò¼¨¤¹¡£
986 ¤³¤Î¤¿¤á¤Ë¡¢¡Ö¥¤¥ó¥¿¥×¥ê¥¿¡×¤È¤·¤ÆÀè¤Û¤ÉºîÀ®¤·¤¿¥×¥í¥°¥é¥à
988 ¤ò»È¤¦¥¹¥¯¥ê¥×¥È¤òºîÀ®¤¹¤ë¡£
992 .RB "$" " cat > script.sh"
993 .B #! ./myecho script-arg
995 .RB "$" " chmod +x script.sh"
999 .\"O We can then use our program to exec the script:
1000 ºîÀ®¤·¤Æ¤ª¤¤¤¿¥×¥í¥°¥é¥à¤ò»È¤Ã¤Æ¥¹¥¯¥ê¥×¥È¤ò¼Â¹Ô¤¹¤ë¡£
1004 .RB "$" " ./execve ./script.sh"
1007 argv[2]: ./script.sh
1020 .BR credentials (7),
1022 .BR path_resolution (7),