dbus-scope.c revision 96aad8d15a324d0e956a4e5653a11a67b209b41a
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/***
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering This file is part of systemd.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Copyright 2013 Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is free software; you can redistribute it and/or modify it
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering under the terms of the GNU Lesser General Public License as published by
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering (at your option) any later version.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is distributed in the hope that it will be useful, but
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Lesser General Public License for more details.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering You should have received a copy of the GNU Lesser General Public License
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering***/
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#include "unit.h"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#include "scope.h"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#include "dbus-unit.h"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#include "dbus-cgroup.h"
50f1e641a93cacfc693b0c3d300bee5df0c8c460Tom Gundersen#include "dbus-kill.h"
71d35b6b5563817dfbe757ab9e3b9f018b2db491Thomas Hindoe Paaboel Andersen#include "dbus-scope.h"
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering#include "dbus.h"
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poettering#include "bus-util.h"
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering#include "bus-internal.h"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#include "bus-common-errors.h"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstatic int bus_scope_abandon(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering Scope *s = userdata;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering int r;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering assert(bus);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering assert(message);
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering assert(s);
b93312f5960b276bae915906ccde36f545bae3e0Zbigniew Jędrzejewski-Szmek
b93312f5960b276bae915906ccde36f545bae3e0Zbigniew Jędrzejewski-Szmek r = bus_verify_manage_unit_async(UNIT(s)->manager, message, error);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if (r < 0)
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering return r;
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering if (r == 0)
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering r = scope_abandon(s);
23502de3b0891455c8ce499a9eb61b69d060a829Daniel Mack if (sd_bus_error_is_set(error))
23502de3b0891455c8ce499a9eb61b69d060a829Daniel Mack return r;
23502de3b0891455c8ce499a9eb61b69d060a829Daniel Mack
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering if (r == -ESTALE)
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering return sd_bus_error_setf(error, BUS_ERROR_SCOPE_NOT_RUNNING, "Scope %s is not running, cannot abandon.", UNIT(s)->id);
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering return sd_bus_reply_method_return(message, NULL);
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering}
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poetteringstatic BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, scope_result, ScopeResult);
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poetteringconst sd_bus_vtable bus_scope_vtable[] = {
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering SD_BUS_VTABLE_START(0),
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering SD_BUS_PROPERTY("Controller", "s", NULL, offsetof(Scope, controller), SD_BUS_VTABLE_PROPERTY_CONST),
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering SD_BUS_PROPERTY("TimeoutStopUSec", "t", bus_property_get_usec, offsetof(Scope, timeout_stop_usec), SD_BUS_VTABLE_PROPERTY_CONST),
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering SD_BUS_PROPERTY("Result", "s", property_get_result, offsetof(Scope, result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering SD_BUS_SIGNAL("RequestStop", NULL, 0),
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering SD_BUS_METHOD("Abandon", NULL, NULL, bus_scope_abandon, 0),
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering SD_BUS_VTABLE_END
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering};
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poetteringstatic int bus_scope_set_transient_property(
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering Scope *s,
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering const char *name,
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering sd_bus_message *message,
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering UnitSetPropertiesMode mode,
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering sd_bus_error *error) {
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering int r;
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering assert(s);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering assert(name);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering assert(message);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
23502de3b0891455c8ce499a9eb61b69d060a829Daniel Mack if (streq(name, "PIDs")) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering unsigned n = 0;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering uint32_t pid;
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering r = sd_bus_message_enter_container(message, 'a', "u");
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering if (r < 0)
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering return r;
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering while ((r = sd_bus_message_read(message, "u", &pid)) > 0) {
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering if (pid <= 1)
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering return -EINVAL;
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering if (mode != UNIT_CHECK) {
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering r = unit_watch_pid(UNIT(s), pid);
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering if (r < 0 && r != -EEXIST)
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering return r;
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering }
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering n++;
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering }
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering if (r < 0)
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering return r;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering r = sd_bus_message_exit_container(message);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if (r < 0)
a8812dd7f161a3e459c1730ac92ff2bbc9986ff1Lennart Poettering return r;
a8812dd7f161a3e459c1730ac92ff2bbc9986ff1Lennart Poettering
a8812dd7f161a3e459c1730ac92ff2bbc9986ff1Lennart Poettering if (n <= 0)
a8812dd7f161a3e459c1730ac92ff2bbc9986ff1Lennart Poettering return -EINVAL;
a8812dd7f161a3e459c1730ac92ff2bbc9986ff1Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering return 1;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering } else if (streq(name, "Controller")) {
f5430a3ef308f3a102899fcaf7fbece757082f2aLennart Poettering const char *controller;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering char *c;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
9c92ce6d67f88beb31dd6555d12ae3f632218a39Lennart Poettering r = sd_bus_message_read(message, "s", &controller);
9c92ce6d67f88beb31dd6555d12ae3f632218a39Lennart Poettering if (r < 0)
9c92ce6d67f88beb31dd6555d12ae3f632218a39Lennart Poettering return r;
9c92ce6d67f88beb31dd6555d12ae3f632218a39Lennart Poettering
9c92ce6d67f88beb31dd6555d12ae3f632218a39Lennart Poettering if (!isempty(controller) && !service_name_is_valid(controller))
9c92ce6d67f88beb31dd6555d12ae3f632218a39Lennart Poettering return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Controller '%s' is not a valid bus name.", controller);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if (mode != UNIT_CHECK) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if (isempty(controller))
8ac4e9e1e54397f6d1745c2a7a806132418c7da2Lennart Poettering c = NULL;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering else {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering c = strdup(controller);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if (!c)
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering return -ENOMEM;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering }
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
2e276efc7b0398a3086629a52970bdd4ab7252f9Zbigniew Jędrzejewski-Szmek free(s->controller);
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering s->controller = c;
c0eb11cfd016381fe02875a4ef29c1ade00c94e7Lennart Poettering }
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering return 1;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering } else if (streq(name, "TimeoutStopUSec")) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if (mode != UNIT_CHECK) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering r = sd_bus_message_read(message, "t", &s->timeout_stop_usec);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if (r < 0)
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering return r;
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering unit_write_drop_in_format(UNIT(s), mode, name, "[Scope]\nTimeoutStopSec="USEC_FMT"us\n", s->timeout_stop_usec);
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering } else {
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering r = sd_bus_message_skip(message, "t");
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering if (r < 0)
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering return r;
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering }
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering return 1;
946c70944ebdf428ffeb9991a7449edbd4011461Zbigniew Jędrzejewski-Szmek }
946c70944ebdf428ffeb9991a7449edbd4011461Zbigniew Jędrzejewski-Szmek
946c70944ebdf428ffeb9991a7449edbd4011461Zbigniew Jędrzejewski-Szmek return 0;
946c70944ebdf428ffeb9991a7449edbd4011461Zbigniew Jędrzejewski-Szmek}
946c70944ebdf428ffeb9991a7449edbd4011461Zbigniew Jędrzejewski-Szmek
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmekint bus_scope_set_property(
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek Unit *u,
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek const char *name,
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek sd_bus_message *message,
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek UnitSetPropertiesMode mode,
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek sd_bus_error *error) {
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek Scope *s = SCOPE(u);
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek int r;
0dae31d468b1a0e22d98921f7b0dbd92fd217167Zbigniew Jędrzejewski-Szmek
42cc2eebb01056beb7acd3ecfe8e533558237f84Lennart Poettering assert(s);
abf126a355e2f2b62b6c51ab3bb37895d1e3eee7Tom Gundersen assert(name);
abf126a355e2f2b62b6c51ab3bb37895d1e3eee7Tom Gundersen assert(message);
abf126a355e2f2b62b6c51ab3bb37895d1e3eee7Tom Gundersen
abf126a355e2f2b62b6c51ab3bb37895d1e3eee7Tom Gundersen r = bus_cgroup_set_property(u, &s->cgroup_context, name, message, mode, error);
abf126a355e2f2b62b6c51ab3bb37895d1e3eee7Tom Gundersen if (r != 0)
abf126a355e2f2b62b6c51ab3bb37895d1e3eee7Tom Gundersen return r;
abf126a355e2f2b62b6c51ab3bb37895d1e3eee7Tom Gundersen
abf126a355e2f2b62b6c51ab3bb37895d1e3eee7Tom Gundersen if (u->load_state == UNIT_STUB) {
549c1a2564b56f2bb38f1203d59c747ea15817f3Tom Gundersen /* While we are created we still accept PIDs */
42cc2eebb01056beb7acd3ecfe8e533558237f84Lennart Poettering
42cc2eebb01056beb7acd3ecfe8e533558237f84Lennart Poettering r = bus_scope_set_transient_property(s, name, message, mode, error);
42cc2eebb01056beb7acd3ecfe8e533558237f84Lennart Poettering if (r != 0)
549c1a2564b56f2bb38f1203d59c747ea15817f3Tom Gundersen return r;
549c1a2564b56f2bb38f1203d59c747ea15817f3Tom Gundersen
42cc2eebb01056beb7acd3ecfe8e533558237f84Lennart Poettering r = bus_kill_context_set_transient_property(u, &s->kill_context, name, message, mode, error);
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek if (r != 0)
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek return r;
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek }
f91dc2400dc33e9a0745ecaaef7489af116dca38Lennart Poettering
f91dc2400dc33e9a0745ecaaef7489af116dca38Lennart Poettering return 0;
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek}
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmekint bus_scope_commit_properties(Unit *u) {
8db0d2f5c37e7e8f5bfce016cfdad7947a3ea939Zbigniew Jędrzejewski-Szmek assert(u);
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek unit_update_cgroup_members_masks(u);
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek unit_realize_cgroup(u);
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek return 0;
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek}
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmekint bus_scope_send_request_stop(Scope *s) {
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek _cleanup_free_ char *p = NULL;
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek int r;
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek assert(s);
151226ab4bf276d60d51864330a99f886b923697Zbigniew Jędrzejewski-Szmek
50f1e641a93cacfc693b0c3d300bee5df0c8c460Tom Gundersen if (!s->controller)
9ead3519c54b6d1b79b35541873b5cf7c8b3a7d3Lennart Poettering return 0;
50f1e641a93cacfc693b0c3d300bee5df0c8c460Tom Gundersen
50f1e641a93cacfc693b0c3d300bee5df0c8c460Tom Gundersen p = unit_dbus_path(UNIT(s));
50f1e641a93cacfc693b0c3d300bee5df0c8c460Tom Gundersen if (!p)
50f1e641a93cacfc693b0c3d300bee5df0c8c460Tom Gundersen return -ENOMEM;
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen r = sd_bus_message_new_signal(
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen UNIT(s)->manager->api_bus,
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen &m,
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen p,
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen "org.freedesktop.systemd1.Scope",
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen "RequestStop");
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen if (r < 0)
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen return r;
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen
5d45a8808431987c370706d365fb0cc95cf03d52Tom Gundersen return sd_bus_send_to(UNIT(s)->manager->api_bus, m, /* s->controller */ NULL, NULL);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering}
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering