X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fdbus-manager.c;h=4bed5c88459641b0a7f263da8ceb47807d98b1a8;hb=a17204af0e950be7a5199db62ef400814e29aa3c;hp=9776b0b9decb73924d8693537075ad5598771996;hpb=a133bf10d09f788079b82f63faa7058a27ba310b;p=elogind.git diff --git a/src/dbus-manager.c b/src/dbus-manager.c index 9776b0b9d..4bed5c884 100644 --- a/src/dbus-manager.c +++ b/src/dbus-manager.c @@ -128,6 +128,10 @@ " \n" \ " \n" \ " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ " \n" #define BUS_MANAGER_INTERFACE_SIGNALS \ @@ -147,6 +151,12 @@ " \n" \ " \n" \ " \n" \ + " " \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ " " #define BUS_MANAGER_INTERFACE_PROPERTIES_GENERAL \ @@ -532,10 +542,23 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, DBUS_TYPE_INVALID)) return bus_send_error_reply(connection, message, &error, -EINVAL); - if ((mode = kill_mode_from_string(smode)) < 0 || - (who = kill_who_from_string(swho)) < 0 || - signo <= 0 || - signo >= _NSIG) + if (isempty(swho)) + who = KILL_ALL; + else { + who = kill_who_from_string(swho); + if (who < 0) + 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))) { @@ -922,8 +945,8 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "Reexecute")) { - if (!(reply = dbus_message_new_method_return(message))) - goto oom; + /* We don't send a reply back here, the client should + * just wait for us disconnecting. */ m->exit_code = MANAGER_REEXECUTE; @@ -1035,6 +1058,58 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, strv_free(m->environment); m->environment = e; + } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "UnsetAndSetEnvironment")) { + char **l_set = NULL, **l_unset = NULL, **e = NULL, **f = NULL; + DBusMessageIter iter; + + if (!dbus_message_iter_init(message, &iter)) + return bus_send_error_reply(connection, message, NULL, -EINVAL); + + r = bus_parse_strv_iter(&iter, &l_unset); + if (r < 0) { + if (r == -ENOMEM) + goto oom; + + return bus_send_error_reply(connection, message, NULL, r); + } + + if (!dbus_message_iter_next(&iter)) { + strv_free(l_unset); + return bus_send_error_reply(connection, message, NULL, -EINVAL); + } + + r = bus_parse_strv_iter(&iter, &l_set); + if (r < 0) { + strv_free(l_unset); + if (r == -ENOMEM) + goto oom; + + return bus_send_error_reply(connection, message, NULL, r); + } + + e = strv_env_delete(m->environment, 1, l_unset); + strv_free(l_unset); + + if (!e) { + strv_free(l_set); + goto oom; + } + + f = strv_env_merge(2, e, l_set); + strv_free(l_set); + strv_free(e); + + if (!f) + goto oom; + + if (!(reply = dbus_message_new_method_return(message))) { + strv_free(f); + goto oom; + } + + strv_free(m->environment); + m->environment = f; + } else return bus_default_message_handler(connection, message, NULL, INTERFACES_LIST, properties);