OSDN Git Service

(split) DP: release pages (catch up to 3.50).
[linuxjm/LDP_man-pages.git] / release / man2 / access.2
1 .\" This manpage is Copyright (C) 1992 Drew Eckhardt;
2 .\"                               1993 Michael Haardt, Ian Jackson.
3 .\" and Copyright (C) 2007 Michael Kerrisk <mtk.manpages@gmail.com>
4 .\"
5 .\" %%%LICENSE_START(VERBATIM)
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.
9 .\"
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.
14 .\"
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
21 .\" professionally.
22 .\"
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" %%%LICENSE_END
26 .\"
27 .\" Modified 1993-07-21 Rik Faith (faith@cs.unc.edu)
28 .\" Modified 1994-08-21 by Michael Chastain (mec@shell.portal.com):
29 .\"   Removed note about old kernel (pre-1.1.44) using wrong id on path.
30 .\" Modified 1996-03-18 by Martin Schulze (joey@infodrom.north.de):
31 .\"   Stated more clearly how it behaves with symbolic links.
32 .\" Added correction due to Nick Duffek (nsd@bbc.com), aeb, 960426
33 .\" Modified 1996-09-07 by Michael Haardt:
34 .\"   Restrictions for NFS
35 .\" Modified 1997-09-09 by Joseph S. Myers <jsm28@cam.ac.uk>
36 .\" Modified 1998-01-13 by Michael Haardt:
37 .\"   Using access is often insecure
38 .\" Modified 2001-10-16 by aeb
39 .\" Modified 2002-04-23 by Roger Luethi <rl@hellgate.ch>
40 .\" Modified 2004-06-23 by Michael Kerrisk
41 .\" 2007-06-10, mtk, various parts rewritten, and added BUGS section.
42 .\"
43 .\"*******************************************************************
44 .\"
45 .\" This file was generated with po4a. Translate the source file.
46 .\"
47 .\"*******************************************************************
48 .TH ACCESS 2 2013\-02\-28 Linux "Linux Programmer's Manual"
49 .SH 名前
50 access \- ファイルに対する実ユーザーでのアクセス権をチェックする
51 .SH 書式
52 .nf
53 \fB#include <unistd.h>\fP
54 .sp
55 \fBint access(const char *\fP\fIpathname\fP\fB, int \fP\fImode\fP\fB);\fP
56 .fi
57 .SH 説明
58 \fBaccess\fP()  は、呼び出し元プロセスがファイル \fIpathname\fP にアクセスできるかどうかをチェックする。 \fIpathname\fP
59 がシンボリック・リンクの場合、シンボリック・リンクは展開される。
60
61 .\" F_OK is defined as 0 on every system that I know of.
62 \fImode\fP はチェックを行うアクセス権を指定するもので、その値は \fBF_OK\fP、 もしくは \fBR_OK\fP, \fBW_OK\fP, \fBX_OK\fP の
63 1個以上のビット単位の論理和から構成されるマスクである。 \fBF_OK\fP はファイルが存在するかどうかのみを検査する。 \fBR_OK\fP,
64 \fBW_OK\fP, \fBX_OK\fP は、ファイルが存在して、それぞれ読み込み、書き込み、実行の許可があるか を検査する。
65
66 チェックは、実際に操作が行われる際に使用される実効 (effective) ID でなく、 呼び出し元プロセスの \fI実 (real)\fP UID と
67 \fI実 (real)\fP GID を使って行われる。 これにより、set\-user\-ID プログラムで、プログラムを起動するユーザの権限を
68 簡単に決定することができる。
69
70 呼び出し元プロセスが特権プロセス (つまり、プロセスの実 UID が 0) の場合、 通常のファイルに対する \fBX_OK\fP
71 のチェックは、そのファイルの所有者、グループ、他人のいずれかの 実行許可が有効になっていれば成功する。
72 .SH 返り値
73 成功した場合 (要求した全てについて許可が得られたら)、ゼロが返される。 エラーの場合 (\fImode\fP
74 の少なくとも一つのビットで要求した許可がなかった場合や、 他のエラーが起こった場合)、\-1 が返され、 \fIerrno\fP が適切に設定される。
75 .SH エラー
76 \fBaccess\fP()  は以下の場合に失敗する。
77 .TP 
78 \fBEACCES\fP
79 要求されたアクセスは そのファイル自身に拒否されたか \fIpathname\fP へ至るまでディレクトリのいずれかに対する検索許可 (search
80 permission) が得られなかった。 (\fBpath_resolution\fP(7)  も参照のこと)
81 .TP 
82 \fBELOOP\fP
83 \fIpathname\fP を解決するときに、解決すべきシンボリックリンクが多すぎた。
84 .TP 
85 \fBENAMETOOLONG\fP
86 \fIpathname\fP が長過ぎる。
87 .TP 
88 \fBENOENT\fP
89 \fIpathname\fP を構成するパスのいずれかが、存在しないか、 参照先のない (dangling) シンボリックリンクになっている。
90 .TP 
91 \fBENOTDIR\fP
92 \fIpathname\fP のディレクトリ部分が実際にはディレクトリでない。
93 .TP 
94 \fBEROFS\fP
95 読み込み専用 (read\-only) のファイル・システムに対して書き込み許可を 要求した。
96 .PP
97 \fBaccess\fP()  は以下の理由により失敗することがある。
98 .TP 
99 \fBEFAULT\fP
100 \fIpathname\fP がアクセス可能なアドレス空間の外を指している。
101 .TP 
102 \fBEINVAL\fP
103 \fImode\fP に不正な値が指定された。
104 .TP 
105 \fBEIO\fP
106 I/O エラーが発生した。
107 .TP 
108 \fBENOMEM\fP
109 カーネルに十分なメモリがない。
110 .TP 
111 \fBETXTBSY\fP
112 実行中のファイルに対して書き込みを要求した。
113 .SH 準拠
114 SVr4, 4.3BSD, POSIX.1\-2001.
115 .SH 注意
116 .PP
117 \fB警告\fP: あるユーザが、例えば \fBopen\fP(2) によるアクセスが可能かどうかを、
118 (実際に行う前に) \fBaccess\fP() を使ってチェックするのは、セキュリティホール
119 の原因になる。なぜならチェックをしてから 実際にファイルのオープン操作を
120 する間の短い間隔を悪用できるからである。 \fBこの理由があるので、この
121 システムコールを使うのは避けるべきである。\fP
122 (ここで説明した例の場合には、より安全な方法としては、
123 そのプロセスの実効ユーザ ID を実ユーザ ID に一時的に切り替えてから
124 \fBopen\fP(2) を呼び出す方法がある。)
125 .PP
126 \fBaccess\fP()  always dereferences symbolic links.  If you need to check the
127 permissions on a symbolic link, use \fBfaccessat\fP(2)  with the flag
128 \fBAT_SYMLINK_NOFOLLOW\fP.
129 .PP
130 \fImode\fP で指定されたアクセス種別のいずれか一つでも拒否されると、 たとえ \fImode\fP で指定された他のアクセス種別が許可されたとしても、
131 \fBaccess\fP()  はエラーを返す。
132 .PP
133 .\" HPU-UX 11 and Tru64 5.1 do this.
134 POSIX.1\-2001 では、 呼び出し元プロセスが適切な特権を持っている場合 (つまり、スーパーユーザの場合)、
135 たとえファイルの実行許可ビットが全くセットされていなくても \fBX_OK\fP のチェックとして成功を返す実装が認められている。 Linux
136 はこのようにはなっていない。
137 .PP
138 \fIpathname\fP のプレフィックスを構成するディレクトリの全てに対して 検索アクセス (すなわち、実行アクセス) が許可された場合にのみ、
139 ファイルはアクセス可能となる。 いずれかのディレクトリがアクセス不可の場合、 ファイル自身のアクセス許可に関わらず、 \fBaccess\fP()
140 は失敗する。
141 .PP
142 アクセス・ビットのみがチェックされ、ファイルの種類や内容はチェックされない。 従って、ディレクトリが書き込み可能となった場合は、ディレクトリに
143 ファイルを作成することが可能なことを意味するのであり、ディレクトリに ファイルとして書き込むことができるわけではない。 同様に DOS
144 のファイルは「実行可能」と判断されるが、 \fBexecve\fP(2)  コールは失敗するだろう。
145 .PP
146 \fBaccess\fP()  may not work correctly on NFS file systems with UID mapping
147 enabled, because UID mapping is done on the server and hidden from the
148 client, which checks permissions.  Similar problems can occur to FUSE
149 mounts.
150 .SH バグ
151 .\" This behavior appears to have been an implementation accident.
152 バージョン 2.4 (とそれ以前) のカーネルには、スーパーユーザでの \fBX_OK\fP のチェックの扱いに奇妙な点がある。 ディレクトリ以外のファイルで
153 (ユーザ、グループ、他人の) 全てのカテゴリについて 実行許可がない場合、 \fBaccess\fP()  のチェックで \-1 が返るのは \fImode\fP に
154 \fBX_OK\fP だけが指定されたときだけであり \fImode\fP に \fBR_OK\fP や \fBW_OK\fP が一緒に指定された場合には
155 \fBaccess\fP()  は 0 を返す。 (バージョン 2.6.3 以前の) 初期の 2.6 系のカーネルも 2.4 系のカーネルと同様の動作をする。
156
157 2.6.20 より前のカーネルでは、 ファイルが存在するファイルシステムを \fBmount\fP(2)  する際に指定された \fBMS_NOEXEC\fP
158 フラグの効果を、 \fBaccess\fP()  は無視していた。 カーネル 2.6.20 以降では、 \fBaccess\fP()
159 はこのフラグを考慮するようになっている。
160 .SH 関連項目
161 \fBchmod\fP(2), \fBchown\fP(2), \fBfaccessat\fP(2), \fBopen\fP(2), \fBsetgid\fP(2),
162 \fBsetuid\fP(2), \fBstat\fP(2), \fBeauidaccess\fP(3), \fBcredentials\fP(7),
163 \fBpath_resolution\fP(7)
164 .SH この文書について
165 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.50 の一部
166 である。プロジェクトの説明とバグ報告に関する情報は
167 http://www.kernel.org/doc/man\-pages/ に書かれている。