]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/core/dbus-snapshot.c
remove unused includes
[thirdparty/systemd.git] / src / core / dbus-snapshot.c
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
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
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
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
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 #include "selinux-access.h"
23 #include "unit.h"
24 #include "dbus.h"
25 #include "snapshot.h"
26 #include "dbus-snapshot.h"
27
28 int bus_snapshot_method_remove(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
29 Snapshot *s = userdata;
30 int r;
31
32 assert(bus);
33 assert(message);
34 assert(s);
35
36 r = mac_selinux_unit_access_check(UNIT(s), message, "stop", error);
37 if (r < 0)
38 return r;
39
40 r = bus_verify_manage_units_async(UNIT(s)->manager, message, error);
41 if (r < 0)
42 return r;
43 if (r == 0)
44 return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
45
46 snapshot_remove(s);
47
48 return sd_bus_reply_method_return(message, NULL);
49 }
50
51 const sd_bus_vtable bus_snapshot_vtable[] = {
52 SD_BUS_VTABLE_START(0),
53 SD_BUS_PROPERTY("Cleanup", "b", bus_property_get_bool, offsetof(Snapshot, cleanup), SD_BUS_VTABLE_PROPERTY_CONST),
54 SD_BUS_METHOD("Remove", NULL, NULL, bus_snapshot_method_remove, SD_BUS_VTABLE_UNPRIVILEGED),
55 SD_BUS_VTABLE_END
56 };