Commit 5e8d1c9a authored by Lennart Poettering's avatar Lennart Poettering
Browse files

dbus: to make sure that systemd stays controllable during early bootup,...

dbus: to make sure that systemd stays controllable during early bootup, register our services on our own micro usb server in addition to the bus
parent f9704703
......@@ -59,12 +59,12 @@
* systemd-sysvinit as package
* abstract namespace dbus socket
* patch /etc/init.d/functions with:
if [ $PPID -ne 1 && mountpoint /cgroup/systemd ] ; then echo "You suck!" ; fi
* remove MANAGER_SYSTEM
Regularly:
* look for close() vs. close_nointr() vs. close_nointr_nofail()
......
......@@ -38,12 +38,12 @@
const char bus_automount_interface[] = BUS_AUTOMOUNT_INTERFACE;
DBusHandlerResult bus_automount_message_handler(Unit *u, DBusMessage *message) {
DBusHandlerResult bus_automount_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
{ "org.freedesktop.systemd1.Automount", "Where", bus_property_append_string, "s", u->automount.where },
{ NULL, NULL, NULL, NULL, NULL }
};
return bus_default_message_handler(u->meta.manager, message, INTROSPECTION, properties);
return bus_default_message_handler(u->meta.manager, c, message, INTROSPECTION, properties);
}
......@@ -26,7 +26,7 @@
#include "unit.h"
DBusHandlerResult bus_automount_message_handler(Unit *u, DBusMessage *message);
DBusHandlerResult bus_automount_message_handler(Unit *u, DBusConnection *c, DBusMessage *message);
extern const char bus_automount_interface[];
......
......@@ -38,12 +38,12 @@
const char bus_device_interface[] = BUS_DEVICE_INTERFACE;
DBusHandlerResult bus_device_message_handler(Unit *u, DBusMessage *message) {
DBusHandlerResult bus_device_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
{ "org.freedesktop.systemd1.Device", "SysFSPath", bus_property_append_string, "s", u->device.sysfs },
{ NULL, NULL, NULL, NULL, NULL }
};
return bus_default_message_handler(u->meta.manager, message, INTROSPECTION, properties);
return bus_default_message_handler(u->meta.manager, c, message, INTROSPECTION, properties);
}
......@@ -26,7 +26,7 @@
#include "unit.h"
DBusHandlerResult bus_device_message_handler(Unit *u, DBusMessage *message);
DBusHandlerResult bus_device_message_handler(Unit *u, DBusConnection *c, DBusMessage *message);
extern const char bus_device_interface[];
......
......@@ -78,7 +78,7 @@ static int bus_job_append_unit(Manager *m, DBusMessageIter *i, const char *prope
return 0;
}
static DBusHandlerResult bus_job_message_dispatch(Job *j, DBusMessage *message) {
static DBusHandlerResult bus_job_message_dispatch(Job *j, DBusConnection *connection, DBusMessage *message) {
const BusProperty properties[] = {
{ "org.freedesktop.systemd1.Job", "Id", bus_property_append_uint32, "u", &j->id },
{ "org.freedesktop.systemd1.Job", "State", bus_job_append_state, "s", &j->state },
......@@ -88,7 +88,6 @@ static DBusHandlerResult bus_job_message_dispatch(Job *j, DBusMessage *message)
};
DBusMessage *reply = NULL;
Manager *m = j->manager;
if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Job", "Cancel")) {
if (!(reply = dbus_message_new_method_return(message)))
......@@ -97,10 +96,10 @@ static DBusHandlerResult bus_job_message_dispatch(Job *j, DBusMessage *message)
job_free(j);
} else
return bus_default_message_handler(j->manager, message, INTROSPECTION, properties);
return bus_default_message_handler(j->manager, connection, message, INTROSPECTION, properties);
if (reply) {
if (!dbus_connection_send(m->api_bus, reply, NULL))
if (!dbus_connection_send(connection, reply, NULL))
goto oom;
dbus_message_unref(reply);
......@@ -115,7 +114,7 @@ oom:
return DBUS_HANDLER_RESULT_NEED_MEMORY;
}
static DBusHandlerResult bus_job_message_handler(DBusConnection *connection, DBusMessage *message, void *data) {
static DBusHandlerResult bus_job_message_handler(DBusConnection *connection, DBusMessage *message, void *data) {
Manager *m = data;
Job *j;
int r;
......@@ -137,10 +136,10 @@ static DBusHandlerResult bus_job_message_handler(DBusConnection *connection, DB
if (r == -ENOENT)
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
return bus_send_error_reply(m, message, NULL, r);
return bus_send_error_reply(m, connection, message, NULL, r);
}
return bus_job_message_dispatch(j, message);
return bus_job_message_dispatch(j, connection, message);
}
const DBusObjectPathVTable bus_job_vtable = {
......@@ -183,7 +182,7 @@ void bus_job_send_change_signal(Job *j) {
goto oom;
}
if (!dbus_connection_send(j->manager->api_bus, m, NULL))
if (bus_broadcast(j->manager, m) < 0)
goto oom;
free(p);
......@@ -228,7 +227,7 @@ void bus_job_send_removed_signal(Job *j, bool success) {
DBUS_TYPE_INVALID))
goto oom;
if (!dbus_connection_send(j->manager->api_bus, m, NULL))
if (bus_broadcast(j->manager, m) < 0)
goto oom;
free(p);
......
......@@ -185,7 +185,7 @@ static int bus_manager_append_n_jobs(Manager *m, DBusMessageIter *i, const char
return 0;
}
static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, DBusMessage *message, void *data) {
static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, DBusMessage *message, void *data) {
Manager *m = data;
const BusProperty properties[] = {
......@@ -226,10 +226,10 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
&error,
DBUS_TYPE_STRING, &name,
DBUS_TYPE_INVALID))
return bus_send_error_reply(m, message, &error, -EINVAL);
return bus_send_error_reply(m, connection, message, &error, -EINVAL);
if (!(u = manager_get_unit(m, name)))
return bus_send_error_reply(m, message, NULL, -ENOENT);
return bus_send_error_reply(m, connection, message, NULL, -ENOENT);
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
......@@ -252,10 +252,10 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
&error,
DBUS_TYPE_STRING, &name,
DBUS_TYPE_INVALID))
return bus_send_error_reply(m, message, &error, -EINVAL);
return bus_send_error_reply(m, connection, message, &error, -EINVAL);
if ((r = manager_load_unit(m, name, NULL, &u)) < 0)
return bus_send_error_reply(m, message, NULL, r);
return bus_send_error_reply(m, connection, message, NULL, r);
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
......@@ -286,10 +286,10 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
&error,
DBUS_TYPE_UINT32, &id,
DBUS_TYPE_INVALID))
return bus_send_error_reply(m, message, &error, -EINVAL);
return bus_send_error_reply(m, connection, message, &error, -EINVAL);
if (!(j = manager_get_job(m, id)))
return bus_send_error_reply(m, message, NULL, -ENOENT);
return bus_send_error_reply(m, connection, message, NULL, -ENOENT);
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
......@@ -449,7 +449,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
r = set_put(m->subscribed, client);
if (r < 0)
return bus_send_error_reply(m, message, NULL, r);
return bus_send_error_reply(m, connection, message, NULL, r);
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
......@@ -458,7 +458,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
char *client;
if (!(client = set_remove(m->subscribed, (char*) dbus_message_get_sender(message))))
return bus_send_error_reply(m, message, NULL, -ENOENT);
return bus_send_error_reply(m, connection, message, NULL, -ENOENT);
free(client);
......@@ -504,13 +504,13 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
DBUS_TYPE_STRING, &name,
DBUS_TYPE_BOOLEAN, &cleanup,
DBUS_TYPE_INVALID))
return bus_send_error_reply(m, message, &error, -EINVAL);
return bus_send_error_reply(m, connection, message, &error, -EINVAL);
if (name && name[0] == 0)
name = NULL;
if ((r = snapshot_create(m, name, cleanup, &s)) < 0)
return bus_send_error_reply(m, message, NULL, r);
return bus_send_error_reply(m, connection, message, NULL, r);
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
......@@ -609,7 +609,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
} else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "Exit")) {
if (m->running_as == MANAGER_INIT)
return bus_send_error_reply(m, message, NULL, -ENOTSUP);
return bus_send_error_reply(m, connection, message, NULL, -ENOTSUP);
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
......@@ -623,7 +623,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
if (r == -ENOMEM)
goto oom;
return bus_send_error_reply(m, message, NULL, r);
return bus_send_error_reply(m, connection, message, NULL, r);
}
e = strv_env_merge(2, m->environment, l);
......@@ -647,7 +647,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
if (r == -ENOMEM)
goto oom;
return bus_send_error_reply(m, message, NULL, r);
return bus_send_error_reply(m, connection, message, NULL, r);
}
e = strv_env_delete(m->environment, 1, l);
......@@ -663,7 +663,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
m->environment = e;
} else
return bus_default_message_handler(m, message, NULL, properties);
return bus_default_message_handler(m, connection, message, NULL, properties);
if (job_type != _JOB_TYPE_INVALID) {
......@@ -678,19 +678,19 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
DBUS_TYPE_STRING, &name,
DBUS_TYPE_STRING, &smode,
DBUS_TYPE_INVALID))
return bus_send_error_reply(m, message, &error, -EINVAL);
return bus_send_error_reply(m, connection, message, &error, -EINVAL);
if ((mode = job_mode_from_string(smode)) == _JOB_MODE_INVALID)
return bus_send_error_reply(m, message, NULL, -EINVAL);
return bus_send_error_reply(m, connection, message, NULL, -EINVAL);
if ((r = manager_load_unit(m, name, NULL, &u)) < 0)
return bus_send_error_reply(m, message, NULL, r);
return bus_send_error_reply(m, connection, message, NULL, r);
if (job_type == JOB_START && u->meta.only_by_dependency)
return bus_send_error_reply(m, message, NULL, -EPERM);
return bus_send_error_reply(m, connection, message, NULL, -EPERM);
if ((r = manager_add_job(m, job_type, u, mode, true, &j)) < 0)
return bus_send_error_reply(m, message, NULL, r);
return bus_send_error_reply(m, connection, message, NULL, r);
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
......
......@@ -120,7 +120,7 @@ static int bus_mount_append_type(Manager *n, DBusMessageIter *i, const char *pro
return 0;
}
DBusHandlerResult bus_mount_message_handler(Unit *u, DBusMessage *message) {
DBusHandlerResult bus_mount_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
{ "org.freedesktop.systemd1.Mount", "Where", bus_property_append_string, "s", u->mount.where },
......@@ -135,5 +135,5 @@ DBusHandlerResult bus_mount_message_handler(Unit *u, DBusMessage *message) {
{ NULL, NULL, NULL, NULL, NULL }
};
return bus_default_message_handler(u->meta.manager, message, INTROSPECTION, properties);
return bus_default_message_handler(u->meta.manager, c, message, INTROSPECTION, properties);
}
......@@ -26,7 +26,7 @@
#include "unit.h"
DBusHandlerResult bus_mount_message_handler(Unit *u, DBusMessage *message);
DBusHandlerResult bus_mount_message_handler(Unit *u, DBusConnection *c, DBusMessage *message);
extern const char bus_mount_interface[];
......
......@@ -41,12 +41,12 @@
const char bus_path_interface[] = BUS_PATH_INTERFACE;
DBusHandlerResult bus_path_message_handler(Unit *u, DBusMessage *message) {
DBusHandlerResult bus_path_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
{ "org.freedesktop.systemd1.Path", "Unit", bus_property_append_string, "s", &u->path.unit->meta.id },
{ NULL, NULL, NULL, NULL, NULL }
};
return bus_default_message_handler(u->meta.manager, message, INTROSPECTION, properties);
return bus_default_message_handler(u->meta.manager, c, message, INTROSPECTION, properties);
}
......@@ -26,7 +26,7 @@
#include "unit.h"
DBusHandlerResult bus_path_message_handler(Unit *u, DBusMessage *message);
DBusHandlerResult bus_path_message_handler(Unit *u, DBusConnection *c, DBusMessage *message);
extern const char bus_path_interface[];
......
......@@ -58,7 +58,7 @@ const char bus_service_interface[] = BUS_SERVICE_INTERFACE;
static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_service_append_type, service_type, ServiceType);
static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_service_append_restart, service_restart, ServiceRestart);
DBusHandlerResult bus_service_message_handler(Unit *u, DBusMessage *message) {
DBusHandlerResult bus_service_message_handler(Unit *u, DBusConnection *connection, DBusMessage *message) {
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
{ "org.freedesktop.systemd1.Service", "Type", bus_service_append_type, "s", &u->service.type },
......@@ -81,5 +81,5 @@ DBusHandlerResult bus_service_message_handler(Unit *u, DBusMessage *message) {
{ NULL, NULL, NULL, NULL, NULL }
};
return bus_default_message_handler(u->meta.manager, message, INTROSPECTION, properties);
return bus_default_message_handler(u->meta.manager, connection, message, INTROSPECTION, properties);
}
......@@ -26,7 +26,7 @@
#include "unit.h"
DBusHandlerResult bus_service_message_handler(Unit *u, DBusMessage *message);
DBusHandlerResult bus_service_message_handler(Unit *u, DBusConnection *c, DBusMessage *message);
extern const char bus_service_interface[];
......
......@@ -39,7 +39,7 @@
const char bus_snapshot_interface[] = BUS_SNAPSHOT_INTERFACE;
DBusHandlerResult bus_snapshot_message_handler(Unit *u, DBusMessage *message) {
DBusHandlerResult bus_snapshot_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
{ "org.freedesktop.systemd1.Snapshot", "Cleanup", bus_property_append_bool, "b", &u->snapshot.cleanup },
......@@ -59,10 +59,10 @@ DBusHandlerResult bus_snapshot_message_handler(Unit *u, DBusMessage *message) {
goto oom;
} else
return bus_default_message_handler(u->meta.manager, message, INTROSPECTION, properties);
return bus_default_message_handler(u->meta.manager, c, message, INTROSPECTION, properties);
if (reply) {
if (!dbus_connection_send(u->meta.manager->api_bus, reply, NULL))
if (!dbus_connection_send(c, reply, NULL))
goto oom;
dbus_message_unref(reply);
......
......@@ -26,7 +26,7 @@
#include "unit.h"
DBusHandlerResult bus_snapshot_message_handler(Unit *u, DBusMessage *message);
DBusHandlerResult bus_snapshot_message_handler(Unit *u, DBusConnection *c, DBusMessage *message);
extern const char bus_snapshot_interface[];
......
......@@ -52,7 +52,7 @@ const char bus_socket_interface[] = BUS_SOCKET_INTERFACE;
static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_socket_append_bind_ipv6_only, socket_address_bind_ipv6_only, SocketAddressBindIPv6Only);
DBusHandlerResult bus_socket_message_handler(Unit *u, DBusMessage *message) {
DBusHandlerResult bus_socket_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
{ "org.freedesktop.systemd1.Socket", "BindIPv6Only", bus_socket_append_bind_ipv6_only, "s", &u->socket.bind_ipv6_only },
......@@ -69,5 +69,5 @@ DBusHandlerResult bus_socket_message_handler(Unit *u, DBusMessage *message) {
{ NULL, NULL, NULL, NULL, NULL }
};
return bus_default_message_handler(u->meta.manager, message, INTROSPECTION, properties);
return bus_default_message_handler(u->meta.manager, c, message, INTROSPECTION, properties);
}
......@@ -26,7 +26,7 @@
#include "unit.h"
DBusHandlerResult bus_socket_message_handler(Unit *u, DBusMessage *message);
DBusHandlerResult bus_socket_message_handler(Unit *u, DBusConnection *c, DBusMessage *message);
extern const char bus_socket_interface[];
......
......@@ -66,7 +66,7 @@ static int bus_swap_append_priority(Manager *m, DBusMessageIter *i, const char *
return 0;
}
DBusHandlerResult bus_swap_message_handler(Unit *u, DBusMessage *message) {
DBusHandlerResult bus_swap_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
{ "org.freedesktop.systemd1.Swap", "What", bus_property_append_string, "s", u->swap.what },
......@@ -74,5 +74,5 @@ DBusHandlerResult bus_swap_message_handler(Unit *u, DBusMessage *message) {
{ NULL, NULL, NULL, NULL, NULL }
};
return bus_default_message_handler(u->meta.manager, message, INTROSPECTION, properties);
return bus_default_message_handler(u->meta.manager, c, message, INTROSPECTION, properties);
}
......@@ -27,7 +27,7 @@
#include "unit.h"
DBusHandlerResult bus_swap_message_handler(Unit *u, DBusMessage *message);
DBusHandlerResult bus_swap_message_handler(Unit *u, DBusConnection *c, DBusMessage *message);
extern const char bus_swap_interface[];
......
......@@ -37,11 +37,11 @@
const char bus_target_interface[] = BUS_TARGET_INTERFACE;
DBusHandlerResult bus_target_message_handler(Unit *u, DBusMessage *message) {
DBusHandlerResult bus_target_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
{ NULL, NULL, NULL, NULL, NULL }
};
return bus_default_message_handler(u->meta.manager, message, INTROSPECTION, properties);
return bus_default_message_handler(u->meta.manager, c, message, INTROSPECTION, properties);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment