blob: 65c9f3587cb4b8466d905753d78ae5da045d0ffc [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,
paul8d6b00e2003-05-22 02:35:52 +000035 ZCAP_SYS_ADMIN,
paul01245822003-05-20 01:22:17 +000036 ZCAP_RAW,
37 ZCAP_CHROOT,
38 ZCAP_NICE,
39 ZCAP_PTRACE,
paul8d6b00e2003-05-22 02:35:52 +000040 ZCAP_DAC_OVERRIDE,
41 ZCAP_READ_SEARCH,
42 ZCAP_FOWNER,
paul01245822003-05-20 01:22:17 +000043 ZCAP_MAX
44} zebra_capabilities_t;
45
46typedef enum
47{
48 ZPRIVS_LOWERED,
49 ZPRIVS_RAISED
50} zebra_privs_current_t;
51
52typedef enum
53{
54 ZPRIVS_RAISE,
55 ZPRIVS_LOWER,
56} zebra_privs_ops_t;
57
58struct zebra_privs_t
59{
60 zebra_capabilities_t *caps_p; /* caps required for operation */
61 zebra_capabilities_t *caps_i; /* caps to allow inheritance of */
62 int cap_num_p; /* number of caps in arrays */
63 int cap_num_i;
64 char *user; /* user and group to run as */
65 char *group;
hassoba3a0bc2003-06-04 17:41:54 +000066 char *vty_group; /* group to chown vty socket to */
paul01245822003-05-20 01:22:17 +000067 /* methods */
68 int
69 (*change) (zebra_privs_ops_t); /* change privileges, 0 on success */
70 zebra_privs_current_t
71 (*current_state) (void); /* current privilege state */
72};
73
hassoba3a0bc2003-06-04 17:41:54 +000074struct zprivs_ids_t
75{
76 /* -1 is undefined */
77 uid_t uid_priv; /* privileged uid */
78 uid_t uid_normal; /* normal uid */
79 gid_t gid_priv; /* privileged uid */
80 gid_t gid_normal; /* normal uid */
81 gid_t gid_vty; /* vty gid */
82};
83
paul01245822003-05-20 01:22:17 +000084 /* initialise zebra privileges */
85void zprivs_init (struct zebra_privs_t *zprivs);
86 /* drop all and terminate privileges */
87void zprivs_terminate (void);
hassoba3a0bc2003-06-04 17:41:54 +000088 /* query for runtime uid's and gid's, eg vty needs this */
89void zprivs_get_ids(struct zprivs_ids_t *);
paul01245822003-05-20 01:22:17 +000090
91#endif /* _ZEBRA_PRIVS_H */