Path: blob/main/lib/libcasper/services/cap_grp/cap_grp.h
48261 views
/*-1* Copyright (c) 2013 The FreeBSD Foundation2*3* This software was developed by Pawel Jakub Dawidek under sponsorship from4* the FreeBSD Foundation.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14*15* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND16* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE17* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE18* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE19* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL20* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS21* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)22* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT23* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY24* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF25* SUCH DAMAGE.26*/2728#ifndef _CAP_GRP_H_29#define _CAP_GRP_H_3031#ifdef HAVE_CASPER32#define WITH_CASPER33#endif3435#include <sys/cdefs.h>3637#ifdef WITH_CASPER38__BEGIN_DECLS3940struct group *cap_getgrent(cap_channel_t *chan);41struct group *cap_getgrnam(cap_channel_t *chan, const char *name);42struct group *cap_getgrgid(cap_channel_t *chan, gid_t gid);4344int cap_getgrent_r(cap_channel_t *chan, struct group *grp, char *buffer,45size_t bufsize, struct group **result);46int cap_getgrnam_r(cap_channel_t *chan, const char *name, struct group *grp,47char *buffer, size_t bufsize, struct group **result);48int cap_getgrgid_r(cap_channel_t *chan, gid_t gid, struct group *grp,49char *buffer, size_t bufsize, struct group **result);5051int cap_setgroupent(cap_channel_t *chan, int stayopen);52int cap_setgrent(cap_channel_t *chan);53void cap_endgrent(cap_channel_t *chan);5455int cap_grp_limit_cmds(cap_channel_t *chan, const char * const *cmds,56size_t ncmds);57int cap_grp_limit_fields(cap_channel_t *chan, const char * const *fields,58size_t nfields);59int cap_grp_limit_groups(cap_channel_t *chan, const char * const *names,60size_t nnames, const gid_t *gids, size_t ngids);6162__END_DECLS6364#else65#define cap_getgrent(chan) getgrent()66#define cap_getgrnam(chan, name) getgrnam(name)67#define cap_getgrgid(chan, gid) getgrgid(gid)6869#define cap_setgroupent(chan, stayopen) etgroupent(stayopen)70#define endgrent(chan) endgrent()71static inline int72cap_setgrent(cap_channel_t *chan __unused)73{7475setgrent();76return(0);77}7879#define cap_getgrent_r(chan, grp, buffer, bufsize, result) \80getgrent_r(grp, buffer, bufsize, result)81#define cap_getgrnam_r(chan, name, grp, buffer, bufsize, result) \82getgrnam_r(name, grp, buffer, bufsize, result)83#define cap_getgrgid_r(chan, gid, grp, buffer, bufsize, result) \84getgrgid_r(gid, grp, buffer, bufsize, result)8586#define cap_grp_limit_cmds(chan, cmds, ncmds) (0)87#define cap_grp_limit_fields(chan, fields, nfields) (0)88#define cap_grp_limit_groups(chan, names, nnames, gids, ngids) (0)8990#endif9192#endif /* !_CAP_GRP_H_ */939495