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. All advertising materials mentioning features or use of this software
13 .\" must display the following acknowledgement:
14 .\" This product includes software developed by the University of
15 .\" California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" @(#)access.2 8.2 (Berkeley) 4/1/94
33 .\" $FreeBSD: src/lib/libc/sys/access.2,v 1.7.2.5 2002/10/12 22:02:53 rwatson Exp $
34 .\" $DragonFly: src/lib/libc/sys/access.2,v 1.2 2003/06/17 04:26:47 dillon Exp $
42 .Nd check access permissions of a file or pathname
48 .Fn access "const char *path" "int mode"
50 .Fn faccessat "int fd" "const char *path" "int mode" "int flags"
54 function checks the accessibility of the
57 for the access permissions indicated by
61 is the bitwise inclusive OR of the access permissions to be
66 for write permission and
68 for execute/search permission) or the existence test,
70 All components of the pathname
72 are checked for access permissions (including
75 The real user ID is used in place of the effective user ID
76 and the real group access list
77 (including the real group ID) are
78 used in place of the effective ID for verifying permission.
80 Even if a process has appropriate privileges and indicates success for
82 the file may not actually have execute permission bits set.
93 function but uses either the effective and group IDs or real ones depending on
99 are constructed by a bitwise-inclusive OR of flags from the following list,
102 .Bl -tag -width indent
104 Use effective user and group IDs.
109 specifies a relative path the file to access is determined relative to the
110 directory associated with the file descriptor
112 instead of the current working directory.
117 the current working directory is used and the behavior is identical to a call to
122 cannot be found or if any of the desired access modes would
123 not be granted, then a -1 value is returned; otherwise
124 a 0 value is returned.
130 functions can fail with:
133 A component of the path prefix is not a directory.
134 .It Bq Er ENAMETOOLONG
135 A component of a pathname exceeded 255 characters,
136 or an entire path name exceeded 1023 characters.
138 The named file does not exist.
140 Too many symbolic links were encountered in translating the pathname.
142 Write access is requested for a file on a read-only file system.
144 Write access is requested for a pure procedure (shared text)
145 file presently being executed.
147 Permission bits of the file mode do not permit the requested
148 access, or search permission is denied on a component of the
149 path prefix. The owner of a file has permission checked with
150 respect to the ``owner'' read, write, and execute mode bits,
151 members of the file's group other than the owner have permission
152 checked with respect to the ``group'' mode bits, and all
153 others have permissions checked with respect to the ``other''
157 points outside the process's allocated address space.
159 An I/O error occurred while reading from or writing to the file system.
164 function can fail with:
168 is not a valid file descriptor.
173 does not point to a directory.
176 contains unsupported flags.
184 function call is expected to conform to
189 function call is expected to conform to
193 is a potential security hole due to race conditions and
194 should never be used.
195 Setuid and setgid applications should either use the
197 function or restore the effective uid or gid
198 and perform actions directly rather than use
200 to simulate access checks for the real user of group id.
204 function call appeared in
209 system call appeared in