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"
74 access \- ファイルに対する実ユーザーでのアクセス権をチェックする
77 .B #include <unistd.h>
79 .BI "int access(const char *" pathname ", int " mode );
87 がシンボリック・リンクの場合、シンボリック・リンクは展開される。
89 .\" F_OK is defined as 0 on every system that I know of.
91 はチェックを行うアクセス権を指定するもので、その値は
93 .\" 私が知っているすべてのシステムで F_OK は 0 に定義されている。
95 .BR R_OK ", " W_OK ", " X_OK
96 の 1個以上のビット単位の論理和から構成されるマスクである。
98 はファイルが存在するかどうかのみを検査する。
99 .BR R_OK ", " W_OK ", " X_OK
100 は、ファイルが存在して、それぞれ読み込み、書き込み、実行の許可があるか
103 チェックは、実際に操作が行われる際に使用される実効 (effective) ID でなく、
109 これにより、set-user-ID プログラムで、プログラムを起動するユーザの権限を
112 呼び出し元プロセスが特権プロセス (つまり、プロセスの実 UID が 0) の場合、
115 のチェックは、そのファイルの所有者、グループ、他人のいずれかの
118 成功した場合(全ての要求された許可が得られたら)、ゼロが返される。
121 で要求された許可がなかった場合や、他のエラーが起きた場合)、
133 へ至るまでディレクトリのいずれかに対する検索許可
134 (search permission) が得られなかった。
135 .RB ( path_resolution (7)
140 を解決する際に遭遇したシンボリック・リンクが多過ぎる。
148 を構成するパスのいずれかが、存在しないか、
149 参照先のない (dangling) シンボリックリンクになっている。
153 のディレクトリ部分が、実際にはディレクトリでない。
156 読み込み専用 (read-only) のファイル・システムに対して書き込み許可を
164 がアクセス可能なアドレス空間の外を指している。
177 実行中のファイルに対して書き込みを要求した。
179 SVr4, 4.3BSD, POSIX.1-2001.
185 によるアクセスが可能かどうかを、(実際に行う前に)
187 を使ってチェックするのは、セキュリティホールの原因になる。
189 実際にファイルのオープン操作をする間の短い間隔を悪用できるからである。
190 .BR この理由があるので、このシステムコールを使うのは避けるべきである。
193 で指定されたアクセス種別のいずれか一つでも拒否されると、
196 で指定された他のアクセス種別が許可されたとしても、
201 呼び出し元プロセスが適切な特権を持っている場合
203 たとえファイルの実行許可ビットが全くセットされていなくても
205 のチェックとして成功を返す実装が認められている。
206 .\" HPU-UX 11 と Tru64 5.1 はこのようになっている。
210 のプレフィックスを構成するディレクトリの全てに対して
211 検索アクセス (すなわち、実行アクセス) が許可された場合にのみ、
213 いずれかのディレクトリがアクセス不可の場合、
218 アクセス・ビットのみがチェックされ、ファイルの種類や内容はチェックされない。
219 従って、ディレクトリが書き込み可能となった場合は、ディレクトリに
220 ファイルを作成することが可能なことを意味するのであり、ディレクトリに
221 ファイルとして書き込むことができるわけではない。
222 同様に DOS のファイルは「実行可能」と判断されるが、
227 は、 UID マッピングを使用した NFS ファイル・システムでは正常に
228 機能しないかもしれない。なぜならば UID のマッピングはサーバーで
229 行なわれ、権利のチェックをするクライアントには見えないからである。
231 バージョン 2.4 (とそれ以前) のカーネルには、スーパーユーザでの
235 (ユーザ、グループ、他人の) 全てのカテゴリについて
251 .\" この挙動は実装時の事故だったようである。
252 (バージョン 2.6.3 以前の) 初期の 2.6 系のカーネルも
276 .BR path_resolution (7)