summaryrefslogtreecommitdiff
path: root/src/bus-proxyd/bus-xml-policy.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-12-23 18:36:04 +0100
committerLennart Poettering <lennart@poettering.net>2014-12-23 19:15:27 +0100
commit3c70e3bb022f0de3317f3600c9366a2f4597339e (patch)
treef8cd5021f6f4bc2dd8fe8b6d777ca85d9f6fb896 /src/bus-proxyd/bus-xml-policy.h
parent3e0a2048978fcc7aff00797bdb876b2592c2fbc7 (diff)
core: rearrange code so that libsystemd/sd-bus/ does not include header files from core
Stuff in src/shared or src/libsystemd should *never* include code from src/core or any of the tools, so don't do that here either. It's not OK!
Diffstat (limited to 'src/bus-proxyd/bus-xml-policy.h')
-rw-r--r--src/bus-proxyd/bus-xml-policy.h104
1 files changed, 104 insertions, 0 deletions
diff --git a/src/bus-proxyd/bus-xml-policy.h b/src/bus-proxyd/bus-xml-policy.h
new file mode 100644
index 0000000000..933a53ceb5
--- /dev/null
+++ b/src/bus-proxyd/bus-xml-policy.h
@@ -0,0 +1,104 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+#pragma once
+
+/***
+ This file is part of systemd.
+
+ Copyright 2013 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <inttypes.h>
+
+#include "list.h"
+#include "hashmap.h"
+
+typedef enum PolicyItemType {
+ _POLICY_ITEM_TYPE_UNSET = 0,
+ POLICY_ITEM_ALLOW,
+ POLICY_ITEM_DENY,
+ _POLICY_ITEM_TYPE_MAX,
+ _POLICY_ITEM_TYPE_INVALID = -1,
+} PolicyItemType;
+
+typedef enum PolicyItemClass {
+ _POLICY_ITEM_CLASS_UNSET = 0,
+ POLICY_ITEM_SEND,
+ POLICY_ITEM_RECV,
+ POLICY_ITEM_OWN,
+ POLICY_ITEM_OWN_PREFIX,
+ POLICY_ITEM_USER,
+ POLICY_ITEM_GROUP,
+ POLICY_ITEM_IGNORE,
+ _POLICY_ITEM_CLASS_MAX,
+ _POLICY_ITEM_CLASS_INVALID = -1,
+} PolicyItemClass;
+
+typedef struct PolicyItem PolicyItem;
+
+struct PolicyItem {
+ PolicyItemType type;
+ PolicyItemClass class;
+ char *interface;
+ char *member;
+ char *error;
+ char *path;
+ char *name;
+ uint8_t message_type;
+ uid_t uid;
+ gid_t gid;
+
+ bool uid_valid, gid_valid;
+
+ LIST_FIELDS(PolicyItem, items);
+};
+
+typedef struct Policy {
+ LIST_HEAD(PolicyItem, default_items);
+ LIST_HEAD(PolicyItem, mandatory_items);
+ Hashmap *user_items;
+ Hashmap *group_items;
+} Policy;
+
+int policy_load(Policy *p, char **files);
+void policy_free(Policy *p);
+
+bool policy_check_own(Policy *p, uid_t uid, gid_t gid, const char *name);
+bool policy_check_hello(Policy *p, uid_t uid, gid_t gid);
+bool policy_check_recv(Policy *p,
+ uid_t uid,
+ gid_t gid,
+ int message_type,
+ const char *name,
+ const char *path,
+ const char *interface,
+ const char *member);
+bool policy_check_send(Policy *p,
+ uid_t uid,
+ gid_t gid,
+ int message_type,
+ const char *name,
+ const char *path,
+ const char *interface,
+ const char *member);
+
+void policy_dump(Policy *p);
+
+const char* policy_item_type_to_string(PolicyItemType t) _const_;
+PolicyItemType policy_item_type_from_string(const char *s) _pure_;
+
+const char* policy_item_class_to_string(PolicyItemClass t) _const_;
+PolicyItemClass policy_item_class_from_string(const char *s) _pure_;