1 .\" $NetBSD: puffs_cred.3,v 1.5 2009/04/11 15:36:22 joerg Exp $
3 .\" Copyright (c) 2007 Antti Kantee. All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 .Nd puffs credential and access control routines
37 .Fn puffs_cred_getuid "const struct puffs_cred *pcr" "uid_t *uid"
39 .Fn puffs_cred_getgid "const struct puffs_cred *pcr" "gid_t *gid"
41 .Fo puffs_cred_getgroups
42 .Fa "const struct puffs_cred *pcr" "gid_t *gids" "short *ngids"
46 .Fn puffs_cred_isuid "const struct puffs_cred *pcr" "uid_t uid"
48 .Fn puffs_cred_hasgroup "const struct puffs_cred *pcr" "gid_t gid"
50 .Fn puffs_cred_iskernel "const struct puffs_cred *pcr"
52 .Fn puffs_cred_isfs "const struct puffs_cred *pcr"
54 .Fn puffs_cred_isjuggernaut "const struct puffs_cred *pcr"
58 .Fa "enum vtype type" "mode_t file_mode" "uid_t owner" "gid_t group"
59 .Fa "mode_t access_mode" "const struct puffs_cred *pcr"
62 .Fo puffs_access_chown
63 .Fa "uid_t owner" "gid_t group" "uid_t newowner" "gid_t newgroup"
64 .Fa "const struct puffs_cred *pcr"
67 .Fo puffs_access_chmod
68 .Fa "uid_t owner" "gid_t group" "enum vtype type" "mode_t newmode"
69 .Fa "const struct puffs_cred *pcr"
72 .Fo puffs_access_times
73 .Fa "uid_t owner" "gid_t group" "mode_t file_mode" "int va_utimes_null"
74 .Fa "const struct puffs_cred *pcr"
77 These functions can be used to check operation credentials and perform
81 can contain two types of credentials: ones belonging to users and
82 ones belonging to the kernel.
83 The latter is further divided into generic kernel credentials and
84 file system credentials.
85 The general rule is that these should be treated as more powerful
86 than superuser credentials, but the file system is free to treat
91 family of functions fetch the uid or gid(s) from the given credential
93 They return 0 for success or \-1 for an error and set
95 An error happens when the credentials represent kernel or file system
96 credentials and do not contain an uid or gid(s).
99 .Fn puffs_cred_getgroups ,
102 should point to an array with room for
108 family of functions return 1 if the truth value of the function for
110 is true and 0 if it is false.
112 .Fn puffs_cred_isjuggernaut
115 describes superuser, kernel or file system credentials.
117 To help the programmers task of emulating normal kernel file system
118 access control semantics, several helper functions are provided to
119 check if access is allowed.
120 They return 0 if access should be permitted or an errno value to
121 indicate that access should be denied with the returned value.
124 is equivalent to the kernel
127 The arguments specify current information of the file to be
128 tested with the exception of
130 which is a combination of
135 indicating the desired file access mode.
137 The rest of the functions provide UFS semantics for operations.
138 .Fn puffs_access_chown
139 checks if it is permissible to chown a file with the current uid
140 and gid to the new uid and gid with the credentials of
143 .Fn puffs_access_chmod
144 checks against permission to chmod a file of type
150 .Fn puffs_access_times
151 checks if it is allowable to update the timestamps of a file.
160 If coming from a path where this information is unavailable, passing
161 0 as this argument restricts the permission of modification to the
163 Otherwise the function checks for write permissions to the node and
164 returns success if the caller has write permissions.