1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" This manpage is Copyright (C) 1992 Drew Eckhardt;
4 .\" 1993 Michael Haardt, Ian Jackson.
5 .\" and Copyright (C) 2007 Michael Kerrisk <mtk.manpages@gmail.com>
7 .\" Permission is granted to make and distribute verbatim copies of this
8 .\" manual provided the copyright notice and this permission notice are
9 .\" preserved on all copies.
11 .\" Permission is granted to copy and distribute modified versions of this
12 .\" manual under the conditions for verbatim copying, provided that the
13 .\" entire resulting derived work is distributed under the terms of a
14 .\" permission notice identical to this one.
16 .\" Since the Linux kernel and libraries are constantly changing, this
17 .\" manual page may be incorrect or out-of-date. The author(s) assume no
18 .\" responsibility for errors or omissions, or for damages resulting from
19 .\" the use of the information contained herein. The author(s) may not
20 .\" have taken the same level of care in the production of this manual,
21 .\" which is licensed free of charge, as they might when working
24 .\" Formatted or processed versions of this manual, if unaccompanied by
25 .\" the source, must acknowledge the copyright and authors of this work.
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.
43 .\" Japanese Version Copyright (c) 1997-1998 HANATAKA Shinya
44 .\" all rights reserved.
45 .\" Translated 1997-12-17, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
46 .\" Modified 1998-05-11, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
47 .\" Updated 2001-12-14, Kentaro Shirakata <argrath@ub32.org>
48 .\" Updated 2002-06-17, Kentaro Shirakata <argrath@ub32.org>
49 .\" Updated 2005-02-23, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
50 .\" Updated 2007-05-01, Akihiro MOTOKI, LDP v2.46
51 .\" Updated 2007-09-04, Akihiro MOTOKI, LDP v2.64
53 .\"WORD: permission アクセス権
54 .\"WORD: privileges 権限
56 .\"WORD: file system ファイル・システム
57 .\"WORD: object オブジェクト
58 .\"WORD: symbolic link シンボリック・リンク
62 .\"WORD: effective user-ID 実効ユーザーID
63 .\"WORD: real user-ID 実ユーザーID
66 .\"WORD: directory ディレクトリ
70 .\"WORD: dangling 参照先のない
72 .TH ACCESS 2 2007-07-10 "Linux" "Linux Programmer's Manual"
75 .\"O access \- check real user's permissions for a file
76 access \- ファイルに対する実ユーザーでのアクセス権をチェックする
80 .B #include <unistd.h>
82 .BI "int access(const char *" pathname ", int " mode );
87 .\"O checks whether the calling process can access the file
91 .\"O is a symbolic link, it is dereferenced.
97 がシンボリック・リンクの場合、シンボリック・リンクは展開される。
101 .\"O specifies the accessibility check(s) to be performed,
102 .\"O and is either the value
104 .\" F_OK is defined as 0 on every system that I know of.
105 .\"O or a mask consisting of the bitwise OR of one or more of
106 .\"O .BR R_OK ", " W_OK ", and " X_OK .
108 はチェックを行うアクセス権を指定するもので、その値は
110 .\" 私が知っているすべてのシステムで F_OK は 0 に定義されている。
112 .BR R_OK ", " W_OK ", " X_OK
113 の 1個以上のビット単位の論理和から構成されるマスクである。
115 .\"O tests for the existence of the file.
116 .\"O .BR R_OK ", " W_OK ", and " X_OK
117 .\"O test whether the file exists and grants read, write, and
118 .\"O execute permissions, respectively.
120 はファイルが存在するかどうかのみを検査する。
121 .BR R_OK ", " W_OK ", " X_OK
122 は、ファイルが存在して、それぞれ読み込み、書き込み、実行の許可があるか
125 .\"O The check is done using the calling process's
127 .\"O UID and GID, rather than the effective IDs as is done when
128 .\"O actually attempting an operation (e.g.,
131 .\"O This allows set-user-ID programs to
132 .\"O easily determine the invoking user's authority.
133 チェックは、実際に操作が行われる際に使用される実効 (effective) ID でなく、
139 これにより、set-user-ID プログラムで、プログラムを起動するユーザの権限を
142 .\"O If the calling process is privileged (i.e., its real UID is zero),
145 .\"O check is successful for a regular file if execute permission
146 .\"O is enabled for any of the file owner, group, or other.
147 呼び出し元プロセスが特権プロセス (つまり、プロセスの実 UID が 0) の場合、
150 のチェックは、そのファイルの所有者、グループ、他人のいずれかの
152 .\"O .SH "RETURN VALUE"
154 .\"O On success (all requested permissions granted), zero is returned.
155 .\"O On error (at least one bit in
157 .\"O asked for a permission that is denied, or some other error occurred),
158 .\"O \-1 is returned, and
160 .\"O is set appropriately.
161 成功した場合(全ての要求された許可が得られたら)、ゼロが返される。
164 で要求された許可がなかった場合や、他のエラーが起きた場合)、
176 .\"O The requested access would be denied to the file, or search permission
177 .\"O is denied for one of the directories in the path prefix of
180 .\"O .BR path_resolution (7).)
184 へ至るまでディレクトリのいずれかに対する検索許可
185 (search permission) が得られなかった。
186 .RB ( path_resolution (7)
190 .\"O Too many symbolic links were encountered in resolving
193 を解決する際に遭遇したシンボリック・リンクが多過ぎる。
204 .\"O does not exist or is a dangling symbolic link.
206 を構成するパスのいずれかが、存在しないか、
207 参照先のない (dangling) シンボリックリンクになっている。
210 .\"O A component used as a directory in
212 .\"O is not, in fact, a directory.
214 のディレクトリ部分が、実際にはディレクトリでない。
217 .\"O Write permission was requested for a file on a read-only file system.
218 読み込み専用 (read-only) のファイル・システムに対して書き込み許可を
228 .\"O points outside your accessible address space.
230 がアクセス可能なアドレス空間の外を指している。
234 .\"O was incorrectly specified.
239 .\"O An I/O error occurred.
243 .\"O Insufficient kernel memory was available.
247 .\"O Write access was requested to an executable which is being
249 実行中のファイルに対して書き込みを要求した。
250 .\"O .SH "CONFORMING TO"
252 SVr4, 4.3BSD, POSIX.1-2001.
259 .\"O to check if a user is authorized to, for example,
260 .\"O open a file before actually doing so using
262 .\"O creates a security hole, because the user might exploit the short time
263 .\"O interval between checking and opening the file to manipulate it.
267 によるアクセスが可能かどうかを、(実際に行う前に)
269 を使ってチェックするのは、セキュリティホールの原因になる。
271 実際にファイルのオープン操作をする間の短い間隔を悪用できるからである。
272 .\"O .BR "For this reason, the use of this system call should be avoided" .
273 .BR この理由があるので、このシステムコールを使うのは避けるべきである。
276 .\"O returns an error if any of the access types in
278 .\"O is denied, even if some of the other access types in
282 で指定されたアクセス種別のいずれか一つでも拒否されると、
285 で指定された他のアクセス種別が許可されたとしても、
289 .\"O If the calling process has appropriate privileges (i.e., is superuser),
290 .\"O POSIX.1-2001 permits implementation to indicate success for an
292 .\"O check even if none of the execute file permission bits are set.
293 .\"O .\" HPU-UX 11 and Tru64 5.1 do this.
294 .\"O Linux does not do this.
296 呼び出し元プロセスが適切な特権を持っている場合
298 たとえファイルの実行許可ビットが全くセットされていなくても
300 のチェックとして成功を返す実装が認められている。
301 .\" HPU-UX 11 と Tru64 5.1 はこのようになっている。
304 .\"O A file is only accessible if the permissions on each of the
305 .\"O directories in the path prefix of
307 .\"O grant search (i.e., execute) access.
308 .\"O If any directory is inaccessible, then the
310 .\"O call will fail, regardless of the permissions on the file itself.
312 のプレフィックスを構成するディレクトリの全てに対して
313 検索アクセス (すなわち、実行アクセス) が許可された場合にのみ、
315 いずれかのディレクトリがアクセス不可の場合、
320 .\"O Only access bits are checked, not the file type or contents.
321 .\"O Therefore, if a directory is found to be writable,
322 .\"O it probably means that files can be created in the directory,
323 .\"O and not that the directory can be written as a file.
324 .\"O Similarly, a DOS file may be found to be "executable," but the
326 .\"O call will still fail.
327 アクセス・ビットのみがチェックされ、ファイルの種類や内容はチェックされない。
328 従って、ディレクトリが書き込み可能となった場合は、ディレクトリに
329 ファイルを作成することが可能なことを意味するのであり、ディレクトリに
330 ファイルとして書き込むことができるわけではない。
331 同様に DOS のファイルは「実行可能」と判断されるが、
336 .\"O may not work correctly on NFS file systems with UID mapping enabled,
337 .\"O because UID mapping is done on the server and hidden from the client,
338 .\"O which checks permissions.
340 は、 UID マッピングを使用した NFS ファイル・システムでは正常に
341 機能しないかもしれない。なぜならば UID のマッピングはサーバーで
342 行なわれ、権利のチェックをするクライアントには見えないからである。
345 .\"O In kernel 2.4 (and earlier) there is some strangeness in the handling of
347 .\"O tests for superuser.
348 .\"O If all categories of execute permission are disabled
349 .\"O for a nondirectory file, then the only
351 .\"O test that returns \-1 is when
353 .\"O is specified as just
359 .\"O is also specified in
363 .\"O returns 0 for such files.
364 .\"O .\" This behavior appears to have been an implementation accident.
365 .\"O Early 2.6 kernels (up to and including 2.6.3)
366 .\"O also behaved in the same way as kernel 2.4.
367 バージョン 2.4 (とそれ以前) のカーネルには、スーパーユーザでの
371 (ユーザ、グループ、他人の) 全てのカテゴリについて
387 .\" この挙動は実装時の事故だったようである。
388 (バージョン 2.6.3 以前の) 初期の 2.6 系のカーネルも
391 .\"O In kernels before 2.6.20,
393 .\"O ignored the effect of the
395 .\"O flag if it was used to
397 .\"O the underlying file system.
398 .\"O Since kernel 2.6.20,
400 .\"O honors this flag.
423 .BR path_resolution (7)