Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / lib / libcr / sys / access.2
1 .\" Copyright (c) 1980, 1991, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
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.
19 .\"
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
30 .\" SUCH DAMAGE.
31 .\"
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/libcr/sys/Attic/access.2,v 1.2 2003/06/17 04:26:47 dillon Exp $
35 .\"
36 .Dd April 1, 1994
37 .Dt ACCESS 2
38 .Os
39 .Sh NAME
40 .Nm access
41 .Nd check access permissions of a file or pathname
42 .Sh LIBRARY
43 .Lb libc
44 .Sh SYNOPSIS
45 .In unistd.h
46 .Ft int
47 .Fn access "const char *path" "int mode"
48 .Sh DESCRIPTION
49 The
50 .Fn access
51 function checks the accessibility of the
52 file named by
53 .Fa path
54 for the access permissions indicated by
55 .Fa mode .
56 The value of
57 .Fa mode
58 is the bitwise inclusive OR of the access permissions to be
59 checked
60 .Pf ( Dv R_OK
61 for read permission,
62 .Dv W_OK
63 for write permission and
64 .Dv X_OK
65 for execute/search permission) or the existence test,
66 .Dv F_OK .
67 All components of the pathname
68 .Fa path
69 are checked for access permissions (including
70 .Dv F_OK ) .
71 .Pp
72 The real user ID is used in place of the effective user ID
73 and the real group access list
74 (including the real group ID) are
75 used in place of the effective ID for verifying permission.
76 .Pp
77 Even if a process has appropriate privileges and indicates success for
78 .Dv X_OK ,
79 the file may not actually have execute permission bits set.
80 Likewise for
81 .Dv R_OK
82 and
83 .Dv W_OK .
84 .Sh RETURN VALUES
85 If
86 .Fa path
87 cannot be found or if any of the desired access modes would
88 not be granted, then a -1 value is returned; otherwise
89 a 0 value is returned.
90 .Sh ERRORS
91 Access to the file is denied if:
92 .Bl -tag -width Er
93 .It Bq Er ENOTDIR
94 A component of the path prefix is not a directory.
95 .It Bq Er ENAMETOOLONG
96 A component of a pathname exceeded 255 characters,
97 or an entire path name exceeded 1023 characters.
98 .It Bq Er ENOENT
99 The named file does not exist.
100 .It Bq Er ELOOP
101 Too many symbolic links were encountered in translating the pathname.
102 .It Bq Er EROFS
103 Write access is requested for a file on a read-only file system.
104 .It Bq Er ETXTBSY
105 Write access is requested for a pure procedure (shared text)
106 file presently being executed.
107 .It Bq Er EACCES
108 Permission bits of the file mode do not permit the requested
109 access, or search permission is denied on a component of the
110 path prefix.  The owner of a file has permission checked with
111 respect to the ``owner'' read, write, and execute mode bits,
112 members of the file's group other than the owner have permission
113 checked with respect to the ``group'' mode bits, and all
114 others have permissions checked with respect to the ``other''
115 mode bits.
116 .It Bq Er EFAULT
117 .Fa Path
118 points outside the process's allocated address space.
119 .It Bq Er EIO
120 An I/O error occurred while reading from or writing to the file system.
121 .El
122 .Sh SEE ALSO
123 .Xr chmod 2 ,
124 .Xr stat 2
125 .Sh STANDARDS
126 The
127 .Fn access
128 function call is expected to conform to
129 .St -p1003.1-90 .
130 .Sh CAVEAT
131 .Fn Access
132 is a potential security hole due to race conditions and
133 should never be used.
134 Setuid and setgid applications should restore the effective uid or gid
135 and perform actions directly rather than use
136 .Fn access
137 to simulate access checks for the real user of group id.
138 .Sh HISTORY
139 An
140 .Fn access
141 function call appeared in
142 .At v7 .