1 .\" Copyright (c) 1980, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the University nor the names of its contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" @(#)access.2 8.2 (Berkeley) 4/1/94
38 .Nd check accessibility of a file
44 .Fn access "const char *path" "int mode"
46 .Fn eaccess "const char *path" "int mode"
48 .Fn faccessat "int fd" "const char *path" "int mode" "int flag"
54 system calls check the accessibility of the
59 for the access permissions indicated by
65 is either the bitwise-inclusive OR of the access permissions to be
70 for write permission, and
72 for execute/search permission),
76 For additional information, see the
77 .Sx "File Access Permission"
84 the effective user ID and the group access list
85 to authorize the request;
89 the real user ID in place of the effective user ID,
90 the real group ID in place of the effective group ID,
91 and the rest of the group access list.
95 system call is equivalent to
97 except in the case where
99 specifies a relative path.
100 In this case the file whose accessibility is to be determined is
101 located relative to the directory associated with the file descriptor
103 instead of the current working directory.
106 is passed the special value
110 parameter, the current working directory is used and the behavior is
111 identical to a call to
115 are constructed by a bitwise-inclusive OR of flags from the following
118 .Bl -tag -width indent
120 The checks for accessibility are performed using the effective user and group
121 IDs instead of the real user and group ID as required in a call to
124 Only operate on files and directories below the starting directory.
127 Even if a process's real or effective user has appropriate privileges
128 and indicates success for
130 the file may not actually have execute permission bits set.
149 A component of the path prefix is not a directory.
150 .It Bq Er ENAMETOOLONG
151 A component of a pathname exceeded 255 characters,
152 or an entire path name exceeded 1023 characters.
154 The named file does not exist.
156 Too many symbolic links were encountered in translating the pathname.
158 Write access is requested for a file on a read-only file system.
160 Write access is requested for a pure procedure (shared text)
161 file presently being executed.
163 Permission bits of the file mode do not permit the requested
164 access, or search permission is denied on a component of the
170 points outside the process's allocated address space.
172 An I/O error occurred while reading from or writing to the file system.
177 system call may fail if:
182 argument does not specify an absolute path and the
187 nor a valid file descriptor.
191 argument is not valid.
195 argument is not an absolute path and
199 nor a file descriptor associated with a directory.
200 .It Bq Er ENOTCAPABLE
203 flag was specified but
205 is not strictly relative to the starting directory.
208 is absolute or includes a ".." component that escapes the starting directory.
217 system call is expected to conform to
221 system call follows The Open Group Extended API Set 2 specification.
229 system call appeared in
231 .Sh SECURITY CONSIDERATIONS
235 is a potential security hole due to race conditions and
236 should never be used.
237 Set-user-ID and set-group-ID applications should restore the
238 effective user or group ID,
239 and perform actions directly rather than use
241 to simulate access checks for the real user or group ID.
245 likewise may be subject to races if used inappropriately.
248 remains useful for providing clues to users as to whether operations
249 make sense for particular filesystem objects (e.g. 'delete' menu
250 item only highlighted in a writable folder ... avoiding interpretation
251 of the st_mode bits that the application might not understand --
252 e.g. in the case of AFS).
253 It also allows a cheaper file existence test than