- NetBSD Manual Pages
PUFFS_CRED(3) NetBSD Library Functions Manual PUFFS_CRED(3)
Powered by man-cgi (2021-06-01).
Maintained for NetBSD
by Kimmo Suominen.
Based on man-cgi by Panagiotis Christias.
puffs_cred -- puffs credential and access control routines
puffs Convenience Library (libpuffs, -lpuffs)
puffs_cred_getuid(const struct puffs_cred *pcr, uid_t *uid);
puffs_cred_getgid(const struct puffs_cred *pcr, gid_t *gid);
puffs_cred_getgroups(const struct puffs_cred *pcr, gid_t *gids,
puffs_cred_isuid(const struct puffs_cred *pcr, uid_t uid);
puffs_cred_hasgroup(const struct puffs_cred *pcr, gid_t gid);
puffs_cred_iskernel(const struct puffs_cred *pcr);
puffs_cred_isfs(const struct puffs_cred *pcr);
puffs_cred_isjuggernaut(const struct puffs_cred *pcr);
puffs_access(enum vtype type, mode_t file_mode, uid_t owner, gid_t group,
mode_t access_mode, const struct puffs_cred *pcr);
puffs_access_chown(uid_t owner, gid_t group, uid_t newowner,
gid_t newgroup, const struct puffs_cred *pcr);
puffs_access_chmod(uid_t owner, gid_t group, enum vtype type,
mode_t newmode, const struct puffs_cred *pcr);
puffs_access_times(uid_t owner, gid_t group, mode_t file_mode,
int va_utimes_null, const struct puffs_cred *pcr);
These functions can be used to check operation credentials and perform
access control. The structure struct puffs_cred can contain two types of
credentials: ones belonging to users and ones belonging to the kernel.
The latter is further divided into generic kernel credentials and file
system credentials. The general rule is that these should be treated as
more powerful than superuser credentials, but the file system is free to
treat them as it sees fit.
The puffs_cred_get() family of functions fetch the uid or gid(s) from the
given credential cookie. They return 0 for success or -1 for an error
and set errno. An error happens when the credentials represent kernel or
file system credentials and do not contain an uid or gid(s).
For puffs_cred_getgroups(), the argument gids should point to an array
with room for *ngids elements.
The puffs_cred_is() family of functions return 1 if the truth value of
the function for pcr is true and 0 if it is false. The function
puffs_cred_isjuggernaut() is true if pcr describes superuser, kernel or
file system credentials.
To help the programmers task of emulating normal kernel file system
access control semantics, several helper functions are provided to check
if access is allowed. They return 0 if access should be permitted or an
errno value to indicate that access should be denied with the returned
puffs_access() is equivalent to the kernel vaccess() function. The argu-
ments specify current information of the file to be tested with the
exception of access_mode, which is a combination of PUFFS_VREAD,
PUFFS_VWRITE and PUFFS_VEXEC indicating the desired file access mode.
The rest of the functions provide UFS semantics for operations.
puffs_access_chown() checks if it is permissible to chown a file with the
current uid and gid to the new uid and gid with the credentials of pcr.
puffs_access_chmod() checks against permission to chmod a file of type
type to the mode newmode.
Finally, puffs_access_times() checks if it is allowable to update the
timestamps of a file. The argument va_utimes_null signals if the flags
VA_UTIMES_NULL was set in va_vaflags of struct vattr. If coming from a
path where this information is unavailable, passing 0 as this argument
restricts the permission of modification to the owner and superuser.
Otherwise the function checks for write permissions to the node and
returns success if the caller has write permissions.
NetBSD 9.3 October 18, 2007 NetBSD 9.3