]>
Commit | Line | Data |
---|---|---|
d6c9574f | 1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
4139c1b2 LP |
2 | |
3 | /*** | |
4 | This file is part of systemd. | |
5 | ||
6 | Copyright 2010 Lennart Poettering | |
7 | ||
8 | systemd is free software; you can redistribute it and/or modify it | |
5430f7f2 LP |
9 | under the terms of the GNU Lesser General Public License as published by |
10 | the Free Software Foundation; either version 2.1 of the License, or | |
4139c1b2 LP |
11 | (at your option) any later version. |
12 | ||
13 | systemd is distributed in the hope that it will be useful, but | |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
5430f7f2 | 16 | Lesser General Public License for more details. |
4139c1b2 | 17 | |
5430f7f2 | 18 | You should have received a copy of the GNU Lesser General Public License |
4139c1b2 LP |
19 | along with systemd; If not, see <http://www.gnu.org/licenses/>. |
20 | ***/ | |
21 | ||
718db961 LP |
22 | #include "selinux-access.h" |
23 | #include "unit.h" | |
1d22e906 | 24 | #include "dbus.h" |
718db961 | 25 | #include "snapshot.h" |
4139c1b2 | 26 | #include "dbus-snapshot.h" |
d200735e | 27 | |
19070062 | 28 | int bus_snapshot_method_remove(sd_bus_message *message, void *userdata, sd_bus_error *error) { |
718db961 | 29 | Snapshot *s = userdata; |
ebcf1f97 | 30 | int r; |
4139c1b2 | 31 | |
718db961 LP |
32 | assert(message); |
33 | assert(s); | |
4139c1b2 | 34 | |
8a188de9 | 35 | r = mac_selinux_unit_access_check(UNIT(s), message, "stop", error); |
ebcf1f97 LP |
36 | if (r < 0) |
37 | return r; | |
cad45ba1 | 38 | |
1d22e906 LP |
39 | r = bus_verify_manage_units_async(UNIT(s)->manager, message, error); |
40 | if (r < 0) | |
41 | return r; | |
42 | if (r == 0) | |
43 | return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ | |
44 | ||
718db961 | 45 | snapshot_remove(s); |
5dd9014f | 46 | |
df2d202e | 47 | return sd_bus_reply_method_return(message, NULL); |
4139c1b2 | 48 | } |
718db961 LP |
49 | |
50 | const sd_bus_vtable bus_snapshot_vtable[] = { | |
51 | SD_BUS_VTABLE_START(0), | |
556089dc | 52 | SD_BUS_PROPERTY("Cleanup", "b", bus_property_get_bool, offsetof(Snapshot, cleanup), SD_BUS_VTABLE_PROPERTY_CONST), |
1d22e906 | 53 | SD_BUS_METHOD("Remove", NULL, NULL, bus_snapshot_method_remove, SD_BUS_VTABLE_UNPRIVILEGED), |
718db961 LP |
54 | SD_BUS_VTABLE_END |
55 | }; |