]>
Commit | Line | Data |
---|---|---|
9bccf70c A |
1 | .\" $NetBSD: access.2,v 1.7 1995/02/27 12:31:44 cgd Exp $ |
2 | .\" | |
3 | .\" Copyright (c) 1980, 1991, 1993 | |
4 | .\" The Regents of the University of California. All rights reserved. | |
5 | .\" | |
6 | .\" Redistribution and use in source and binary forms, with or without | |
7 | .\" modification, are permitted provided that the following conditions | |
8 | .\" are met: | |
9 | .\" 1. Redistributions of source code must retain the above copyright | |
10 | .\" notice, this list of conditions and the following disclaimer. | |
11 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
12 | .\" notice, this list of conditions and the following disclaimer in the | |
13 | .\" documentation and/or other materials provided with the distribution. | |
14 | .\" 3. All advertising materials mentioning features or use of this software | |
15 | .\" must display the following acknowledgement: | |
16 | .\" This product includes software developed by the University of | |
17 | .\" California, Berkeley and its contributors. | |
18 | .\" 4. Neither the name of the University nor the names of its contributors | |
19 | .\" may be used to endorse or promote products derived from this software | |
20 | .\" without specific prior written permission. | |
21 | .\" | |
22 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
23 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
24 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
25 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
26 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
27 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
28 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
29 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
30 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
31 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
32 | .\" SUCH DAMAGE. | |
33 | .\" | |
34 | .\" @(#)access.2 8.2 (Berkeley) 4/1/94 | |
35 | .\" | |
36 | .Dd April 1, 1994 | |
37 | .Dt ACCESS 2 | |
38 | .Os BSD 4 | |
39 | .Sh NAME | |
40 | .Nm access | |
41 | .Nd check access permissions of a file or pathname | |
42 | .Sh SYNOPSIS | |
43 | .Fd #include <unistd.h> | |
44 | .Ft int | |
2d21ac55 A |
45 | .Fo access |
46 | .Fa "const char *path" | |
47 | .Fa "int amode" | |
48 | .Fc | |
9bccf70c A |
49 | .Sh DESCRIPTION |
50 | The | |
51 | .Fn access | |
52 | function checks the accessibility of the | |
53 | file named by | |
54 | .Fa path | |
55 | for the access permissions indicated by | |
2d21ac55 | 56 | .Fa amode . |
9bccf70c | 57 | The value of |
2d21ac55 | 58 | .Fa amode |
9bccf70c A |
59 | is the bitwise inclusive OR of the access permissions to be |
60 | checked | |
61 | .Pf ( Dv R_OK | |
62 | for read permission, | |
63 | .Dv W_OK | |
64 | for write permission and | |
65 | .Dv X_OK | |
66 | for execute/search permission) or the existence test, | |
67 | .Dv F_OK . | |
68 | All components of the pathname | |
69 | .Fa path | |
70 | are checked for access permissions (including | |
71 | .Dv F_OK ) . | |
72 | .Pp | |
73 | The real user ID is used in place of the effective user ID | |
74 | and the real group access list | |
75 | (including the real group ID) are | |
76 | used in place of the effective ID for verifying permission. | |
77 | .Pp | |
78 | Even if a process has appropriate privileges and indicates success for | |
79 | .Dv X_OK , | |
80 | the file may not actually have execute permission bits set. | |
81 | Likewise for | |
82 | .Dv R_OK | |
83 | and | |
84 | .Dv W_OK . | |
85 | .Sh RETURN VALUES | |
86 | If | |
87 | .Fa path | |
2d21ac55 A |
88 | cannot be found |
89 | or if any of the desired access modes would not be granted, | |
90 | then a -1 value is returned and the global integer variable | |
91 | .Va errno | |
92 | is set to indicate the error. | |
93 | Otherwise, a 0 value is returned. | |
9bccf70c A |
94 | .Sh ERRORS |
95 | Access to the file is denied if: | |
96 | .Bl -tag -width Er | |
2d21ac55 A |
97 | .\" ========== |
98 | .It Bq Er EACCES | |
99 | Permission bits of the file mode do not permit the requested access, | |
100 | or search permission is denied on a component of the path prefix. | |
101 | .Pp | |
102 | The owner of a file has permission checked | |
103 | with respect to the ``owner'' read, write, and execute mode bits, | |
104 | members of the file's group other than the owner have permission checked | |
105 | with respect to the ``group'' mode bits, | |
106 | and all others have permissions checked | |
107 | with respect to the ``other'' mode bits. | |
108 | .\" | |
109 | .\" ========== | |
110 | .It Bq Er EFAULT | |
111 | .Fa Path | |
112 | points outside the process's allocated address space. | |
113 | .It Bq Er EINVAL | |
114 | An invalid value was specified for | |
115 | .Ar amode . | |
116 | .\" ========== | |
117 | .It Bq Er EIO | |
118 | An I/O error occurred while reading from or writing to the file system. | |
119 | .\" ========== | |
120 | .It Bq Er ELOOP | |
121 | Too many symbolic links were encountered in translating the pathname. | |
122 | .\" ========== | |
9bccf70c A |
123 | .It Bq Er ENAMETOOLONG |
124 | A component of a pathname exceeded | |
125 | .Dv {NAME_MAX} | |
126 | characters, or an entire path name exceeded | |
127 | .Dv {PATH_MAX} | |
128 | characters. | |
2d21ac55 | 129 | .\" ========== |
9bccf70c A |
130 | .It Bq Er ENOENT |
131 | The named file does not exist. | |
2d21ac55 A |
132 | .\" ========== |
133 | .It Bq Er ENOTDIR | |
134 | A component of the path prefix is not a directory. | |
135 | .\" ========== | |
9bccf70c A |
136 | .It Bq Er EROFS |
137 | Write access is requested for a file on a read-only file system. | |
2d21ac55 | 138 | .\" ========== |
9bccf70c A |
139 | .It Bq Er ETXTBSY |
140 | Write access is requested for a pure procedure (shared text) | |
2d21ac55 | 141 | file that is presently being executed. |
9bccf70c A |
142 | .El |
143 | .Sh SEE ALSO | |
144 | .Xr chmod 2 , | |
145 | .Xr stat 2 | |
146 | .Sh STANDARDS | |
147 | The | |
148 | .Fn access | |
149 | function conforms to | |
150 | .St -p1003.1-90 . | |
151 | .Sh CAVEAT | |
152 | .Fn Access | |
153 | is a potential security hole and | |
154 | should never be used. |