summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
ec84087)
Add a new config 'Activating' directive which denotes whether a busname
is actually registered on the bus. It defaults to 'yes'.
If set to 'no', the .busname unit only uploads policy, which will remain
active as long as the unit is running.
units/systemd-bus-driverd.service
dist_systemunit_DATA += \
units/systemd-bus-driverd.service
dist_systemunit_DATA += \
- units/org.freedesktop.DBus.busname
+ units/org.freedesktop.DBus.busname \
+ units/org.freedesktop.systemd1.busname
BUSNAMES_TARGET_WANTS += \
BUSNAMES_TARGET_WANTS += \
- org.freedesktop.DBus.busname
+ org.freedesktop.DBus.busname \
+ org.freedesktop.systemd1.busname
nodist_userunit_DATA += \
units/user/systemd-bus-driverd.service
nodist_userunit_DATA += \
units/user/systemd-bus-driverd.service
static const UnitActiveState state_translation_table[_BUSNAME_STATE_MAX] = {
[BUSNAME_DEAD] = UNIT_INACTIVE,
static const UnitActiveState state_translation_table[_BUSNAME_STATE_MAX] = {
[BUSNAME_DEAD] = UNIT_INACTIVE,
+ [BUSNAME_REGISTERED] = UNIT_ACTIVE,
[BUSNAME_LISTENING] = UNIT_ACTIVE,
[BUSNAME_RUNNING] = UNIT_ACTIVE,
[BUSNAME_FAILED] = UNIT_FAILED
[BUSNAME_LISTENING] = UNIT_ACTIVE,
[BUSNAME_RUNNING] = UNIT_ACTIVE,
[BUSNAME_FAILED] = UNIT_FAILED
- if (!UNIT_DEREF(n->service)) {
- Unit *x;
+ if (n->activating) {
+ if (!UNIT_DEREF(n->service)) {
+ Unit *x;
- r = unit_load_related_unit(u, ".service", &x);
+ r = unit_load_related_unit(u, ".service", &x);
+ if (r < 0)
+ return r;
+
+ unit_ref_set(&n->service, x);
+ }
+
+ r = unit_add_two_dependencies(u, UNIT_BEFORE, UNIT_TRIGGERS, UNIT_DEREF(n->service), true);
-
- unit_ref_set(&n->service, x);
- r = unit_add_two_dependencies(u, UNIT_BEFORE, UNIT_TRIGGERS, UNIT_DEREF(n->service), true);
- if (r < 0)
- return r;
-
if (u->default_dependencies) {
r = busname_add_default_default_dependencies(n);
if (r < 0)
if (u->default_dependencies) {
r = busname_add_default_default_dependencies(n);
if (r < 0)
"%sBus Name State: %s\n"
"%sResult: %s\n"
"%sName: %s\n"
"%sBus Name State: %s\n"
"%sResult: %s\n"
"%sName: %s\n"
"%sAccept FD: %s\n",
prefix, busname_state_to_string(n->state),
prefix, busname_result_to_string(n->result),
prefix, n->name,
"%sAccept FD: %s\n",
prefix, busname_state_to_string(n->state),
prefix, busname_result_to_string(n->result),
prefix, n->name,
+ prefix, yes_no(n->activating),
prefix, yes_no(n->accept_fd));
}
prefix, yes_no(n->accept_fd));
}
n->starter_fd = bus_kernel_create_starter(
UNIT(n)->manager->running_as == SYSTEMD_SYSTEM ? "system" : "user",
n->starter_fd = bus_kernel_create_starter(
UNIT(n)->manager->running_as == SYSTEMD_SYSTEM ? "system" : "user",
- n->name, n->accept_fd, n->policy);
+ n->name, n->activating, n->accept_fd, n->policy);
if (n->starter_fd < 0) {
log_warning_unit(UNIT(n)->id, "Failed to create starter fd: %s", strerror(-n->starter_fd));
if (n->starter_fd < 0) {
log_warning_unit(UNIT(n)->id, "Failed to create starter fd: %s", strerror(-n->starter_fd));
if (state != BUSNAME_LISTENING)
busname_unwatch_fd(n);
if (state != BUSNAME_LISTENING)
busname_unwatch_fd(n);
- if (!IN_SET(state, BUSNAME_LISTENING, BUSNAME_RUNNING))
+ if (!IN_SET(state, BUSNAME_LISTENING, BUSNAME_REGISTERED, BUSNAME_RUNNING))
busname_close_fd(n);
if (state != old_state)
busname_close_fd(n);
if (state != old_state)
if (n->deserialized_state == n->state)
return 0;
if (n->deserialized_state == n->state)
return 0;
- if (IN_SET(n->deserialized_state, BUSNAME_LISTENING, BUSNAME_RUNNING)) {
+ if (IN_SET(n->deserialized_state, BUSNAME_LISTENING, BUSNAME_REGISTERED, BUSNAME_RUNNING)) {
r = busname_open_fd(n);
if (r < 0)
return r;
r = busname_open_fd(n);
if (r < 0)
return r;
r = busname_open_fd(n);
if (r < 0) {
r = busname_open_fd(n);
if (r < 0) {
- log_warning_unit(UNIT(n)->id, "%s failed to listen on bus names: %s", UNIT(n)->id, strerror(-r));
+ log_warning_unit(UNIT(n)->id, "%s failed to %s: %s", UNIT(n)->id,
+ n->activating ? "listen on bus name" : "register policy for name",
+ strerror(-r));
- r = busname_watch_fd(n);
- if (r < 0) {
- log_warning_unit(UNIT(n)->id, "%s failed to watch names: %s", UNIT(n)->id, strerror(-r));
- goto fail;
- }
+ if (n->activating) {
+ r = busname_watch_fd(n);
+ if (r < 0) {
+ log_warning_unit(UNIT(n)->id, "%s failed to watch names: %s", UNIT(n)->id, strerror(-r));
+ goto fail;
+ }
+
+ busname_set_state(n, BUSNAME_LISTENING);
+ } else
+ busname_set_state(n, BUSNAME_REGISTERED);
- busname_set_state(n, BUSNAME_LISTENING);
+ if (!n->activating)
+ return;
+
/* We don't take conenctions anymore if we are supposed to
* shut down anyway */
/* We don't take conenctions anymore if we are supposed to
* shut down anyway */
- if (UNIT_ISSET(n->service)) {
+ if (n->activating && UNIT_ISSET(n->service)) {
Service *service;
service = SERVICE(UNIT_DEREF(n->service));
Service *service;
service = SERVICE(UNIT_DEREF(n->service));
BusName *n = BUSNAME(u);
assert(n);
BusName *n = BUSNAME(u);
assert(n);
- assert(n->state == BUSNAME_LISTENING || n->state == BUSNAME_RUNNING);
+ assert(IN_SET(n->state, BUSNAME_REGISTERED, BUSNAME_LISTENING, BUSNAME_RUNNING));
busname_enter_dead(n, BUSNAME_SUCCESS);
return 0;
busname_enter_dead(n, BUSNAME_SUCCESS);
return 0;
static const char* const busname_state_table[_BUSNAME_STATE_MAX] = {
[BUSNAME_DEAD] = "dead",
static const char* const busname_state_table[_BUSNAME_STATE_MAX] = {
[BUSNAME_DEAD] = "dead",
+ [BUSNAME_REGISTERED] = "registered",
[BUSNAME_LISTENING] = "listening",
[BUSNAME_RUNNING] = "running",
[BUSNAME_FAILED] = "failed"
[BUSNAME_LISTENING] = "listening",
[BUSNAME_RUNNING] = "running",
[BUSNAME_FAILED] = "failed"
typedef enum BusNameState {
BUSNAME_DEAD,
typedef enum BusNameState {
BUSNAME_DEAD,
BUSNAME_LISTENING,
BUSNAME_RUNNING,
BUSNAME_FAILED,
BUSNAME_LISTENING,
BUSNAME_RUNNING,
BUSNAME_FAILED,
char *name;
int starter_fd;
char *name;
int starter_fd;
KILL_CONTEXT_CONFIG_ITEMS(Socket)m4_dnl
m4_dnl
BusName.Name, config_parse_string, 0, offsetof(BusName, name)
KILL_CONTEXT_CONFIG_ITEMS(Socket)m4_dnl
m4_dnl
BusName.Name, config_parse_string, 0, offsetof(BusName, name)
+BusName.Activating, config_parse_bool, 0, offsetof(BusName, activating)
BusName.Service, config_parse_busname_service, 0, 0
BusName.AllowUser, config_parse_bus_policy, 0, 0
BusName.AllowGroup, config_parse_bus_policy, 0, 0
BusName.Service, config_parse_busname_service, 0, 0
BusName.AllowUser, config_parse_bus_policy, 0, 0
BusName.AllowGroup, config_parse_bus_policy, 0, 0
-int bus_kernel_create_starter(const char *bus, const char *name, bool accept_fd, BusNamePolicy *policy) {
+int bus_kernel_create_starter(const char *bus, const char *name, bool activating, bool accept_fd, BusNamePolicy *policy) {
struct kdbus_cmd_hello *hello;
struct kdbus_item *n;
size_t policy_cnt = 0;
struct kdbus_cmd_hello *hello;
struct kdbus_item *n;
size_t policy_cnt = 0;
- hello->conn_flags = KDBUS_HELLO_ACTIVATOR | (accept_fd ? KDBUS_HELLO_ACCEPT_FD : 0);
+ hello->conn_flags =
+ (activating ? KDBUS_HELLO_ACTIVATOR : KDBUS_HELLO_POLICY_HOLDER) |
+ (accept_fd ? KDBUS_HELLO_ACCEPT_FD : 0);
hello->pool_size = KDBUS_POOL_SIZE;
hello->attach_flags = _KDBUS_ATTACH_ALL;
hello->pool_size = KDBUS_POOL_SIZE;
hello->attach_flags = _KDBUS_ATTACH_ALL;
int bus_kernel_create_bus(const char *name, bool world, char **s);
int bus_kernel_create_domain(const char *name, char **s);
int bus_kernel_create_bus(const char *name, bool world, char **s);
int bus_kernel_create_domain(const char *name, char **s);
-int bus_kernel_create_starter(const char *bus, const char *name, bool accept_fd, BusNamePolicy *policy);
+int bus_kernel_create_starter(const char *bus, const char *name, bool activating, bool accept_fd, BusNamePolicy *policy);
int bus_kernel_create_monitor(const char *bus);
int bus_kernel_pop_memfd(sd_bus *bus, void **address, size_t *mapped, size_t *allocated);
int bus_kernel_create_monitor(const char *bus);
int bus_kernel_pop_memfd(sd_bus *bus, void **address, size_t *mapped, size_t *allocated);
--- /dev/null
+# This file is part of systemd.
+#
+# 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.
+
+[Unit]
+Description=systemd busname unit
+Documentation=man:systemd-hostnamed.service(8)
+Documentation=http://www.freedesktop.org/wiki/Software/systemd
+
+[BusName]
+Activating=no
+AllowWorld=talk