X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=dbus-manager.c;h=90ab8d1a0cab509b1d78270191962a65bf0a8842;hp=47fb403f11b1d2521c55ed59e9b83c3003c852e9;hb=67ef7823c651015929d4f20e4c9d59998c5bac7d;hpb=4f0f902fc8837999e5c9f3a6f7e2592cc6f096eb diff --git a/dbus-manager.c b/dbus-manager.c index 47fb403f1..90ab8d1a0 100644 --- a/dbus-manager.c +++ b/dbus-manager.c @@ -24,6 +24,7 @@ #include "dbus.h" #include "log.h" #include "dbus-manager.h" +#include "strv.h" #define INTROSPECTION_BEGIN \ DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \ @@ -59,6 +60,12 @@ " " \ " " \ " " \ + " " \ + " " \ + " " \ + " " \ + " " \ + " " \ " " \ " " \ " " \ @@ -82,6 +89,7 @@ " " \ " " \ " " \ + " " \ " " \ BUS_PROPERTIES_INTERFACE \ BUS_INTROSPECTABLE_INTERFACE @@ -162,6 +170,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection { "org.freedesktop.systemd1.Manager", "LogTarget", bus_manager_append_log_target, "s", NULL }, { "org.freedesktop.systemd1.Manager", "NNames", bus_manager_append_n_names, "u", NULL }, { "org.freedesktop.systemd1.Manager", "NJobs", bus_manager_append_n_jobs, "u", NULL }, + { "org.freedesktop.systemd1.Manager", "Environment", bus_property_append_strv, "as", m->environment }, { NULL, NULL, NULL, NULL, NULL } }; @@ -572,6 +581,52 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection m->exit_code = MANAGER_EXIT; + } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "SetEnvironment")) { + char **l = NULL, **e = NULL; + + if ((r = bus_parse_strv(message, &l)) < 0) { + if (r == -ENOMEM) + goto oom; + + return bus_send_error_reply(m, message, NULL, r); + } + + e = strv_env_merge(m->environment, l, NULL); + strv_free(l); + + if (!e) + goto oom; + + if (!(reply = dbus_message_new_method_return(message))) { + strv_free(e); + goto oom; + } + + strv_free(m->environment); + m->environment = e; + + } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "UnsetEnvironment")) { + char **l = NULL, **e = NULL; + + if ((r = bus_parse_strv(message, &l)) < 0) { + if (r == -ENOMEM) + goto oom; + + return bus_send_error_reply(m, message, NULL, r); + } + + e = strv_env_delete(m->environment, l, NULL); + strv_free(l); + + if (!e) + goto oom; + + if (!(reply = dbus_message_new_method_return(message))) + goto oom; + + strv_free(m->environment); + m->environment = e; + } else return bus_default_message_handler(m, message, NULL, properties);