X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcore%2Fdbus-manager.c;h=276ad6c634a24e5a570ece53cc5e4d8bff668f6b;hp=cd827ca458ddbcbd16a6ce6c5e0517f71addd5fd;hb=67445f4e22ad924394acdd4fd49e6f238244a5ca;hpb=2aac569ab4f7fa21cf634f5a82c1c7d69381ab25 diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c index cd827ca45..276ad6c63 100644 --- a/src/core/dbus-manager.c +++ b/src/core/dbus-manager.c @@ -30,6 +30,7 @@ #include "build.h" #include "dbus-common.h" #include "install.h" +#include "selinux-access.h" #include "watchdog.h" #include "hwclock.h" #include "path-util.h" @@ -94,7 +95,6 @@ " \n" \ " \n" \ " \n" \ - " \n" \ " \n" \ " \n" \ " \n" \ @@ -114,7 +114,9 @@ " \n" \ " \n" \ " \n" \ - " \n" \ + " \n" \ + " \n" \ + " \n" \ " \n" \ " \n" \ " \n" \ @@ -142,7 +144,7 @@ " \n" \ " \n" \ " \n" \ - " \n" \ + " \n" \ " \n" \ " \n" \ " \n" \ @@ -213,6 +215,8 @@ " \n" \ " " \ " \n" \ + " \n" \ + " \n" \ " \n" \ " \n" \ " \n" \ @@ -225,10 +229,16 @@ " \n" \ " \n" \ " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ " \n" \ " \n" \ - " \n" \ - " \n" \ + " \n" \ + " \n" \ " \n" \ " \n" \ " \n" \ @@ -519,10 +529,16 @@ static const BusProperty bus_systemd_properties[] = { static const BusProperty bus_manager_properties[] = { { "Tainted", bus_manager_append_tainted, "s", 0 }, + { "FirmwareTimestamp", bus_property_append_uint64, "t", offsetof(Manager, firmware_timestamp.realtime) }, + { "FirmwareTimestampMonotonic", bus_property_append_uint64,"t", offsetof(Manager, firmware_timestamp.monotonic)}, + { "LoaderTimestamp", bus_property_append_uint64, "t", offsetof(Manager, loader_timestamp.realtime) }, + { "LoaderTimestampMonotonic", bus_property_append_uint64, "t", offsetof(Manager, loader_timestamp.monotonic) }, + { "KernelTimestamp", bus_property_append_uint64, "t", offsetof(Manager, kernel_timestamp.realtime) }, + { "KernelTimestampMonotonic", bus_property_append_uint64, "t", offsetof(Manager, kernel_timestamp.monotonic) }, { "InitRDTimestamp", bus_property_append_uint64, "t", offsetof(Manager, initrd_timestamp.realtime) }, { "InitRDTimestampMonotonic", bus_property_append_uint64, "t", offsetof(Manager, initrd_timestamp.monotonic) }, - { "StartupTimestamp", bus_property_append_uint64, "t", offsetof(Manager, startup_timestamp.realtime) }, - { "StartupTimestampMonotonic", bus_property_append_uint64, "t", offsetof(Manager, startup_timestamp.monotonic) }, + { "UserspaceTimestamp", bus_property_append_uint64, "t", offsetof(Manager, userspace_timestamp.realtime)}, + { "UserspaceTimestampMonotonic", bus_property_append_uint64,"t",offsetof(Manager, userspace_timestamp.monotonic)}, { "FinishTimestamp", bus_property_append_uint64, "t", offsetof(Manager, finish_timestamp.realtime) }, { "FinishTimestampMonotonic", bus_property_append_uint64, "t", offsetof(Manager, finish_timestamp.monotonic) }, { "LogLevel", bus_manager_append_log_level, "s", 0, false, bus_manager_set_log_level }, @@ -563,6 +579,9 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, dbus_error_init(&error); member = dbus_message_get_member(message); + r = selinux_manager_access_check(connection, message, m, &error); + if (r < 0) + return bus_send_error_reply(connection, message, &error, r); if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "GetUnit")) { const char *name; @@ -663,10 +682,9 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, reload_if_possible = true; job_type = JOB_TRY_RESTART; } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "KillUnit")) { - const char *name, *swho, *smode; + const char *name, *swho; int32_t signo; Unit *u; - KillMode mode; KillWho who; if (!dbus_message_get_args( @@ -674,7 +692,6 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, &error, DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &swho, - DBUS_TYPE_STRING, &smode, DBUS_TYPE_INT32, &signo, DBUS_TYPE_INVALID)) return bus_send_error_reply(connection, message, &error, -EINVAL); @@ -687,23 +704,17 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, return bus_send_error_reply(connection, message, &error, -EINVAL); } - if (isempty(smode)) - mode = KILL_CONTROL_GROUP; - else { - mode = kill_mode_from_string(smode); - if (mode < 0) - return bus_send_error_reply(connection, message, &error, -EINVAL); - } - if (signo <= 0 || signo >= _NSIG) return bus_send_error_reply(connection, message, &error, -EINVAL); - if (!(u = manager_get_unit(m, name))) { + u = manager_get_unit(m, name); + if (!u) { dbus_set_error(&error, BUS_ERROR_NO_SUCH_UNIT, "Unit %s is not loaded.", name); return bus_send_error_reply(connection, message, &error, -ENOENT); } - if ((r = unit_kill(u, who, mode, signo, &error)) < 0) + r = unit_kill(u, who, signo, &error); + if (r < 0) return bus_send_error_reply(connection, message, &error, r); if (!(reply = dbus_message_new_method_return(message))) @@ -1089,7 +1100,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_SYSTEM) { + if (m->running_as == SYSTEMD_SYSTEM) { dbus_set_error(&error, BUS_ERROR_NOT_SUPPORTED, "Exit is only supported for user service managers."); return bus_send_error_reply(connection, message, &error, -ENOTSUP); } @@ -1101,7 +1112,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "Reboot")) { - if (m->running_as != MANAGER_SYSTEM) { + if (m->running_as != SYSTEMD_SYSTEM) { dbus_set_error(&error, BUS_ERROR_NOT_SUPPORTED, "Reboot is only supported for system managers."); return bus_send_error_reply(connection, message, &error, -ENOTSUP); } @@ -1113,7 +1124,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "PowerOff")) { - if (m->running_as != MANAGER_SYSTEM) { + if (m->running_as != SYSTEMD_SYSTEM) { dbus_set_error(&error, BUS_ERROR_NOT_SUPPORTED, "Powering off is only supported for system managers."); return bus_send_error_reply(connection, message, &error, -ENOTSUP); } @@ -1125,7 +1136,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "Halt")) { - if (m->running_as != MANAGER_SYSTEM) { + if (m->running_as != SYSTEMD_SYSTEM) { dbus_set_error(&error, BUS_ERROR_NOT_SUPPORTED, "Halting is only supported for system managers."); return bus_send_error_reply(connection, message, &error, -ENOTSUP); } @@ -1137,7 +1148,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "KExec")) { - if (m->running_as != MANAGER_SYSTEM) { + if (m->running_as != SYSTEMD_SYSTEM) { dbus_set_error(&error, BUS_ERROR_NOT_SUPPORTED, "kexec is only supported for system managers."); return bus_send_error_reply(connection, message, &error, -ENOTSUP); } @@ -1166,7 +1177,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, if (!isempty(switch_root_init) && !path_is_absolute(switch_root_init)) return bus_send_error_reply(connection, message, NULL, -EINVAL); - if (m->running_as != MANAGER_SYSTEM) { + if (m->running_as != SYSTEMD_SYSTEM) { dbus_set_error(&error, BUS_ERROR_NOT_SUPPORTED, "Switching root is only supported for system managers."); return bus_send_error_reply(connection, message, &error, -ENOTSUP); } @@ -1177,7 +1188,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, else { char *p; - p = join(switch_root, "/", switch_root_init, NULL); + p = strjoin(switch_root, "/", switch_root_init, NULL); if (!p) goto oom; @@ -1324,7 +1335,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, if (!h) goto oom; - r = unit_file_get_list(m->running_as == MANAGER_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER, NULL, h); + r = unit_file_get_list(m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER, NULL, h); if (r < 0) { unit_file_list_free(h); dbus_message_unref(reply); @@ -1370,7 +1381,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, DBUS_TYPE_INVALID)) return bus_send_error_reply(connection, message, &error, -EINVAL); - state = unit_file_get_state(m->running_as == MANAGER_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER, NULL, name); + state = unit_file_get_state(m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER, NULL, name); if (state < 0) return bus_send_error_reply(connection, message, NULL, state); @@ -1394,7 +1405,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, char **l = NULL; DBusMessageIter iter; - UnitFileScope scope = m->running_as == MANAGER_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER; + UnitFileScope scope = m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER; UnitFileChange *changes = NULL; unsigned n_changes = 0; dbus_bool_t runtime, force; @@ -1453,7 +1464,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, char **l = NULL; DBusMessageIter iter; - UnitFileScope scope = m->running_as == MANAGER_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER; + UnitFileScope scope = m->running_as == SYSTEMD_SYSTEM ? UNIT_FILE_SYSTEM : UNIT_FILE_USER; UnitFileChange *changes = NULL; unsigned n_changes = 0; dbus_bool_t runtime;