1.\" $NetBSD: genfs.9,v 1.6 2020/08/07 20:17:59 wiz 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 August 7, 2020 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 "vnode_t *vp" "kauth_cred_t cred" "uid_t uid" \ 39"gid_t gid" "mode_t file_mode" "struct acl *acl" "accmode_t accmode" 40.Ft int 41.Fn genfs_can_chflags "vnode_t *vp" kauth_cred_t cred" "uid_t owner_uid" \ 42"bool changing_sysflags" 43.Ft int 44.Fn genfs_can_chmod "vnode_t *vp" "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 "vnode_t *vp" "kauth_cred_t cred" "uid_t cur_uid" \ 48 "gid_t cur_gid" "uid_t new_uid" "gid_t new_gid" 49.Ft int 50.Fn genfs_can_chtimes "vnode_t *vp" "kauth_cred_t cred" "uid_t owner_uid" \ 51"u_int vaflags" 52.Ft int 53.Fn genfs_can_extattr "vnode_t *vp" "kauth_cred_t cred" "accmode_t accmode" \ 54"int attrnamespace" 55.Ft int 56.Fn genfs_can_sticky "vnode_t *vp" "kauth_cred_t cred" "uid_t dir_uid" \ 57 "uid_t file_uid" 58.Sh DESCRIPTION 59The functions documented here are general routines for internal use in 60file systems to implement common policies for performing various operations. 61The developer must understand that these routines implement no system-wide 62policies and only take into account the object being accessed and the 63nominal values of the credentials accessing it. 64.Pp 65In other words, these functions are not meant to be called directly. 66They are intended to be used in 67.Xr kauth 9 68vnode scope authorization calls, for providing the fall-back file system 69decision. 70.Pp 71As a rule of thumb, code that looks like this is wrong: 72.Bd -literal -offset indent 73error = genfs_can_foo(...); /* WRONG */ 74.Ed 75.Pp 76While code that looks like this is right: 77.Bd -literal -offset indent 78error = kauth_authorize_vnode(..., genfs_can_foo(...)); 79.Ed 80.Sh FUNCTIONS 81.Bl -tag -width compact 82.It Fn genfs_can_access "vnode_t *vp" "kauth_cred_t cred" "uid_t uid" \ 83"gid_t gid" "mode_t file_mode" "struct acl *" "accmode_t accmode" 84Implements file access checking based on traditional Unix permissions. 85.It Fn genfs_can_chflags "vnode_t *vp" "kauth_cred_t cred" 86"uid_t owner_uid" "bool changing_sysflags" 87Implements 88.Xr chflags 2 89policy. 90.It Fn genfs_can_chmod "vnode_t *vp" "kauth_cred_t cred" "uid_t cur_uid" \ 91"gid_t cur_gid" "mode_t new_mode" 92Implements 93.Xr chmod 2 94policy. 95.It Fn genfs_can_chown "vnode_t *vp" "kauth_cred_t cred" "uid_t cur_uid" \ 96"gid_t cur_gid" "uid_t new_uid" "gid_t new_gid" 97Implements 98.Xr chown 2 99policy. 100.It Fn genfs_can_chtimes "vnode_t *vp" "kauth_cred_t cred" "uid_t owner_uid" \ 101"u_int vaflags" 102Implements 103.Xr utimes 2 104policy. 105.It Fn genfs_can_extattr "vnode_t *vp" "kauth_cred_t cred" "accmode_t accmode" \ 106"int attrnamespace" 107Implements extended attributes access policy. 108.It Fn genfs_can_sticky "vnode_t *vp" "kauth_cred_t cred" "uid_t dir_uid" \ 109"uid_t file_uid" 110Implements rename and delete policy from sticky directories. 111.El 112.Sh SEE ALSO 113.Xr kauth 9 114.Sh AUTHORS 115.An Elad Efrat Aq Mt elad@NetBSD.org 116wrote this manual page. 117