X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fdbus-manager.c;h=2235e3649635ddd62eaf2e9d30f221fbec8179fb;hb=6569cae18ed640a4e9f52f73e2a3ec54b07d0406;hp=e96929a55c502c422553814e5c63c285986eeff4;hpb=7c0987d8129e4761d24c21bbc2e5d39731a6b7f0;p=elogind.git
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index e96929a55..2235e3649 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" \
@@ -247,17 +257,7 @@
" \n" \
" \n" \
" \n" \
- " \n" \
- " \n"
-
-#ifdef HAVE_SYSV_COMPAT
-#define BUS_MANAGER_INTERFACE_PROPERTIES_SYSV \
- " \n" \
- " \n" \
- " \n"
-#else
-#define BUS_MANAGER_INTERFACE_PROPERTIES_SYSV
-#endif
+ " \n"
#define BUS_MANAGER_INTERFACE_END \
" \n"
@@ -267,7 +267,6 @@
BUS_MANAGER_INTERFACE_METHODS \
BUS_MANAGER_INTERFACE_SIGNALS \
BUS_MANAGER_INTERFACE_PROPERTIES_GENERAL \
- BUS_MANAGER_INTERFACE_PROPERTIES_SYSV \
BUS_MANAGER_INTERFACE_END
#define INTROSPECTION_BEGIN \
@@ -505,20 +504,6 @@ static int bus_manager_send_unit_files_changed(Manager *m) {
return r;
}
-static int bus_manager_append_have_watchdog(DBusMessageIter *i, const char *property, void *data) {
- dbus_bool_t b;
-
- assert(i);
- assert(property);
-
- b = access("/dev/watchdog", F_OK) >= 0;
-
- if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &b))
- return -ENOMEM;
-
- return 0;
-}
-
static int bus_manager_set_runtime_watchdog_usec(DBusMessageIter *i, const char *property, void *data) {
uint64_t *t = data;
@@ -544,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 },
@@ -567,12 +558,6 @@ static const BusProperty bus_manager_properties[] = {
{ "DefaultStandardError", bus_manager_append_exec_output, "s", offsetof(Manager, default_std_error) },
{ "RuntimeWatchdogUSec", bus_property_append_usec, "t", offsetof(Manager, runtime_watchdog), false, bus_manager_set_runtime_watchdog_usec },
{ "ShutdownWatchdogUSec", bus_property_append_usec, "t", offsetof(Manager, shutdown_watchdog), false, bus_property_set_usec },
- { "HaveWatchdog", bus_manager_append_have_watchdog, "b", 0 },
-#ifdef HAVE_SYSV_COMPAT
- { "SysVConsole", bus_property_append_bool, "b", offsetof(Manager, sysv_console) },
- { "SysVInitPath", bus_property_append_strv, "as", offsetof(Manager, lookup_paths.sysvinit_path), true },
- { "SysVRcndPath", bus_property_append_strv, "as", offsetof(Manager, lookup_paths.sysvrcnd_path), true },
-#endif
{ NULL, }
};
@@ -594,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;
@@ -694,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(
@@ -705,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);
@@ -718,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)))
@@ -1208,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;
@@ -1587,6 +1567,11 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
job_type = JOB_RELOAD;
}
+ if (job_type == JOB_STOP && u->load_state == UNIT_ERROR && unit_active_state(u) == UNIT_INACTIVE) {
+ dbus_set_error(&error, BUS_ERROR_NO_SUCH_UNIT, "Unit %s not loaded.", name);
+ return bus_send_error_reply(connection, message, &error, -EPERM);
+ }
+
if ((job_type == JOB_START && u->refuse_manual_start) ||
(job_type == JOB_STOP && u->refuse_manual_stop) ||
((job_type == JOB_RESTART || job_type == JOB_TRY_RESTART) &&