Unix-system-calls-execve
[top]#
|http://www.google.com/[Google] | a|
Web | This Site |
選択した読書
Copyright©2014 by finddevguides |
[cols=",,,,,,,",] |
| | Home | | References | | Discussion Forums | | About TP
[width="100%",cols="100%",] |
a| == execve()-Unix、Linuxシステムコール
[[File:]] image :http://www.finddevguides.com/images/next.gif [next] image:http://www.finddevguides.com/add- this.gif [AddThisソーシャルブックマークボタン]
広告
NAME
execve-プログラムの実行
概要
#include <unistd.h> int execve(const char* filename, char *const argv[], char *const envp[]); |
説明
_argv_は、新しいプログラムに渡される引数文字列の配列です。 _envp_は文字列の配列で、通常は key = value の形式で、環境として新しいプログラムに渡されます。 _argv_と_envp_の両方は、nullポインターで終了する必要があります。 引数ベクトルと環境は、 int main(int argc、char argv []、char * envp [])*として定義されている場合、呼び出されたプログラムのメイン関数からアクセスできます。
現在のプログラムがptraceされている場合、 execve ()が成功した後に SIGTRAP が送信されます。
_filename_が指すプログラムファイルにset-user-IDビットが設定されており、呼び出しプロセスがptraceされていない場合、呼び出しプロセスの有効なユーザーIDはプログラムファイルの所有者のユーザーIDに変更されます。 i同様に、プログラムファイルのset-group-IDビットが設定されると、呼び出しプロセスの実効グループIDがプログラムファイルのグループに設定されます。
プロセスの実効ユーザーIDは、保存されたset-user-IDにコピーされます。同様に、有効なグループIDは保存されたset-group-IDにコピーされます。 このコピーは、set-user-IDおよびset-group-ID許可ビットが原因で発生する有効なIDの変更後に行われます。
実行可能ファイルが共有ライブラリスタブを含むa.out動的リンクバイナリ実行可能ファイルである場合、Linux動的リンカー ld.so (8)が実行の開始時に呼び出され、必要な共有ライブラリをメモリに取り込み、実行可能ファイルをリンクします。それら。
実行可能ファイルが動的にリンクされたELF実行可能ファイルである場合、PT_INTERPセグメントで指定されたインタープリターを使用して、必要な共有ライブラリーをロードします。 このインタープリターは通常、Linux libcバージョン5にリンクされたバイナリーの場合は_/lib/ld-linux.so.1_、GNU libcバージョン2にリンクされたバイナリーの場合は_/lib/ld-linux.so.2_です。
返り値
成功した場合、 execve ()は戻りません。エラーの場合、-1が返され、_errno_が適切に設定されます。
エラー
Error Code | Description |
---|---|
E2BIG | The total number of bytes in the environment (envp) and argument list (argv) is too large. |
*EACCES * | Search permission is denied on a component of the path prefix of filename or the name of a script interpreter. (See also* path_resolution*(2).) |
EACCES | The file or a script interpreter is not a regular file. |
EACCES | Execute permission is denied for the file or a script or ELF interpreter. |
EACCES | The file system is mounted noexec. |
EFAULT | filename points outside your accessible address space. |
EINVAL | An ELF executable had more than one PT_INTERP segment (i.e., tried to name more than one interpreter). |
EIO | An I/O error occurred. |
EISDIR | An ELF interpreter was a directory. |
ELIBBAD | An ELF interpreter was not in a recognised format. |
ELOOP | Too many symbolic links were encountered in resolving filename or the name of a script or ELF interpreter. |
EMFILE | The process has the maximum number of files open. |
ENAMETOOLONG | filename is too long. |
ENFILE | The system limit on the total number of open files has been reached. |
ENOENT | The file filename or a script or ELF interpreter does not exist, or a shared library needed for file or interpreter cannot be found. |
ENOEXEC | An executable is not in a recognised format, is for the wrong architecture, or has some other format error that means it cannot be executed. |
ENOMEM | Insufficient kernel memory was available. |
ENOTDIR | A component of the path prefix of filename or a script or ELF interpreter is not a directory. |
EPERM | The file system is mounted nosuid, the user is not the superuser, and the file has an SUID or SGID bit set. |
EPERM | The process is being traced, the user is not the superuser and the file has an SUID or SGID bit set. |
ETXTBSY | Executable was open for writing by one or more processes. |
準拠
SVr4、4.3BSD、POSIX.1-2001。 POSIX.1-2001は#!を文書化していません。 動作しますが、それ以外は互換性があります。
ノート
SUIDおよびSGIDプロセスは ptrace ()dにできません。 Linuxは、スクリプトのSUIDおよびSGIDビットを無視します。
ファイルシステムをマウントした結果_nosuid_はLinuxカーネルのバージョンによって異なります。これは、SUID/SGID実行可能ファイルの実行を拒否し、ユーザーがまだ持っていない(およびEPERMを返す)場合、SUID/SGIDビットを無視し、 exec ()は正常に終了しました。
#!の最初の行の最大行長は127文字です。 実行可能なシェルスクリプト。
歴史的
Unix V6では、 exec ()呼び出しの引数リストは0で終了しましたが、_main_の引数リストは-1で終了しました。 したがって、この引数リストは、以降の exec ()呼び出しで直接使用できませんでした。 Unix V7は両方ともNULLです。
関連項目
[[File:]] image :http://www.finddevguides.com/images/next.gif [next] [[File:]]
広告
|
[cols="^",] |
|Advertisements