xref: /netbsd-src/share/man/man9/genfs.9 (revision 946379e7b37692fc43f68eb0d1c10daa0a7f3b6c)
1.\" $NetBSD: genfs.9,v 1.4 2014/03/18 18:20:40 riastradh Exp $
2.\"
3.\" Copyright 2012 Elad Efrat <elad@NetBSD.org>
4.\" 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. The name of the author may not be used to endorse or promote products
15.\"    derived from this software without specific prior written permission.
16.\"
17.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27.\" POSSIBILITY OF SUCH DAMAGE.
28.\"
29.Dd March 1, 2012
30.Dt GENFS 9
31.Os
32.Sh NAME
33.Nm genfs
34.Nd genfs routines
35.Sh SYNOPSIS
36.In miscfs/genfs/genfs.h
37.Ft int
38.Fn genfs_can_access "enum vtype type" "mode_t file_mode" "uid_t uid" \
39"gid_t gid" "mode_t acc_mode" "kauth_cred_t cred"
40.Ft int
41.Fn genfs_can_chflags "kauth_cred_t cred" "enum vtype type" "uid_t owner_uid" \
42"bool changing_sysflags"
43.Ft int
44.Fn genfs_can_chmod "enum vtype type" "kauth_cred_t cred" "uid_t cur_uid" \
45"gid_t cur_gid" "mode_t new_mode"
46.Ft int
47.Fn genfs_can_chown "kauth_cred_t cred" "uid_t cur_uid" "gid_t cur_gid" \
48"uid_t new_uid" "gid_t new_gid"
49.Ft int
50.Fn genfs_can_chtimes "vnode_t *vp" "u_int vaflags" "uid_t owner_uid" \
51"kauth_cred_t cred"
52.Ft int
53.Fn genfs_can_extattr "kauth_cred_t cred" "int access_mode" "vnode_t *vp" \
54"const char *attr"
55.Ft int
56.Fn genfs_can_sticky "kauth_cred_t cred" "uid_t dir_uid" "uid_t file_uid"
57.Sh DESCRIPTION
58The functions documented here are general routines for internal use in
59file systems to implement common policies for performing various operations.
60The developer must understand that these routines implement no system-wide
61policies and only take into account the object being accessed and the
62nominal values of the credentials accessing it.
63.Pp
64In other words, these functions are not meant to be called directly.
65They are intended to be used in
66.Xr kauth 9
67vnode scope authorization calls, for providing the fall-back file system
68decision.
69.Pp
70As a rule of thumb, code that looks like this is wrong:
71.Bd -literal -offset indent
72error = genfs_can_foo(...); /* WRONG */
73.Ed
74.Pp
75While code that looks like this is right:
76.Bd -literal -offset indent
77error = kauth_authorize_vnode(..., genfs_can_foo(...));
78.Ed
79.Sh FUNCTIONS
80.Bl -tag -width compact
81.It Fn genfs_can_access "enum vtype type" "mode_t file_mode" "uid_t uid" \
82"gid_t gid" "mode_t acc_mode" "kauth_cred_t cred"
83Implements file access checking based on traditional Unix permissions.
84.It Fn genfs_can_chflags "kauth_cred_t cred" "enum vtype type" \
85"uid_t owner_uid" "bool changing_sysflags"
86Implements
87.Xr chflags 2
88policy.
89.It Fn genfs_can_chmod "enum vtype type" "kauth_cred_t cred" "uid_t cur_uid" \
90"gid_t cur_gid" "mode_t new_mode"
91Implements
92.Xr chmod 2
93policy.
94.It Fn genfs_can_chown "kauth_cred_t cred" "uid_t cur_uid" "gid_t cur_gid" \
95"uid_t new_uid" "gid_t new_gid"
96Implements
97.Xr chown 2
98policy.
99.It Fn genfs_can_chtimes "vnode_t *vp" "u_int vaflags" "uid_t owner_uid" \
100"kauth_cred_t cred"
101Implements
102.Xr utimes 2
103policy.
104.It Fn genfs_can_extattr "kauth_cred_t cred" "int access_mode" "vnode_t *vp" \
105"const char *attr"
106Implements extended attributes access policy.
107.It Fn genfs_can_sticky "kauth_cred_t cred" "uid_t dir_uid" "uid_t file_uid"
108Implements rename and delete policy from sticky directories.
109.El
110.Sh SEE ALSO
111.Xr kauth 9
112.Sh AUTHORS
113.An Elad Efrat Aq Mt elad@NetBSD.org
114wrote this manual page.
115