blob: 6839c479ff11dddb92f3de7c11bb3f29a6bfe1a8 [file] [log] [blame]
paul01245822003-05-20 01:22:17 +00001/*
2 * Zebra privileges header.
3 *
4 * Copyright (C) 2003 Paul Jakma.
5 *
6 * This file is part of GNU Zebra.
7 *
8 * GNU Zebra is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2, or (at your option) any
11 * later version.
12 *
13 * GNU Zebra is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with GNU Zebra; see the file COPYING. If not, write to the Free
20 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 * 02111-1307, USA.
22 */
23
24#ifndef _ZEBRA_PRIVS_H
25#define _ZEBRA_PRIVS_H
26
27/* list of zebra capabilities */
28typedef enum
29{
30 ZCAP_SETGID,
31 ZCAP_SETUID,
32 ZCAP_BIND,
33 ZCAP_BROADCAST,
34 ZCAP_ADMIN,
35 ZCAP_RAW,
36 ZCAP_CHROOT,
37 ZCAP_NICE,
38 ZCAP_PTRACE,
39 ZCAP_MAX
40} zebra_capabilities_t;
41
42typedef enum
43{
44 ZPRIVS_LOWERED,
45 ZPRIVS_RAISED
46} zebra_privs_current_t;
47
48typedef enum
49{
50 ZPRIVS_RAISE,
51 ZPRIVS_LOWER,
52} zebra_privs_ops_t;
53
54struct zebra_privs_t
55{
56 zebra_capabilities_t *caps_p; /* caps required for operation */
57 zebra_capabilities_t *caps_i; /* caps to allow inheritance of */
58 int cap_num_p; /* number of caps in arrays */
59 int cap_num_i;
60 char *user; /* user and group to run as */
61 char *group;
62
63 /* methods */
64 int
65 (*change) (zebra_privs_ops_t); /* change privileges, 0 on success */
66 zebra_privs_current_t
67 (*current_state) (void); /* current privilege state */
68};
69
70 /* initialise zebra privileges */
71void zprivs_init (struct zebra_privs_t *zprivs);
72 /* drop all and terminate privileges */
73void zprivs_terminate (void);
74
75#endif /* _ZEBRA_PRIVS_H */