.\" Copyright (c) 2007 by Michael Kerrisk .\" .\" 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. .\" .\" 2007-06-13 Creation .\" .\" Japanese Version Copyright (c) 2007 Akihiro MOTOKI all rights reserved. .\" Translated 2007-10-25, Akihiro MOTOKI , LDP v2.66 .\" Updated 2008-08-04, Akihiro MOTOKI, LDP v3.05 .\" .TH CREDENTIALS 7 2008-06-03 "Linux" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O credentials \- process identifiers credentials \- 認証に用いられるプロセスの識別子 .\"O .SH DESCRIPTION .SH 説明 .\"O .SS Process ID (PID) .SS プロセスID (PID) .\"O Each process has a unique nonnegative integer identifier .\"O that is assigned when the process is created using .\"O .BR fork (2). .\"O A process can obtain its PID using .\"O .BR getpid (2). .\"O A PID is represented using the type .\"O .I pid_t .\"O (defined in .\"O .IR ). 各プロセスは、負でない整数の一意な識別子を持つ。 この識別子は .BR fork (2) を使ってプロセスが生成される際に割り当てられる。 プロセスは .BR getpid (2) を使って自分の PID を取得できる。 PID は .I pid_t 型で表現される .RI ( pid_t は .I で定義されている)。 .\"O PIDs are used in a range of system calls to identify the process .\"O affected by the call, for example: PID は各種のシステムコールでそのシステムコールが作用するプロセスを 特定するために使用される。以下に例を挙げる: .BR kill (2), .BR ptrace (2), .BR setpriority (2), .\" .BR sched_rr_get_interval (2), .\" .BR sched_getaffinity (2), .\" .BR sched_setaffinity (2), .\" .BR sched_getparam (2), .\" .BR sched_setparam (2), .\" .BR sched_setscheduler (2), .\" .BR sched_getscheduler (2), .BR setpgid (2), .\" .BR getsid (2), .BR setsid (2), .BR sigqueue (2), .\"O and .BR waitpid (2). .\" .BR waitid (2), .\" .BR wait4 (2), .\"O A process's PID is preserved across an .\"O .BR execve (2). プロセスの PID は .BR execve (2) の前後で不変である。 .\"O .SS Parent Process ID (PPID) .SS 親プロセス ID (PPID) .\"O A process's parent process ID identifies the process that created .\"O this process using .\"O .BR fork (2). .\"O A process can obtain its PPID using .\"O .BR getppid (2). .\"O A PPID is represented using the type .\"O .IR pid_t . プロセスの親プロセスの ID は、 .BR fork (2) を使ってそのプロセスを生成したプロセスを示す。 プロセスは .BR getppid (2) を使って自分の PPID を取得できる。 PPID は .I pid_t 型で表現される。 .\"O A process's PPID is preserved across an .\"O .BR execve (2). プロセスの PPID は .BR execve (2) の前後で不変である。 .\"O .SS Process Group ID and Session ID .SS プロセスグループ ID とセッション ID .\"O Each process has a session ID and a process group ID, .\"O both represented using the type .\"O .IR pid_t . .\"O A process can obtain its session ID using .\"O .BR getsid (2), .\"O and its process group ID using .\"O .BR getpgrp (2). 各プロセスはセッション ID とプロセスグループ ID を持つ。 これらの ID はどちらも .I pid_t 型で表現される。 プロセスは、それぞれ .BR getsid (2), .BR getpgrp (2) を使って自分のセッション ID、プロセスグループ ID を取得できる。 .\"O A child created by .\"O .BR fork (2) .\"O inherits its parent's session ID and process group ID. .\"O A process's session ID and process group ID are preserved across an .\"O .BR execve (2). .BR fork (2) で生成された子プロセスは親プロセスのセッション ID とプロセスグループ ID を継承する。プロセスのセッション ID とプロセスグループ ID は .BR execve (2) の前後で不変である。 .\"O Sessions and process groups are abstractions devised to support shell .\"O job control. .\"O A process group (sometimes called a "job") is a collection of .\"O processes that share the same process group ID; .\"O the shell creates a new process group for the process(es) used .\"O to execute single command or pipeline (e.g., the two processes .\"O created to execute the command "ls\ |\ wc" are placed in the .\"O same process group). .\"O A process's group membership can be set using .\"O .BR setpgid (2). .\"O The process whose process ID is the same as its process group ID is the .\"O \fIprocess group leader\fP for that group. セッションとプロセスグループの概念は、シェルのジョブ制御を行うために 考案されたものである。 プロセスグループ (時には「ジョブ」と呼ばれることもある) は、 同じプロセスグループ ID を共有するプロセスの集まりである。 シェルは、一つのコマンドもしくはパイプラインの実行に使われるプロセス群に 対して一つのプロセスグループを生成する (例えば、コマンド "ls\ |\ wc" を実行するために生成される二つのプロセスは 同じプロセスグループに置かれる)。 所属するプロセスグループは .BR setpgid (2) を使って設定できる。 自身のプロセス ID がプロセスグループ ID と同じプロセスは、 そのグループの「プロセスグループ・リーダー」である。 .\"O A session is a collection of processes that share the same session ID. .\"O All of the members of a process group also have the same session ID .\"O (i.e., all of the members of a process group always belong to the .\"O same session, so that sessions and process groups form a strict .\"O two-level hierarchy of processes.) .\"O A new session is created when a process calls .\"O .BR setsid (2), .\"O which creates a new session whose session ID is the same .\"O as the PID of the process that called .\"O .BR setsid (2). .\"O The creator of the session is called the \fIsession leader\fP. セッションは、同じセッション ID を共有するプロセスの集まりである。 ある一つのプロセスグループの全メンバーは同じセッション ID を持つ (つまり、一つのプロセスグループのメンバーは全て同じセッションに所属し、 これにより、セッションとプロセスグループで二階層のプロセス階層が形成できる)。 新たなセッションの生成はプロセスが .BR setsid (2) を呼び出すことで行う。 .BR setsid (2) は、 .BR setsid (2) を呼び出したプロセスの PID と同じ値のセッション ID を持つ 新たなセッションを生成する。 セッションの生成者は「セッション・リーダー」と呼ばれる。 .\"O .SS User and Group Identifiers .SS ユーザ ID とグループ ID .\"O Each process has various associated user and groups IDs. .\"O These IDs are integers, respectively represented using the types .\"O .I uid_t .\"O and .\"O .I gid_t .\"O (defined in .\"O .IR ). 各プロセスは、数種類のユーザ ID とグループ ID を持つ。 ユーザ ID、グループ ID は整数で、それぞれ .IR uid_t , .I gid_t 型で表現される (これらは .I で定義されている)。 .\"O On Linux, each process has the following user and group identifiers: Linux では、各プロセスは以下のような種類のユーザ ID とグループ ID を持つ。 .IP * 3 .\"O Real user ID and real group ID. 実ユーザ ID と実グループ ID。 .\"O These IDs determine who owns the process. .\"O A process can obtain its real user (group) ID using .\"O .BR getuid (2) .\"O .RB ( getgid (2)). これらの ID によりプロセスの所有者が決定される。 プロセスが自分の実ユーザ ID、実グループ ID を取得するには、それぞれ .BR getuid (2), .BR getgid (2) を使用する。 .IP * .\"O Effective user ID and effective group ID. 実効ユーザ ID と実効グループ ID。 .\"O These IDs are used by the kernel to determine the permissions .\"O that the process will have when accessing shared resources such .\"O as message queues, shared memory, and semaphores. .\"O On most UNIX systems, these IDs also determine the .\"O permissions when accessing files. .\"O However, Linux uses the file system IDs described below .\"O for this task. .\"O A process can obtain its effective user (group) ID using .\"O .BR geteuid (2) .\"O .RB ( getegid (2)). これらの ID は、メッセージキュー、共有メモリ、セマフォなどの 共有リソースにアクセスしようとした際にそのプロセスがアクセス許可を 持っているかをカーネルが判定するのに使用される。 ほとんどの UNIX システムでは、これらの ID はファイルへのアクセス時の アクセス許可の判定にも使用される。 しかしながら、Linux ではファイルへのアクセス許可の判定には 後述のファイルシステム ID が使用される。 プロセスが自分の実効ユーザ ID、実効グループ ID を取得するには、それぞれ .BR geteuid (2), .BR getegid (2) を使用する。 .IP * .\"O Saved set-user-ID and saved set-group-ID. 保存 (saved) set-user-ID と保存 set-group-ID。 .\"O These IDs are used in set-user-ID and set-group-ID programs to save .\"O a copy of the corresponding effective IDs that were set when .\"O the program was executed (see .\"O .BR execve (2)). これらの ID は、set-user-ID や set-group-ID されたプログラムにおいて、 プログラムの実行時に設定された実効 ID のコピーを保存するために 使用される .RB ( execve (2) 参照)。 .\"O A set-user-ID program can assume and drop privileges by .\"O switching its effective user ID back and forth between the values .\"O in its real user ID and saved set-user-ID. .\"O This switching is done via calls to .\"O .BR seteuid (2), .\"O .BR setreuid (2), .\"O or .\"O .BR setresuid (2). .\"O A set-group-ID program performs the analogous tasks using .\"O .BR setegid (2), .\"O .BR setregid (2), .\"O or .\"O .BR setresgid (2). set-user-ID プログラムは、実効ユーザ ID を実ユーザID と保存 set-user-ID の間で行ったり来たり切り替えることで、特権を得たり落としたりできる。 この切り替えは .BR seteuid (2), .BR setreuid (2), .BR setresuid (2) を呼び出すことで実行できる。 set-group-ID プログラムは、 .BR setegid (2), .BR setregid (2), .BR setresgid (2) を使って同様のことができる。 .\"O A process can obtain its saved set-user-ID (set-group-ID) using .\"O .BR getresuid (2) .\"O .RB ( getresgid (2)). プロセスが自分の保存 set-user-ID、保存 set-group-ID を取得するには、 .BR getresuid(2), .BR getresgids (2) をそれぞれ使用する。 .IP * .\"O File system user ID and file system group ID (Linux-specific). ファイルシステム・ユーザ ID とファイルシステム・グループ ID (Linux 固有)。 .\"O These IDs, in conjunction with the supplementary group IDs described .\"O below, are used to determine permissions for accessing files; see .\"O .BR path_resolution (7) .\"O for details. .\"O Whenever a process's effective user (group) ID is changed, .\"O the kernel also automatically changes the file system user (group) ID .\"O to the same value. .\"O Consequently, the file system IDs normally have the same values .\"O as the corresponding effective ID, and the semantics for file-permission .\"O checks are thus the same on Linux as on other UNIX systems. .\"O The file system IDs can be made to differ from the effective IDs .\"O by calling .\"O .BR setfsuid (2) .\"O and .\"O .BR setfsgid (2). これらの ID は、後述の補助グループ ID と組み合わせて使用され、 ファイルへのアクセス権の決定に利用される。詳細は .BR path_resolution (7) を参照。 プロセスの実効 ID (ユーザ ID や グループ ID) が変更されるたびに、 カーネルは自動的に対応するファイルシステム ID を同じ値に変更する。 その結果、ファイルシステム ID は通常は対応する実効 ID と同じ値となり、 ファイルのアクセス権のチェック方法は Linux と他の UNIX システムで同じである。 ファイルシステム ID は実効 ID とは異なる値にすることができ、 変更は .BR setfsuid (2) と .BR setfsgid (2) を呼び出して行う。 .IP * .\"O Supplementary group IDs. 補助グループ ID。 .\"O This is a set of additional group IDs that are used for permission .\"O checks when accessing files and other shared resources. .\"O On Linux kernels before 2.6.4, .\"O a process can be a member of up to 32 supplementary groups; .\"O since kernel 2.6.4, .\"O a process can be a member of up to 65536 supplementary groups. この ID は、ファイルや他の共有リソースへのアクセス時にアクセス許可の チェックに使用される、追加のグループ ID の集合である。 カーネル 2.6.4 より前の Linux では、一つのプロセスあたりの 補助グループのメンバー数は最大で 32 である。 カーネル 2.6.4 以降では、一つのプロセスあたりの 補助グループのメンバー数は最大で 65536 である。 .\"O The call .\"O .I sysconf(_SC_NGROUPS_MAX) .\"O can be used to determine the number of supplementary groups .\"O of which a process may be a member. .I sysconf(_SC_NGROUPS_MAX) を呼び出すことで、あるプロセスがメンバーとなることができる可能性のある 補助グループ数を知ることができる。 .\" Since kernel 2.6.4, the limit is visible via the read-only file .\" /proc/sys/kernel/ngroups_max. .\" As at 2.6.22-rc2, this file is still read-only. .\"O A process can obtain its set of supplementary group IDs using .\"O .BR getgroups (2), .\"O and can modify the set using .\"O .BR setgroups (2). プロセスは、自分の補助グループ ID の集合を .BR getgroups (2) で取得でき、 .BR setgroups (2) で集合を変更できる。 .PP .\"O A child process created by .\"O .BR fork (2) .\"O inherits copies of its parent's user and groups IDs. .\"O During an .\"O .BR execve (2), .\"O a process's real user and group ID and supplementary .\"O group IDs are preserved; .\"O the effective and saved set IDs may be changed, as described in .\"O .BR execve (2). .BR fork (2) で生成された子プロセスは親プロセスのユーザ ID とグループ ID を継承する。 .BR execve (2) の間、プロセスの実ユーザ/グループ ID と補助グループ ID 集合は不変である。 実効 ID と保存セット ID は変更される可能性がある .RB ( execve (2) で説明されている)。 .\"O Aside from the purposes noted above, .\"O a process's user IDs are also employed in a number of other contexts: 上記の目的以外にも、プロセスのユーザ ID は他の様々な場面で利用される。 .IP * 3 .\"O when determining the permissions for sending signals \(em see .\"O .BR kill (2); シグナルを送る許可の判定時 \(em .BR kill (2) 参照。 .IP * .\"O when determining the permissions for setting .\"O process-scheduling parameters (nice value, real time .\"O scheduling policy and priority, CPU affinity, I/O priority) using .\"O .BR setpriority (2), .\"O .BR sched_setaffinity (2), .\"O .BR sched_setscheduler (2), .\"O .BR sched_setparam (2), .\"O and .\"O .BR ioprio_set (2); プロセスのスケジューリング関連のパラメータ (nice 値、 リアルタイム・スケジューリングポリシーや優先度、CPU affinity、 入出力優先度) の設定許可の判定時。 スケジューリング関連のパラメータ設定には .BR setpriority (2), .BR sched_setaffinity (2), .BR sched_setscheduler (2), .BR sched_setparam (2), .BR ioprio_set (2) が使用される。 .IP * .\"O when checking resource limits; see .\"O .BR getrlimit (2); リソース上限のチェック時。 .BR getrlimit (2) 参照。 .IP * .\"O when checking the limit on the number of inotify instances .\"O that the process may create; see .\"O .BR inotify (7). プロセスが生成できる inotify インスタンス数の上限のチェック時。 .BR inotify (7) 参照。 .\"O .SH "CONFORMING TO" .SH 準拠 .\"O Process IDs, parent process IDs, process group IDs, and session IDs .\"O are specified in POSIX.1-2001. .\"O The real, effective, and saved set user and groups IDs, .\"O and the supplementary group IDs, are specified in POSIX.1-2001. .\"O The file system user and group IDs are a Linux extension. プロセス ID、親プロセス ID、プロセスグループ ID、セッション ID は POSIX.1-2001 で規定されている。 実 ID、実効 ID、保存セット ID のユーザ ID / グループ ID および 補助グループ ID は POSIX.1-2001 で規定されている。 ファイルシステム・ユーザ ID / グループ ID は Linux による拡張である。 .\"O .SH NOTES .SH 注意 .\"O The POSIX threads specification requires that .\"O credentials are shared by all of the threads in a process. .\"O However, at the kernel level, Linux maintains separate user and group .\"O credentials for each thread. .\"O The NPTL threading implementation does some work to ensure .\"O that any change to user or group credentials .\"O (e.g., calls to .\"O .BR setuid (2), .\"O .BR setresuid (2), .\"O etc.) .\"O is carried through to all of the POSIX threads in a process. POSIX のスレッド仕様では、これらの識別子がプロセス内の全スレッドで 共有されることを求めている。 しかしながら、カーネルのレベルでは、Linux はスレッド毎に別々の ユーザとグループに関する識別子を管理している。 NPTL スレッド実装が、(例えば .BR setuid (2), .BR setresuid (2) などの呼び出しによる) ユーザやグループに関する識別子に対する変更が プロセス内の全ての POSIX スレッドに対して反映されることを保証する ための処理を行っている。 .\"O .SH "SEE ALSO" .SH 関連項目 .BR bash (1), .BR csh (1), .BR ps (1), .BR access (2), .BR execve (2), .BR faccessat (2), .BR fork (2), .BR getpgrp (2), .BR getpid (2), .BR getppid (2), .BR getsid (2), .BR kill (2), .BR killpg (2), .BR setegid (2), .BR seteuid (2), .BR setfsgid (2), .BR setfsuid (2), .BR setgid (2), .BR setgroups (2), .BR setresgid (2), .BR setresuid (2), .BR setuid (2), .BR waitpid (2), .BR euidaccess (3), .BR initgroups (3), .BR tcgetpgrp (3), .BR tcsetpgrp (3), .BR capabilities (7), .BR path_resolution (7), .BR unix (7)