dbus-scope.c revision 283868e1dcd8ea7475850d9c6e7d4722c473dd50
e2417e4143bb892e4599b01de7b031763421bb64Daniel J Walsh/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
e2417e4143bb892e4599b01de7b031763421bb64Daniel J Walsh This file is part of systemd.
e2417e4143bb892e4599b01de7b031763421bb64Daniel J Walsh Copyright 2013 Lennart Poettering
e2417e4143bb892e4599b01de7b031763421bb64Daniel J Walsh systemd is free software; you can redistribute it and/or modify it
e2417e4143bb892e4599b01de7b031763421bb64Daniel J Walsh under the terms of the GNU Lesser General Public License as published by
e2417e4143bb892e4599b01de7b031763421bb64Daniel J Walsh the Free Software Foundation; either version 2.1 of the License, or
03e22642617f360a6b55cb853bcf59604754ea5dKay Sievers (at your option) any later version.
e2417e4143bb892e4599b01de7b031763421bb64Daniel J Walsh systemd is distributed in the hope that it will be useful, but
e2417e4143bb892e4599b01de7b031763421bb64Daniel J Walsh WITHOUT ANY WARRANTY; without even the implied warranty of
e2417e4143bb892e4599b01de7b031763421bb64Daniel J Walsh MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e2417e4143bb892e4599b01de7b031763421bb64Daniel J Walsh Lesser General Public License for more details.
03e22642617f360a6b55cb853bcf59604754ea5dKay Sievers You should have received a copy of the GNU Lesser General Public License
e2417e4143bb892e4599b01de7b031763421bb64Daniel J Walsh along with systemd; If not, see <http://www.gnu.org/licenses/>.
cad45ba11ec3572296361f53f5852ffb97a97fa3Lennart Poetteringstatic int bus_scope_abandon(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
cad45ba11ec3572296361f53f5852ffb97a97fa3Lennart Poettering r = bus_verify_manage_unit_async(UNIT(s)->manager, message, error);
718db96199eb307751264e4163555662c9a389faLennart Poettering return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
718db96199eb307751264e4163555662c9a389faLennart Poettering return sd_bus_error_setf(error, BUS_ERROR_SCOPE_NOT_RUNNING, "Scope %s is not running, cannot abandon.", UNIT(s)->id);
718db96199eb307751264e4163555662c9a389faLennart Poettering return sd_bus_reply_method_return(message, NULL);
cad45ba11ec3572296361f53f5852ffb97a97fa3Lennart Poetteringstatic BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, scope_result, ScopeResult);
718db96199eb307751264e4163555662c9a389faLennart Poetteringconst sd_bus_vtable bus_scope_vtable[] = {
cad45ba11ec3572296361f53f5852ffb97a97fa3Lennart Poettering SD_BUS_PROPERTY("Controller", "s", NULL, offsetof(Scope, controller), SD_BUS_VTABLE_PROPERTY_CONST),
e2417e4143bb892e4599b01de7b031763421bb64Daniel J Walsh SD_BUS_PROPERTY("TimeoutStopUSec", "t", bus_property_get_usec, offsetof(Scope, timeout_stop_usec), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("Result", "s", property_get_result, offsetof(Scope, result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
static int bus_scope_set_transient_property(
Scope *s,
const char *name,
assert(s);
return -EINVAL;
if (r < 0 && r != -EEXIST)
return -EINVAL;
const char *controller;
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Controller '%s' is not a valid bus name.", controller);
c = NULL;
return -ENOMEM;
s->controller = c;
unit_write_drop_in_format(UNIT(s), mode, name, "[Scope]\nTimeoutStopSec="USEC_FMT"us\n", s->timeout_stop_usec);
Unit *u,
const char *name,
assert(s);
assert(u);
assert(s);
if (!s->controller)
return -ENOMEM;
"org.freedesktop.systemd1.Scope",