mirror of
https://github.com/clearlinux/systemd-stable.git
synced 2026-09-06 21:51:37 +00:00
bus: factor out bus policy items
In order to re-use the policy definitions, factor them out into their own files.
This commit is contained in:
@@ -1026,6 +1026,8 @@ libsystemd_core_la_SOURCES = \
|
||||
src/core/socket.h \
|
||||
src/core/busname.c \
|
||||
src/core/busname.h \
|
||||
src/core/bus-common.c \
|
||||
src/core/bus-common.h \
|
||||
src/core/target.c \
|
||||
src/core/target.h \
|
||||
src/core/snapshot.c \
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
/***
|
||||
This file is part of systemd.
|
||||
|
||||
Copyright 2014 Daniel Mack
|
||||
|
||||
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 "special.h"
|
||||
#include "bus-kernel.h"
|
||||
#include "bus-internal.h"
|
||||
#include "bus-util.h"
|
||||
#include "service.h"
|
||||
#include "bus-common.h"
|
||||
|
||||
static const char* const bus_policy_access_table[_BUS_POLICY_ACCESS_MAX] = {
|
||||
[BUS_POLICY_ACCESS_SEE] = "see",
|
||||
[BUS_POLICY_ACCESS_TALK] = "talk",
|
||||
[BUS_POLICY_ACCESS_OWN] = "own",
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(bus_policy_access, BusPolicyAccess);
|
||||
@@ -0,0 +1,35 @@
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "macro.h"
|
||||
|
||||
/***
|
||||
This file is part of systemd.
|
||||
|
||||
Copyright 2014 Daniel Mack
|
||||
|
||||
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/>.
|
||||
***/
|
||||
|
||||
typedef enum BusPolicyAccess {
|
||||
BUS_POLICY_ACCESS_SEE,
|
||||
BUS_POLICY_ACCESS_TALK,
|
||||
BUS_POLICY_ACCESS_OWN,
|
||||
_BUS_POLICY_ACCESS_MAX,
|
||||
_BUS_POLICY_ACCESS_INVALID = -1
|
||||
} BusPolicyAccess;
|
||||
|
||||
const char* bus_policy_access_to_string(BusPolicyAccess i) _const_;
|
||||
BusPolicyAccess bus_policy_access_from_string(const char *s) _pure_;
|
||||
@@ -911,14 +911,6 @@ static const char* const busname_result_table[_BUSNAME_RESULT_MAX] = {
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(busname_result, BusNameResult);
|
||||
|
||||
static const char* const busname_policy_access_table[_BUSNAME_POLICY_ACCESS_MAX] = {
|
||||
[BUSNAME_POLICY_ACCESS_SEE] = "see",
|
||||
[BUSNAME_POLICY_ACCESS_TALK] = "talk",
|
||||
[BUSNAME_POLICY_ACCESS_OWN] = "own",
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(busname_policy_access, BusNamePolicyAccess);
|
||||
|
||||
const UnitVTable busname_vtable = {
|
||||
.object_size = sizeof(BusName),
|
||||
|
||||
|
||||
+3
-13
@@ -25,6 +25,7 @@ typedef struct BusName BusName;
|
||||
typedef struct BusNamePolicy BusNamePolicy;
|
||||
|
||||
#include "unit.h"
|
||||
#include "bus-common.h"
|
||||
|
||||
typedef enum BusNameState {
|
||||
BUSNAME_DEAD,
|
||||
@@ -58,17 +59,9 @@ typedef enum BusNamePolicyType {
|
||||
_BUSNAME_POLICY_TYPE_INVALID = -1
|
||||
} BusNamePolicyType;
|
||||
|
||||
typedef enum BusNamePolicyAccess {
|
||||
BUSNAME_POLICY_ACCESS_SEE,
|
||||
BUSNAME_POLICY_ACCESS_TALK,
|
||||
BUSNAME_POLICY_ACCESS_OWN,
|
||||
_BUSNAME_POLICY_ACCESS_MAX,
|
||||
_BUSNAME_POLICY_ACCESS_INVALID = -1
|
||||
} BusNamePolicyAccess;
|
||||
|
||||
struct BusNamePolicy {
|
||||
BusNamePolicyType type;
|
||||
BusNamePolicyAccess access;
|
||||
BusPolicyAccess access;
|
||||
|
||||
char *name;
|
||||
|
||||
@@ -97,7 +90,7 @@ struct BusName {
|
||||
pid_t control_pid;
|
||||
|
||||
LIST_HEAD(BusNamePolicy, policy);
|
||||
BusNamePolicyAccess policy_world;
|
||||
BusPolicyAccess policy_world;
|
||||
};
|
||||
|
||||
extern const UnitVTable busname_vtable;
|
||||
@@ -107,6 +100,3 @@ BusNameState busname_state_from_string(const char *s) _pure_;
|
||||
|
||||
const char* busname_result_to_string(BusNameResult i) _const_;
|
||||
BusNameResult busname_result_from_string(const char *s) _pure_;
|
||||
|
||||
const char* busname_policy_access_to_string(BusNamePolicyAccess i) _const_;
|
||||
BusNamePolicyAccess busname_policy_access_from_string(const char *s) _pure_;
|
||||
|
||||
@@ -1686,7 +1686,7 @@ int config_parse_busname_service(
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_CONFIG_PARSE_ENUM(config_parse_bus_policy_world, busname_policy_access, BusNamePolicyAccess, "Failed to parse bus name policy access");
|
||||
DEFINE_CONFIG_PARSE_ENUM(config_parse_bus_policy_world, bus_policy_access, BusPolicyAccess, "Failed to parse bus name policy access");
|
||||
|
||||
int config_parse_bus_policy(
|
||||
const char *unit,
|
||||
@@ -1736,7 +1736,7 @@ int config_parse_bus_policy(
|
||||
access_str++;
|
||||
access_str += strspn(access_str, WHITESPACE);
|
||||
|
||||
p->access = busname_policy_access_from_string(access_str);
|
||||
p->access = bus_policy_access_from_string(access_str);
|
||||
if (p->access < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
|
||||
"Invalid busname policy access type '%s'", access_str);
|
||||
|
||||
@@ -1322,19 +1322,19 @@ int bus_kernel_create_bus(const char *name, bool world, char **s) {
|
||||
return fd;
|
||||
}
|
||||
|
||||
static int bus_kernel_translate_access(BusNamePolicyAccess access) {
|
||||
static int bus_kernel_translate_access(BusPolicyAccess access) {
|
||||
assert(access >= 0);
|
||||
assert(access < _BUSNAME_POLICY_ACCESS_MAX);
|
||||
assert(access < _BUS_POLICY_ACCESS_MAX);
|
||||
|
||||
switch (access) {
|
||||
|
||||
case BUSNAME_POLICY_ACCESS_SEE:
|
||||
case BUS_POLICY_ACCESS_SEE:
|
||||
return KDBUS_POLICY_SEE;
|
||||
|
||||
case BUSNAME_POLICY_ACCESS_TALK:
|
||||
case BUS_POLICY_ACCESS_TALK:
|
||||
return KDBUS_POLICY_TALK;
|
||||
|
||||
case BUSNAME_POLICY_ACCESS_OWN:
|
||||
case BUS_POLICY_ACCESS_OWN:
|
||||
return KDBUS_POLICY_OWN;
|
||||
|
||||
default:
|
||||
@@ -1414,7 +1414,7 @@ int bus_kernel_make_starter(
|
||||
bool activating,
|
||||
bool accept_fd,
|
||||
BusNamePolicy *policy,
|
||||
BusNamePolicyAccess world_policy) {
|
||||
BusPolicyAccess world_policy) {
|
||||
|
||||
struct kdbus_cmd_hello *hello;
|
||||
struct kdbus_item *n;
|
||||
|
||||
@@ -66,7 +66,7 @@ int bus_kernel_write_message(sd_bus *bus, sd_bus_message *m, bool hint_sync_call
|
||||
int bus_kernel_read_message(sd_bus *bus, bool hint_priority, int64_t priority);
|
||||
|
||||
int bus_kernel_open_bus_fd(const char *bus, char **path);
|
||||
int bus_kernel_make_starter(int fd, const char *name, bool activating, bool accept_fd, BusNamePolicy *policy, BusNamePolicyAccess world_policy);
|
||||
int bus_kernel_make_starter(int fd, const char *name, bool activating, bool accept_fd, BusNamePolicy *policy, BusPolicyAccess world_policy);
|
||||
|
||||
int bus_kernel_create_bus(const char *name, bool world, char **s);
|
||||
int bus_kernel_create_domain(const char *name, char **s);
|
||||
|
||||
@@ -55,7 +55,7 @@ int main(int argc, char **argv) {
|
||||
test_table(architecture, ARCHITECTURE);
|
||||
test_table(automount_result, AUTOMOUNT_RESULT);
|
||||
test_table(automount_state, AUTOMOUNT_STATE);
|
||||
test_table(busname_policy_access, BUSNAME_POLICY_ACCESS);
|
||||
test_table(bus_policy_access, BUS_POLICY_ACCESS);
|
||||
test_table(busname_result, BUSNAME_RESULT);
|
||||
test_table(busname_state, BUSNAME_STATE);
|
||||
test_table(cgroup_device_policy, CGROUP_DEVICE_POLICY);
|
||||
|
||||
Reference in New Issue
Block a user