X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fdbus-manager.c;h=7a06ca64929c0986c35ecbf265dc7a8930ad0497;hb=ec8927ca5940e809f0b72f530582c76f1db4f065;hp=770fce12099e7a7808801553a629892da26a2bd0;hpb=8d8e945624a0080073d94941f3032b8fa3b3aa15;p=elogind.git diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c index 770fce120..7a06ca649 100644 --- a/src/core/dbus-manager.c +++ b/src/core/dbus-manager.c @@ -31,6 +31,8 @@ #include "dbus-common.h" #include "install.h" #include "watchdog.h" +#include "hwclock.h" +#include "path-util.h" #define BUS_MANAGER_INTERFACE_BEGIN \ " \n" @@ -125,6 +127,10 @@ " \n" \ " \n" \ " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ " \n" \ " \n" \ " \n" \ @@ -198,10 +204,12 @@ " \n" \ " \n" \ " \n" \ + " \n" \ " \n" \ " \n" \ " \n" \ " \n" \ + " \n" \ " \n" \ " " \ " \n" \ @@ -294,17 +302,24 @@ static int bus_manager_append_tainted(DBusMessageIter *i, const char *property, assert(m); if (m->taint_usr) - e = stpcpy(e, "usr-separate-fs "); + e = stpcpy(e, "split-usr:"); if (readlink_malloc("/etc/mtab", &p) < 0) - e = stpcpy(e, "etc-mtab-not-symlink "); + e = stpcpy(e, "mtab-not-symlink:"); else free(p); if (access("/proc/cgroups", F_OK) < 0) - stpcpy(e, "cgroups-missing "); + e = stpcpy(e, "cgroups-missing:"); + + if (hwclock_is_localtime() > 0) + e = stpcpy(e, "local-hwclock:"); + + /* remove the last ':' */ + if (e != buf) + e[-1] = 0; - t = strstrip(buf); + t = buf; if (!dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &t)) return -ENOMEM; @@ -1168,6 +1183,70 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, m->exit_code = MANAGER_KEXEC; + } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "SwitchRoot")) { + const char *switch_root, *switch_root_init; + char *u, *v; + int k; + + if (!dbus_message_get_args( + message, + &error, + DBUS_TYPE_STRING, &switch_root, + DBUS_TYPE_STRING, &switch_root_init, + DBUS_TYPE_INVALID)) + return bus_send_error_reply(connection, message, &error, -EINVAL); + + if (path_equal(switch_root, "/") || !path_is_absolute(switch_root)) + return bus_send_error_reply(connection, message, NULL, -EINVAL); + + 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) { + 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); + } + + /* Safety check */ + if (isempty(switch_root_init)) + k = access(switch_root, F_OK); + else { + char *p; + + p = join(switch_root, "/", switch_root_init, NULL); + if (!p) + goto oom; + + k = access(p, X_OK); + free(p); + } + if (k < 0) + return bus_send_error_reply(connection, message, NULL, -errno); + + u = strdup(switch_root); + if (!u) + goto oom; + + if (!isempty(switch_root_init)) { + v = strdup(switch_root_init); + if (!v) { + free(u); + goto oom; + } + } else + v = NULL; + + free(m->switch_root); + free(m->switch_root_init); + m->switch_root = u; + m->switch_root_init = v; + + reply = dbus_message_new_method_return(message); + if (!reply) + goto oom; + + m->exit_code = MANAGER_SWITCH_ROOT; + } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "SetEnvironment")) { char **l = NULL, **e = NULL;