]> jfr.im git - solanum.git/blame - include/privilege.h
ircd/authproc.c: avoid crash on lack of any configured DNSBLs
[solanum.git] / include / privilege.h
CommitLineData
9c3f080b 1/*
a6f63a82 2 * Solanum: a slightly advanced ircd
9c3f080b
AC
3 * privilege.h: Dynamic privileges API.
4 *
8aadf0ce
EK
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 *
3fc0499e 22 * Copyright (c) 2008 Ariadne Conill <ariadne@dereferenced.org>
9c3f080b
AC
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
a6f63a82
EK
41#ifndef __SOLANUM_PRIVILEGE_H
42#define __SOLANUM_PRIVILEGE_H
9c3f080b
AC
43
44#include "stdinc.h"
45
7a246575
EK
46struct Client;
47
975c6192 48enum {
9c3f080b 49 PRIV_NEEDOPER = 1
975c6192
JT
50};
51typedef unsigned int PrivilegeFlags;
9c3f080b
AC
52
53struct PrivilegeSet {
8aadf0ce
EK
54 rb_dlink_node node;
55 size_t size;
56 const char **privs;
57 size_t stored_size, allocated_size;
58 char *priv_storage;
9c3f080b 59 char *name;
8aadf0ce 60 struct PrivilegeSet *shadow;
9c3f080b 61 PrivilegeFlags flags;
8aadf0ce
EK
62 unsigned int status; /* If CONF_ILLEGAL, delete when no refs */
63 int refs;
9c3f080b
AC
64};
65
9962f625
EK
66struct privset_diff {
67 const struct PrivilegeSet *unchanged;
68 const struct PrivilegeSet *added;
69 const struct PrivilegeSet *removed;
70};
71
8aadf0ce 72bool privilegeset_in_set(const struct PrivilegeSet *set, const char *priv);
181410f2 73const char *const *privilegeset_privs(const struct PrivilegeSet *set);
9c3f080b 74struct PrivilegeSet *privilegeset_set_new(const char *name, const char *privs, PrivilegeFlags flags);
8aadf0ce 75struct PrivilegeSet *privilegeset_extend(const struct PrivilegeSet *parent, const char *name, const char *privs, PrivilegeFlags flags);
9c3f080b 76struct PrivilegeSet *privilegeset_get(const char *name);
598b4cf1 77struct PrivilegeSet *privilegeset_ref(struct PrivilegeSet *set);
9c3f080b 78void privilegeset_unref(struct PrivilegeSet *set);
8aadf0ce
EK
79void privilegeset_prepare_rehash(void);
80void privilegeset_cleanup_rehash(void);
3a177354 81void privilegeset_report(struct Client *source_p);
9c3f080b 82
9962f625 83struct privset_diff privilegeset_diff(const struct PrivilegeSet *, const struct PrivilegeSet *);
8aadf0ce 84
9c3f080b 85#endif