1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
6 This file is part of systemd.
8 Copyright 2013 Lennart Poettering
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
29 typedef enum PolicyItemType {
30 _POLICY_ITEM_TYPE_UNSET = 0,
33 _POLICY_ITEM_TYPE_MAX,
34 _POLICY_ITEM_TYPE_INVALID = -1,
37 typedef enum PolicyItemClass {
38 _POLICY_ITEM_CLASS_UNSET = 0,
42 POLICY_ITEM_OWN_PREFIX,
46 _POLICY_ITEM_CLASS_MAX,
47 _POLICY_ITEM_CLASS_INVALID = -1,
50 typedef struct PolicyItem PolicyItem;
54 PolicyItemClass class;
64 bool uid_valid, gid_valid;
66 LIST_FIELDS(PolicyItem, items);
69 typedef struct Policy {
70 LIST_HEAD(PolicyItem, default_items);
71 LIST_HEAD(PolicyItem, mandatory_items);
72 LIST_HEAD(PolicyItem, on_console_items);
73 LIST_HEAD(PolicyItem, no_console_items);
78 typedef struct SharedPolicy {
81 pthread_rwlock_t rwlock;
88 int policy_load(Policy *p, char **files);
89 void policy_free(Policy *p);
91 bool policy_check_own(Policy *p, uid_t uid, gid_t gid, const char *name);
92 bool policy_check_hello(Policy *p, uid_t uid, gid_t gid);
93 bool policy_check_one_recv(Policy *p,
99 const char *interface,
101 bool policy_check_recv(Policy *p,
108 const char *interface,
110 bool dbus_to_kernel);
111 bool policy_check_one_send(Policy *p,
117 const char *interface,
119 bool policy_check_send(Policy *p,
126 const char *interface,
129 char **out_used_name);
131 void policy_dump(Policy *p);
133 const char* policy_item_type_to_string(PolicyItemType t) _const_;
134 PolicyItemType policy_item_type_from_string(const char *s) _pure_;
136 const char* policy_item_class_to_string(PolicyItemClass t) _const_;
137 PolicyItemClass policy_item_class_from_string(const char *s) _pure_;
141 int shared_policy_new(SharedPolicy **out);
142 SharedPolicy *shared_policy_free(SharedPolicy *sp);
144 int shared_policy_reload(SharedPolicy *sp);
145 int shared_policy_preload(SharedPolicy *sp, char **configuration);
146 Policy *shared_policy_acquire(SharedPolicy *sp);
147 void shared_policy_release(SharedPolicy *sp, Policy *p);
149 DEFINE_TRIVIAL_CLEANUP_FUNC(SharedPolicy*, shared_policy_free);