4 .\" Copyright (c) 1996 Doug Rabson
6 .\" All rights reserved.
8 .\" This program is free software.
10 .\" Redistribution and use in source and binary forms, with or without
11 .\" modification, are permitted provided that the following conditions
13 .\" 1. Redistributions of source code must retain the above copyright
14 .\" notice, this list of conditions and the following disclaimer.
15 .\" 2. Redistributions in binary form must reproduce the above copyright
16 .\" notice, this list of conditions and the following disclaimer in the
17 .\" documentation and/or other materials provided with the distribution.
19 .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
20 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 .Nd "check access permissions of a file or Unix domain socket"
42 .Fn VOP_ACCESS "struct vnode *vp" "int mode" "struct ucred *cred" "struct thread *td"
44 This entry point checks the access permissions of the file against the
50 The vnode of the file to check.
52 The type of access required.
54 The user credentials to check.
56 The thread which is checking.
61 is a mask which can contain
67 The vnode will be locked on entry and should remain locked on return.
69 If the file is accessible in the specified way, then zero is returned,
70 otherwise an appropriate error code is returned.
74 vop_access(struct vnode *vp, int mode, struct ucred *cred, struct thread *td)
79 * Disallow write attempts on read-only file systems;
80 * unless the file is a socket, fifo, or a block or
81 * character device resident on the filesystem.
88 if (vp->v_mount->mnt_flag & MNT_RDONLY)
95 /* If immutable bit set, nobody gets to write it. */
96 if ((mode & VWRITE) && vp has immutable bit set)
99 /* Otherwise, user id 0 always gets access. */
100 if (cred->cr_uid == 0)
105 /* Otherwise, check the owner. */
106 if (cred->cr_uid == owner of vp) {
113 return (((mode of vp) & mask) == mask ? 0 : EACCES);
116 /* Otherwise, check the groups. */
117 for (i = 0, gp = cred->cr_groups; i < cred->cr_ngroups; i++, gp++)
118 if (group of vp == *gp) {
125 return (((mode of vp) & mask) == mask ? 0 : EACCES);
128 /* Otherwise, check everyone else. */
135 return (((mode of vp) & mask) == mask ? 0 : EACCES);
141 An attempt was made to change an immutable file.
143 The permission bits the file mode or the ACL do not permit the
148 .Xr vaccess_acl_posix1e 9 ,
151 This manual page was written by