Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/lib/libcasper/services/cap_grp/cap_grp.h
48261 views
1
/*-
2
* Copyright (c) 2013 The FreeBSD Foundation
3
*
4
* This software was developed by Pawel Jakub Dawidek under sponsorship from
5
* the FreeBSD Foundation.
6
*
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions
9
* are met:
10
* 1. Redistributions of source code must retain the above copyright
11
* notice, this list of conditions and the following disclaimer.
12
* 2. Redistributions in binary form must reproduce the above copyright
13
* notice, this list of conditions and the following disclaimer in the
14
* documentation and/or other materials provided with the distribution.
15
*
16
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
17
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
20
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26
* SUCH DAMAGE.
27
*/
28
29
#ifndef _CAP_GRP_H_
30
#define _CAP_GRP_H_
31
32
#ifdef HAVE_CASPER
33
#define WITH_CASPER
34
#endif
35
36
#include <sys/cdefs.h>
37
38
#ifdef WITH_CASPER
39
__BEGIN_DECLS
40
41
struct group *cap_getgrent(cap_channel_t *chan);
42
struct group *cap_getgrnam(cap_channel_t *chan, const char *name);
43
struct group *cap_getgrgid(cap_channel_t *chan, gid_t gid);
44
45
int cap_getgrent_r(cap_channel_t *chan, struct group *grp, char *buffer,
46
size_t bufsize, struct group **result);
47
int cap_getgrnam_r(cap_channel_t *chan, const char *name, struct group *grp,
48
char *buffer, size_t bufsize, struct group **result);
49
int cap_getgrgid_r(cap_channel_t *chan, gid_t gid, struct group *grp,
50
char *buffer, size_t bufsize, struct group **result);
51
52
int cap_setgroupent(cap_channel_t *chan, int stayopen);
53
int cap_setgrent(cap_channel_t *chan);
54
void cap_endgrent(cap_channel_t *chan);
55
56
int cap_grp_limit_cmds(cap_channel_t *chan, const char * const *cmds,
57
size_t ncmds);
58
int cap_grp_limit_fields(cap_channel_t *chan, const char * const *fields,
59
size_t nfields);
60
int cap_grp_limit_groups(cap_channel_t *chan, const char * const *names,
61
size_t nnames, const gid_t *gids, size_t ngids);
62
63
__END_DECLS
64
65
#else
66
#define cap_getgrent(chan) getgrent()
67
#define cap_getgrnam(chan, name) getgrnam(name)
68
#define cap_getgrgid(chan, gid) getgrgid(gid)
69
70
#define cap_setgroupent(chan, stayopen) etgroupent(stayopen)
71
#define endgrent(chan) endgrent()
72
static inline int
73
cap_setgrent(cap_channel_t *chan __unused)
74
{
75
76
setgrent();
77
return(0);
78
}
79
80
#define cap_getgrent_r(chan, grp, buffer, bufsize, result) \
81
getgrent_r(grp, buffer, bufsize, result)
82
#define cap_getgrnam_r(chan, name, grp, buffer, bufsize, result) \
83
getgrnam_r(name, grp, buffer, bufsize, result)
84
#define cap_getgrgid_r(chan, gid, grp, buffer, bufsize, result) \
85
getgrgid_r(gid, grp, buffer, bufsize, result)
86
87
#define cap_grp_limit_cmds(chan, cmds, ncmds) (0)
88
#define cap_grp_limit_fields(chan, fields, nfields) (0)
89
#define cap_grp_limit_groups(chan, names, nnames, gids, ngids) (0)
90
91
#endif
92
93
#endif /* !_CAP_GRP_H_ */
94
95