dbus-snapshot.c revision 1d22e9068c52c1cf935bcdff70b9b9654e3c939e
97a9a944b5887e91042b019776c41d5dd74557aferikabele/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
97a9a944b5887e91042b019776c41d5dd74557aferikabele
97a9a944b5887e91042b019776c41d5dd74557aferikabele/***
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive This file is part of systemd.
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive
a945f35eff8b6a88009ce73de6d4c862ce58de3cslive Copyright 2010 Lennart Poettering
b686b6a420bde7f78c416b90be11db94cb789979nd
b686b6a420bde7f78c416b90be11db94cb789979nd systemd is free software; you can redistribute it and/or modify it
b686b6a420bde7f78c416b90be11db94cb789979nd under the terms of the GNU Lesser General Public License as published by
b686b6a420bde7f78c416b90be11db94cb789979nd the Free Software Foundation; either version 2.1 of the License, or
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen (at your option) any later version.
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen systemd is distributed in the hope that it will be useful, but
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen WITHOUT ANY WARRANTY; without even the implied warranty of
b686b6a420bde7f78c416b90be11db94cb789979nd MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b686b6a420bde7f78c416b90be11db94cb789979nd Lesser General Public License for more details.
b686b6a420bde7f78c416b90be11db94cb789979nd
d229f940abfb2490dee17979e9a5ff31b7012eb5rbowen You should have received a copy of the GNU Lesser General Public License
3f08db06526d6901aa08c110b5bc7dde6bc39905nd along with systemd; If not, see <http://www.gnu.org/licenses/>.
b686b6a420bde7f78c416b90be11db94cb789979nd***/
b686b6a420bde7f78c416b90be11db94cb789979nd
b686b6a420bde7f78c416b90be11db94cb789979nd#include "selinux-access.h"
3f08db06526d6901aa08c110b5bc7dde6bc39905nd#include "unit.h"
b686b6a420bde7f78c416b90be11db94cb789979nd#include "dbus.h"
b686b6a420bde7f78c416b90be11db94cb789979nd#include "snapshot.h"
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd#include "dbus-unit.h"
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd#include "dbus-snapshot.h"
0066eddda7203f6345b56f77d146a759298dc635gryzor
7f5b59ccc63c0c0e3e678a168f09ee6a2f51f9d0ndint bus_snapshot_method_remove(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
f3ec420152ca921e4c1ce77782f51b53f659018dnd Snapshot *s = userdata;
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung int r;
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd
b686b6a420bde7f78c416b90be11db94cb789979nd assert(bus);
b686b6a420bde7f78c416b90be11db94cb789979nd assert(message);
b686b6a420bde7f78c416b90be11db94cb789979nd assert(s);
b686b6a420bde7f78c416b90be11db94cb789979nd
b686b6a420bde7f78c416b90be11db94cb789979nd r = mac_selinux_unit_access_check(UNIT(s), message, "stop", error);
b686b6a420bde7f78c416b90be11db94cb789979nd if (r < 0)
b686b6a420bde7f78c416b90be11db94cb789979nd return r;
fd09dcc9b954fde7abde7955af4ba9a094d34d50rbowen
fd09dcc9b954fde7abde7955af4ba9a094d34d50rbowen r = bus_verify_manage_units_async(UNIT(s)->manager, message, error);
fd09dcc9b954fde7abde7955af4ba9a094d34d50rbowen if (r < 0)
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf return r;
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf if (r == 0)
fd09dcc9b954fde7abde7955af4ba9a094d34d50rbowen return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
b686b6a420bde7f78c416b90be11db94cb789979nd
b686b6a420bde7f78c416b90be11db94cb789979nd snapshot_remove(s);
b686b6a420bde7f78c416b90be11db94cb789979nd
b686b6a420bde7f78c416b90be11db94cb789979nd return sd_bus_reply_method_return(message, NULL);
117c1f888a14e73cdd821dc6c23eb0411144a41cnd}
117c1f888a14e73cdd821dc6c23eb0411144a41cnd
b686b6a420bde7f78c416b90be11db94cb789979ndconst sd_bus_vtable bus_snapshot_vtable[] = {
b686b6a420bde7f78c416b90be11db94cb789979nd SD_BUS_VTABLE_START(0),
b686b6a420bde7f78c416b90be11db94cb789979nd SD_BUS_PROPERTY("Cleanup", "b", bus_property_get_bool, offsetof(Snapshot, cleanup), SD_BUS_VTABLE_PROPERTY_CONST),
b686b6a420bde7f78c416b90be11db94cb789979nd SD_BUS_METHOD("Remove", NULL, NULL, bus_snapshot_method_remove, SD_BUS_VTABLE_UNPRIVILEGED),
fd09dcc9b954fde7abde7955af4ba9a094d34d50rbowen SD_BUS_VTABLE_END
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh};
b686b6a420bde7f78c416b90be11db94cb789979nd