]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Solanum: a slightly advanced ircd | |
3 | * privilege.h: Dynamic privileges API. | |
4 | * | |
5 | * Copyright (c) 2021 Ed Kellett <e@kellett.im> | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation; either version 2 of the License, or | |
10 | * (at your option) any later version. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with this program; if not, write to the Free Software | |
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |
20 | * USA | |
21 | * | |
22 | * Copyright (c) 2008 Ariadne Conill <ariadne@dereferenced.org> | |
23 | * | |
24 | * Permission to use, copy, modify, and/or distribute this software for any | |
25 | * purpose with or without fee is hereby granted, provided that the above | |
26 | * copyright notice and this permission notice is present in all copies. | |
27 | * | |
28 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
29 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
30 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
31 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | |
32 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
33 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
34 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | |
37 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
38 | * POSSIBILITY OF SUCH DAMAGE. | |
39 | */ | |
40 | ||
41 | #ifndef __SOLANUM_PRIVILEGE_H | |
42 | #define __SOLANUM_PRIVILEGE_H | |
43 | ||
44 | #include "stdinc.h" | |
45 | ||
46 | struct Client; | |
47 | ||
48 | enum { | |
49 | PRIV_NEEDOPER = 1 | |
50 | }; | |
51 | typedef unsigned int PrivilegeFlags; | |
52 | ||
53 | struct PrivilegeSet { | |
54 | rb_dlink_node node; | |
55 | size_t size; | |
56 | const char **privs; | |
57 | size_t stored_size, allocated_size; | |
58 | char *priv_storage; | |
59 | char *name; | |
60 | struct PrivilegeSet *shadow; | |
61 | PrivilegeFlags flags; | |
62 | unsigned int status; /* If CONF_ILLEGAL, delete when no refs */ | |
63 | int refs; | |
64 | }; | |
65 | ||
66 | struct privset_diff { | |
67 | const struct PrivilegeSet *unchanged; | |
68 | const struct PrivilegeSet *added; | |
69 | const struct PrivilegeSet *removed; | |
70 | }; | |
71 | ||
72 | bool privilegeset_in_set(const struct PrivilegeSet *set, const char *priv); | |
73 | const char *const *privilegeset_privs(const struct PrivilegeSet *set); | |
74 | struct PrivilegeSet *privilegeset_set_new(const char *name, const char *privs, PrivilegeFlags flags); | |
75 | struct PrivilegeSet *privilegeset_extend(const struct PrivilegeSet *parent, const char *name, const char *privs, PrivilegeFlags flags); | |
76 | struct PrivilegeSet *privilegeset_get(const char *name); | |
77 | struct PrivilegeSet *privilegeset_ref(struct PrivilegeSet *set); | |
78 | void privilegeset_unref(struct PrivilegeSet *set); | |
79 | void privilegeset_prepare_rehash(void); | |
80 | void privilegeset_cleanup_rehash(void); | |
81 | void privilegeset_report(struct Client *source_p); | |
82 | ||
83 | struct privset_diff privilegeset_diff(const struct PrivilegeSet *, const struct PrivilegeSet *); | |
84 | ||
85 | #endif |