File: | build-scan/../src/core/dbus-unit.c |
Warning: | line 1505, column 17 Value stored to 'unit_path' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
2 | |
3 | #include "sd-bus.h" |
4 | |
5 | #include "alloc-util.h" |
6 | #include "bpf-firewall.h" |
7 | #include "bus-common-errors.h" |
8 | #include "cgroup-util.h" |
9 | #include "condition.h" |
10 | #include "dbus-job.h" |
11 | #include "dbus-unit.h" |
12 | #include "dbus-util.h" |
13 | #include "dbus.h" |
14 | #include "fd-util.h" |
15 | #include "locale-util.h" |
16 | #include "log.h" |
17 | #include "path-util.h" |
18 | #include "process-util.h" |
19 | #include "selinux-access.h" |
20 | #include "signal-util.h" |
21 | #include "special.h" |
22 | #include "string-util.h" |
23 | #include "strv.h" |
24 | #include "user-util.h" |
25 | #include "web-util.h" |
26 | |
27 | static bool_Bool unit_can_start_refuse_manual(Unit *u) { |
28 | return unit_can_start(u) && !u->refuse_manual_start; |
29 | } |
30 | |
31 | static bool_Bool unit_can_stop_refuse_manual(Unit *u) { |
32 | return unit_can_stop(u) && !u->refuse_manual_stop; |
33 | } |
34 | |
35 | static bool_Bool unit_can_isolate_refuse_manual(Unit *u) { |
36 | return unit_can_isolate(u) && !u->refuse_manual_start; |
37 | } |
38 | |
39 | static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_collect_mode, collect_mode, CollectMode)int property_get_collect_mode(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply , void *userdata, sd_bus_error *error) { CollectMode *data = userdata ; do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 39, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 39, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(data)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ( "data"), "../src/core/dbus-unit.c", 39, __PRETTY_FUNCTION__); } while (0); return sd_bus_message_append(reply, "s", collect_mode_to_string ((*(data)))); }; |
40 | static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_load_state, unit_load_state, UnitLoadState)int property_get_load_state(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply , void *userdata, sd_bus_error *error) { UnitLoadState *data = userdata; do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 40, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 40, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(data)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ( "data"), "../src/core/dbus-unit.c", 40, __PRETTY_FUNCTION__); } while (0); return sd_bus_message_append(reply, "s", unit_load_state_to_string ((*(data)))); }; |
41 | static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_job_mode, job_mode, JobMode)int property_get_job_mode(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply , void *userdata, sd_bus_error *error) { JobMode *data = userdata ; do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 41, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 41, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(data)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ( "data"), "../src/core/dbus-unit.c", 41, __PRETTY_FUNCTION__); } while (0); return sd_bus_message_append(reply, "s", job_mode_to_string ((*(data)))); }; |
42 | static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_emergency_action, emergency_action, EmergencyAction)int property_get_emergency_action(sd_bus *bus, const char *path , const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error) { EmergencyAction *data = userdata; do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c" , 42, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(reply)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 42, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(data)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("data"), "../src/core/dbus-unit.c", 42, __PRETTY_FUNCTION__ ); } while (0); return sd_bus_message_append(reply, "s", emergency_action_to_string ((*(data)))); }; |
43 | static BUS_DEFINE_PROPERTY_GET(property_get_description, "s", Unit, unit_description)int property_get_description(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply , void *userdata, sd_bus_error *error) { Unit *data = userdata ; do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 43, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 43, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(data)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ( "data"), "../src/core/dbus-unit.c", 43, __PRETTY_FUNCTION__); } while (0); return sd_bus_message_append(reply, "s", (unit_description (data))); }; |
44 | static BUS_DEFINE_PROPERTY_GET2(property_get_active_state, "s", Unit, unit_active_state, unit_active_state_to_string)int property_get_active_state(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply , void *userdata, sd_bus_error *error) { Unit *data = userdata ; do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 44, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 44, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(data)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ( "data"), "../src/core/dbus-unit.c", 44, __PRETTY_FUNCTION__); } while (0); return sd_bus_message_append(reply, "s", unit_active_state_to_string (unit_active_state(data))); }; |
45 | static BUS_DEFINE_PROPERTY_GET2(property_get_freezer_state, "s", Unit, unit_freezer_state, freezer_state_to_string)int property_get_freezer_state(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message * reply, void *userdata, sd_bus_error *error) { Unit *data = userdata ; do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 45, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 45, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(data)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ( "data"), "../src/core/dbus-unit.c", 45, __PRETTY_FUNCTION__); } while (0); return sd_bus_message_append(reply, "s", freezer_state_to_string (unit_freezer_state(data))); }; |
46 | static BUS_DEFINE_PROPERTY_GET(property_get_sub_state, "s", Unit, unit_sub_state_to_string)int property_get_sub_state(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply , void *userdata, sd_bus_error *error) { Unit *data = userdata ; do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 46, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 46, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(data)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ( "data"), "../src/core/dbus-unit.c", 46, __PRETTY_FUNCTION__); } while (0); return sd_bus_message_append(reply, "s", (unit_sub_state_to_string (data))); }; |
47 | static BUS_DEFINE_PROPERTY_GET2(property_get_unit_file_state, "s", Unit, unit_get_unit_file_state, unit_file_state_to_string)int property_get_unit_file_state(sd_bus *bus, const char *path , const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error) { Unit *data = userdata ; do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 47, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 47, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(data)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ( "data"), "../src/core/dbus-unit.c", 47, __PRETTY_FUNCTION__); } while (0); return sd_bus_message_append(reply, "s", unit_file_state_to_string (unit_get_unit_file_state(data))); }; |
48 | static BUS_DEFINE_PROPERTY_GET(property_get_can_reload, "b", Unit, unit_can_reload)int property_get_can_reload(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply , void *userdata, sd_bus_error *error) { Unit *data = userdata ; do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 48, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 48, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(data)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ( "data"), "../src/core/dbus-unit.c", 48, __PRETTY_FUNCTION__); } while (0); return sd_bus_message_append(reply, "b", (unit_can_reload (data))); }; |
49 | static BUS_DEFINE_PROPERTY_GET(property_get_can_start, "b", Unit, unit_can_start_refuse_manual)int property_get_can_start(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply , void *userdata, sd_bus_error *error) { Unit *data = userdata ; do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 49, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 49, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(data)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ( "data"), "../src/core/dbus-unit.c", 49, __PRETTY_FUNCTION__); } while (0); return sd_bus_message_append(reply, "b", (unit_can_start_refuse_manual (data))); }; |
50 | static BUS_DEFINE_PROPERTY_GET(property_get_can_stop, "b", Unit, unit_can_stop_refuse_manual)int property_get_can_stop(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply , void *userdata, sd_bus_error *error) { Unit *data = userdata ; do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 50, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 50, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(data)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ( "data"), "../src/core/dbus-unit.c", 50, __PRETTY_FUNCTION__); } while (0); return sd_bus_message_append(reply, "b", (unit_can_stop_refuse_manual (data))); }; |
51 | static BUS_DEFINE_PROPERTY_GET(property_get_can_isolate, "b", Unit, unit_can_isolate_refuse_manual)int property_get_can_isolate(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply , void *userdata, sd_bus_error *error) { Unit *data = userdata ; do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 51, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 51, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(data)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ( "data"), "../src/core/dbus-unit.c", 51, __PRETTY_FUNCTION__); } while (0); return sd_bus_message_append(reply, "b", (unit_can_isolate_refuse_manual (data))); }; |
52 | static BUS_DEFINE_PROPERTY_GET(property_get_can_freeze, "b", Unit, unit_can_freeze)int property_get_can_freeze(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply , void *userdata, sd_bus_error *error) { Unit *data = userdata ; do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 52, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 52, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(data)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ( "data"), "../src/core/dbus-unit.c", 52, __PRETTY_FUNCTION__); } while (0); return sd_bus_message_append(reply, "b", (unit_can_freeze (data))); }; |
53 | static BUS_DEFINE_PROPERTY_GET(property_get_need_daemon_reload, "b", Unit, unit_need_daemon_reload)int property_get_need_daemon_reload(sd_bus *bus, const char * path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error) { Unit *data = userdata ; do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 53, __PRETTY_FUNCTION__ ); } while (0); do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 53, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect (!!(!(data)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ( "data"), "../src/core/dbus-unit.c", 53, __PRETTY_FUNCTION__); } while (0); return sd_bus_message_append(reply, "b", (unit_need_daemon_reload (data))); }; |
54 | static BUS_DEFINE_PROPERTY_GET_GLOBAL(property_get_empty_strv, "as", 0)int property_get_empty_strv(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply , void *userdata, sd_bus_error *error) { do { if ((__builtin_expect (!!(!(bus)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ( "bus"), "../src/core/dbus-unit.c", 54, __PRETTY_FUNCTION__); } while (0); do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 54, __PRETTY_FUNCTION__); } while (0); return sd_bus_message_append (reply, "as", 0); }; |
55 | |
56 | static int property_get_names( |
57 | sd_bus *bus, |
58 | const char *path, |
59 | const char *interface, |
60 | const char *property, |
61 | sd_bus_message *reply, |
62 | void *userdata, |
63 | sd_bus_error *error) { |
64 | |
65 | Set **s = userdata; |
66 | Iterator i; |
67 | const char *t; |
68 | int r; |
69 | |
70 | assert(bus)do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 70, __PRETTY_FUNCTION__ ); } while (0); |
71 | assert(reply)do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 71, __PRETTY_FUNCTION__); } while (0); |
72 | assert(s)do { if ((__builtin_expect(!!(!(s)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("s"), "../src/core/dbus-unit.c", 72, __PRETTY_FUNCTION__ ); } while (0); |
73 | |
74 | r = sd_bus_message_open_container(reply, 'a', "s"); |
75 | if (r < 0) |
76 | return r; |
77 | |
78 | SET_FOREACH(t, *s, i)for ((i) = ((Iterator) { .idx = ((2147483647 *2U +1U) - 1), . next_key = ((void*)0) }); set_iterate((*s), &(i), (void** )&(t)); ) { |
79 | r = sd_bus_message_append(reply, "s", t); |
80 | if (r < 0) |
81 | return r; |
82 | } |
83 | |
84 | return sd_bus_message_close_container(reply); |
85 | } |
86 | |
87 | static int property_get_following( |
88 | sd_bus *bus, |
89 | const char *path, |
90 | const char *interface, |
91 | const char *property, |
92 | sd_bus_message *reply, |
93 | void *userdata, |
94 | sd_bus_error *error) { |
95 | |
96 | Unit *u = userdata, *f; |
97 | |
98 | assert(bus)do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 98, __PRETTY_FUNCTION__ ); } while (0); |
99 | assert(reply)do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 99, __PRETTY_FUNCTION__); } while (0); |
100 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 100, __PRETTY_FUNCTION__ ); } while (0); |
101 | |
102 | f = unit_following(u); |
103 | return sd_bus_message_append(reply, "s", f ? f->id : NULL((void*)0)); |
104 | } |
105 | |
106 | static int property_get_dependencies( |
107 | sd_bus *bus, |
108 | const char *path, |
109 | const char *interface, |
110 | const char *property, |
111 | sd_bus_message *reply, |
112 | void *userdata, |
113 | sd_bus_error *error) { |
114 | |
115 | Hashmap **h = userdata; |
116 | Iterator j; |
117 | Unit *u; |
118 | void *v; |
119 | int r; |
120 | |
121 | assert(bus)do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 121, __PRETTY_FUNCTION__ ); } while (0); |
122 | assert(reply)do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 122 , __PRETTY_FUNCTION__); } while (0); |
123 | assert(h)do { if ((__builtin_expect(!!(!(h)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("h"), "../src/core/dbus-unit.c", 123, __PRETTY_FUNCTION__ ); } while (0); |
124 | |
125 | r = sd_bus_message_open_container(reply, 'a', "s"); |
126 | if (r < 0) |
127 | return r; |
128 | |
129 | HASHMAP_FOREACH_KEY(v, u, *h, j)for ((j) = ((Iterator) { .idx = ((2147483647 *2U +1U) - 1), . next_key = ((void*)0) }); hashmap_iterate((*h), &(j), (void **)&(v), (const void**) &(u)); ) { |
130 | r = sd_bus_message_append(reply, "s", u->id); |
131 | if (r < 0) |
132 | return r; |
133 | } |
134 | |
135 | return sd_bus_message_close_container(reply); |
136 | } |
137 | |
138 | static int property_get_requires_mounts_for( |
139 | sd_bus *bus, |
140 | const char *path, |
141 | const char *interface, |
142 | const char *property, |
143 | sd_bus_message *reply, |
144 | void *userdata, |
145 | sd_bus_error *error) { |
146 | |
147 | Hashmap **h = userdata; |
148 | const char *p; |
149 | Iterator j; |
150 | void *v; |
151 | int r; |
152 | |
153 | assert(bus)do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 153, __PRETTY_FUNCTION__ ); } while (0); |
154 | assert(reply)do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 154 , __PRETTY_FUNCTION__); } while (0); |
155 | assert(h)do { if ((__builtin_expect(!!(!(h)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("h"), "../src/core/dbus-unit.c", 155, __PRETTY_FUNCTION__ ); } while (0); |
156 | |
157 | r = sd_bus_message_open_container(reply, 'a', "s"); |
158 | if (r < 0) |
159 | return r; |
160 | |
161 | HASHMAP_FOREACH_KEY(v, p, *h, j)for ((j) = ((Iterator) { .idx = ((2147483647 *2U +1U) - 1), . next_key = ((void*)0) }); hashmap_iterate((*h), &(j), (void **)&(v), (const void**) &(p)); ) { |
162 | r = sd_bus_message_append(reply, "s", p); |
163 | if (r < 0) |
164 | return r; |
165 | } |
166 | |
167 | return sd_bus_message_close_container(reply); |
168 | } |
169 | |
170 | static int property_get_unit_file_preset( |
171 | sd_bus *bus, |
172 | const char *path, |
173 | const char *interface, |
174 | const char *property, |
175 | sd_bus_message *reply, |
176 | void *userdata, |
177 | sd_bus_error *error) { |
178 | |
179 | Unit *u = userdata; |
180 | int r; |
181 | |
182 | assert(bus)do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 182, __PRETTY_FUNCTION__ ); } while (0); |
183 | assert(reply)do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 183 , __PRETTY_FUNCTION__); } while (0); |
184 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 184, __PRETTY_FUNCTION__ ); } while (0); |
185 | |
186 | r = unit_get_unit_file_preset(u); |
187 | |
188 | return sd_bus_message_append(reply, "s", |
189 | r < 0 ? NULL((void*)0): |
190 | r > 0 ? "enabled" : "disabled"); |
191 | } |
192 | |
193 | static int property_get_job( |
194 | sd_bus *bus, |
195 | const char *path, |
196 | const char *interface, |
197 | const char *property, |
198 | sd_bus_message *reply, |
199 | void *userdata, |
200 | sd_bus_error *error) { |
201 | |
202 | _cleanup_free___attribute__((cleanup(freep))) char *p = NULL((void*)0); |
203 | Job **j = userdata; |
204 | |
205 | assert(bus)do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 205, __PRETTY_FUNCTION__ ); } while (0); |
206 | assert(reply)do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 206 , __PRETTY_FUNCTION__); } while (0); |
207 | assert(j)do { if ((__builtin_expect(!!(!(j)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("j"), "../src/core/dbus-unit.c", 207, __PRETTY_FUNCTION__ ); } while (0); |
208 | |
209 | if (!*j) |
210 | return sd_bus_message_append(reply, "(uo)", 0, "/"); |
211 | |
212 | p = job_dbus_path(*j); |
213 | if (!p) |
214 | return -ENOMEM12; |
215 | |
216 | return sd_bus_message_append(reply, "(uo)", (*j)->id, p); |
217 | } |
218 | |
219 | static int property_get_conditions( |
220 | sd_bus *bus, |
221 | const char *path, |
222 | const char *interface, |
223 | const char *property, |
224 | sd_bus_message *reply, |
225 | void *userdata, |
226 | sd_bus_error *error) { |
227 | |
228 | const char *(*to_string)(ConditionType type) = NULL((void*)0); |
229 | Condition **list = userdata, *c; |
230 | int r; |
231 | |
232 | assert(bus)do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 232, __PRETTY_FUNCTION__ ); } while (0); |
233 | assert(reply)do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 233 , __PRETTY_FUNCTION__); } while (0); |
234 | assert(list)do { if ((__builtin_expect(!!(!(list)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("list"), "../src/core/dbus-unit.c", 234, __PRETTY_FUNCTION__); } while (0); |
235 | |
236 | to_string = streq(property, "Asserts")(strcmp((property),("Asserts")) == 0) ? assert_type_to_string : condition_type_to_string; |
237 | |
238 | r = sd_bus_message_open_container(reply, 'a', "(sbbsi)"); |
239 | if (r < 0) |
240 | return r; |
241 | |
242 | LIST_FOREACH(conditions, c, *list)for ((c) = (*list); (c); (c) = (c)->conditions_next) { |
243 | int tristate; |
244 | |
245 | tristate = |
246 | c->result == CONDITION_UNTESTED ? 0 : |
247 | c->result == CONDITION_SUCCEEDED ? 1 : -1; |
248 | |
249 | r = sd_bus_message_append(reply, "(sbbsi)", |
250 | to_string(c->type), |
251 | c->trigger, c->negate, |
252 | c->parameter, tristate); |
253 | if (r < 0) |
254 | return r; |
255 | |
256 | } |
257 | |
258 | return sd_bus_message_close_container(reply); |
259 | } |
260 | |
261 | static int property_get_load_error( |
262 | sd_bus *bus, |
263 | const char *path, |
264 | const char *interface, |
265 | const char *property, |
266 | sd_bus_message *reply, |
267 | void *userdata, |
268 | sd_bus_error *error) { |
269 | |
270 | _cleanup_(sd_bus_error_free)__attribute__((cleanup(sd_bus_error_free))) sd_bus_error e = SD_BUS_ERROR_NULL((const sd_bus_error) {(((void*)0)), (((void*)0)), 0}); |
271 | Unit *u = userdata; |
272 | int r; |
273 | |
274 | assert(bus)do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 274, __PRETTY_FUNCTION__ ); } while (0); |
275 | assert(reply)do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 275 , __PRETTY_FUNCTION__); } while (0); |
276 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 276, __PRETTY_FUNCTION__ ); } while (0); |
277 | |
278 | r = bus_unit_validate_load_state(u, &e); |
279 | if (r < 0) |
280 | return sd_bus_message_append(reply, "(ss)", e.name, e.message); |
281 | |
282 | return sd_bus_message_append(reply, "(ss)", NULL((void*)0), NULL((void*)0)); |
283 | } |
284 | |
285 | static int bus_verify_manage_units_async_full( |
286 | Unit *u, |
287 | const char *verb, |
288 | int capability, |
289 | const char *polkit_message, |
290 | bool_Bool interactive, |
291 | sd_bus_message *call, |
292 | sd_bus_error *error) { |
293 | |
294 | const char *details[9] = { |
295 | "unit", u->id, |
296 | "verb", verb, |
297 | }; |
298 | |
299 | if (polkit_message) { |
300 | details[4] = "polkit.message"; |
301 | details[5] = polkit_message; |
302 | details[6] = "polkit.gettext_domain"; |
303 | details[7] = GETTEXT_PACKAGE"systemd"; |
304 | } |
305 | |
306 | return bus_verify_polkit_async( |
307 | call, |
308 | capability, |
309 | "org.freedesktop.systemd1.manage-units", |
310 | details, |
311 | interactive, |
312 | UID_INVALID((uid_t) -1), |
313 | &u->manager->polkit_registry, |
314 | error); |
315 | } |
316 | |
317 | static const char *const polkit_message_for_job[_JOB_TYPE_MAX] = { |
318 | [JOB_START] = N_("Authentication is required to start '$(unit)'.")"Authentication is required to start '$(unit)'.", |
319 | [JOB_STOP] = N_("Authentication is required to stop '$(unit)'.")"Authentication is required to stop '$(unit)'.", |
320 | [JOB_RELOAD] = N_("Authentication is required to reload '$(unit)'.")"Authentication is required to reload '$(unit)'.", |
321 | [JOB_RESTART] = N_("Authentication is required to restart '$(unit)'.")"Authentication is required to restart '$(unit)'.", |
322 | [JOB_TRY_RESTART] = N_("Authentication is required to restart '$(unit)'.")"Authentication is required to restart '$(unit)'.", |
323 | }; |
324 | |
325 | int bus_unit_method_start_generic( |
326 | sd_bus_message *message, |
327 | Unit *u, |
328 | JobType job_type, |
329 | bool_Bool reload_if_possible, |
330 | sd_bus_error *error) { |
331 | |
332 | const char *smode; |
333 | JobMode mode; |
334 | _cleanup_free___attribute__((cleanup(freep))) char *verb = NULL((void*)0); |
335 | int r; |
336 | |
337 | assert(message)do { if ((__builtin_expect(!!(!(message)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("message"), "../src/core/dbus-unit.c", 337 , __PRETTY_FUNCTION__); } while (0); |
338 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 338, __PRETTY_FUNCTION__ ); } while (0); |
339 | assert(job_type >= 0 && job_type < _JOB_TYPE_MAX)do { if ((__builtin_expect(!!(!(job_type >= 0 && job_type < _JOB_TYPE_MAX)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("job_type >= 0 && job_type < _JOB_TYPE_MAX") , "../src/core/dbus-unit.c", 339, __PRETTY_FUNCTION__); } while (0); |
340 | |
341 | r = mac_selinux_unit_access_check(mac_selinux_generic_access_check((message), unit_label_path(u ), (job_type_to_access_method(job_type)), (error)) |
342 | u, message,mac_selinux_generic_access_check((message), unit_label_path(u ), (job_type_to_access_method(job_type)), (error)) |
343 | job_type_to_access_method(job_type),mac_selinux_generic_access_check((message), unit_label_path(u ), (job_type_to_access_method(job_type)), (error)) |
344 | error)mac_selinux_generic_access_check((message), unit_label_path(u ), (job_type_to_access_method(job_type)), (error)); |
345 | if (r < 0) |
346 | return r; |
347 | |
348 | r = sd_bus_message_read(message, "s", &smode); |
349 | if (r < 0) |
350 | return r; |
351 | |
352 | mode = job_mode_from_string(smode); |
353 | if (mode < 0) |
354 | return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS"org.freedesktop.DBus.Error.InvalidArgs", "Job mode %s invalid", smode); |
355 | |
356 | if (reload_if_possible) |
357 | verb = strjoin("reload-or-", job_type_to_string(job_type))strjoin_real(("reload-or-"), job_type_to_string(job_type), (( void*)0)); |
358 | else |
359 | verb = strdup(job_type_to_string(job_type)); |
360 | if (!verb) |
361 | return -ENOMEM12; |
362 | |
363 | r = bus_verify_manage_units_async_full( |
364 | u, |
365 | verb, |
366 | CAP_SYS_ADMIN21, |
367 | job_type < _JOB_TYPE_MAX ? polkit_message_for_job[job_type] : NULL((void*)0), |
368 | true1, |
369 | message, |
370 | error); |
371 | if (r < 0) |
372 | return r; |
373 | if (r == 0) |
374 | return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ |
375 | |
376 | return bus_unit_queue_job(message, u, job_type, mode, |
377 | reload_if_possible ? BUS_UNIT_QUEUE_RELOAD_IF_POSSIBLE : 0, error); |
378 | } |
379 | |
380 | static int method_start(sd_bus_message *message, void *userdata, sd_bus_error *error) { |
381 | return bus_unit_method_start_generic(message, userdata, JOB_START, false0, error); |
382 | } |
383 | |
384 | static int method_stop(sd_bus_message *message, void *userdata, sd_bus_error *error) { |
385 | return bus_unit_method_start_generic(message, userdata, JOB_STOP, false0, error); |
386 | } |
387 | |
388 | static int method_reload(sd_bus_message *message, void *userdata, sd_bus_error *error) { |
389 | return bus_unit_method_start_generic(message, userdata, JOB_RELOAD, false0, error); |
390 | } |
391 | |
392 | static int method_restart(sd_bus_message *message, void *userdata, sd_bus_error *error) { |
393 | return bus_unit_method_start_generic(message, userdata, JOB_RESTART, false0, error); |
394 | } |
395 | |
396 | static int method_try_restart(sd_bus_message *message, void *userdata, sd_bus_error *error) { |
397 | return bus_unit_method_start_generic(message, userdata, JOB_TRY_RESTART, false0, error); |
398 | } |
399 | |
400 | static int method_reload_or_restart(sd_bus_message *message, void *userdata, sd_bus_error *error) { |
401 | return bus_unit_method_start_generic(message, userdata, JOB_RESTART, true1, error); |
402 | } |
403 | |
404 | static int method_reload_or_try_restart(sd_bus_message *message, void *userdata, sd_bus_error *error) { |
405 | return bus_unit_method_start_generic(message, userdata, JOB_TRY_RESTART, true1, error); |
406 | } |
407 | |
408 | int bus_unit_method_enqueue_job(sd_bus_message *message, void *userdata, sd_bus_error *error) { |
409 | BusUnitQueueFlags flags = BUS_UNIT_QUEUE_VERBOSE_REPLY; |
410 | const char *jtype, *smode; |
411 | Unit *u = userdata; |
412 | JobType type; |
413 | JobMode mode; |
414 | int r; |
415 | |
416 | assert(message)do { if ((__builtin_expect(!!(!(message)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("message"), "../src/core/dbus-unit.c", 416 , __PRETTY_FUNCTION__); } while (0); |
417 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 417, __PRETTY_FUNCTION__ ); } while (0); |
418 | |
419 | r = sd_bus_message_read(message, "ss", &jtype, &smode); |
420 | if (r < 0) |
421 | return r; |
422 | |
423 | /* Parse the two magic reload types "reload-or-…" manually */ |
424 | if (streq(jtype, "reload-or-restart")(strcmp((jtype),("reload-or-restart")) == 0)) { |
425 | type = JOB_RESTART; |
426 | flags |= BUS_UNIT_QUEUE_RELOAD_IF_POSSIBLE; |
427 | } else if (streq(jtype, "reload-or-try-restart")(strcmp((jtype),("reload-or-try-restart")) == 0)) { |
428 | type = JOB_TRY_RESTART; |
429 | flags |= BUS_UNIT_QUEUE_RELOAD_IF_POSSIBLE; |
430 | } else { |
431 | /* And the rest generically */ |
432 | type = job_type_from_string(jtype); |
433 | if (type < 0) |
434 | return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS"org.freedesktop.DBus.Error.InvalidArgs", "Job type %s invalid", jtype); |
435 | } |
436 | |
437 | mode = job_mode_from_string(smode); |
438 | if (mode < 0) |
439 | return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS"org.freedesktop.DBus.Error.InvalidArgs", "Job mode %s invalid", smode); |
440 | |
441 | r = mac_selinux_unit_access_check(mac_selinux_generic_access_check((message), unit_label_path(u ), (job_type_to_access_method(type)), (error)) |
442 | u, message,mac_selinux_generic_access_check((message), unit_label_path(u ), (job_type_to_access_method(type)), (error)) |
443 | job_type_to_access_method(type),mac_selinux_generic_access_check((message), unit_label_path(u ), (job_type_to_access_method(type)), (error)) |
444 | error)mac_selinux_generic_access_check((message), unit_label_path(u ), (job_type_to_access_method(type)), (error)); |
445 | if (r < 0) |
446 | return r; |
447 | |
448 | r = bus_verify_manage_units_async_full( |
449 | u, |
450 | jtype, |
451 | CAP_SYS_ADMIN21, |
452 | polkit_message_for_job[type], |
453 | true1, |
454 | message, |
455 | error); |
456 | if (r < 0) |
457 | return r; |
458 | if (r == 0) |
459 | return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ |
460 | |
461 | return bus_unit_queue_job(message, u, type, mode, flags, error); |
462 | } |
463 | |
464 | int bus_unit_method_kill(sd_bus_message *message, void *userdata, sd_bus_error *error) { |
465 | Unit *u = userdata; |
466 | const char *swho; |
467 | int32_t signo; |
468 | KillWho who; |
469 | int r; |
470 | |
471 | assert(message)do { if ((__builtin_expect(!!(!(message)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("message"), "../src/core/dbus-unit.c", 471 , __PRETTY_FUNCTION__); } while (0); |
472 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 472, __PRETTY_FUNCTION__ ); } while (0); |
473 | |
474 | r = mac_selinux_unit_access_check(u, message, "stop", error)mac_selinux_generic_access_check((message), unit_label_path(u ), ("stop"), (error)); |
475 | if (r < 0) |
476 | return r; |
477 | |
478 | r = sd_bus_message_read(message, "si", &swho, &signo); |
479 | if (r < 0) |
480 | return r; |
481 | |
482 | if (isempty(swho)) |
483 | who = KILL_ALL; |
484 | else { |
485 | who = kill_who_from_string(swho); |
486 | if (who < 0) |
487 | return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS"org.freedesktop.DBus.Error.InvalidArgs", "Invalid who argument %s", swho); |
488 | } |
489 | |
490 | if (!SIGNAL_VALID(signo)) |
491 | return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS"org.freedesktop.DBus.Error.InvalidArgs", "Signal number out of range."); |
492 | |
493 | r = bus_verify_manage_units_async_full( |
494 | u, |
495 | "kill", |
496 | CAP_KILL5, |
497 | N_("Authentication is required to kill '$(unit)'.")"Authentication is required to kill '$(unit)'.", |
498 | true1, |
499 | message, |
500 | error); |
501 | if (r < 0) |
502 | return r; |
503 | if (r == 0) |
504 | return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ |
505 | |
506 | r = unit_kill(u, who, signo, error); |
507 | if (r < 0) |
508 | return r; |
509 | |
510 | return sd_bus_reply_method_return(message, NULL((void*)0)); |
511 | } |
512 | |
513 | int bus_unit_method_reset_failed(sd_bus_message *message, void *userdata, sd_bus_error *error) { |
514 | Unit *u = userdata; |
515 | int r; |
516 | |
517 | assert(message)do { if ((__builtin_expect(!!(!(message)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("message"), "../src/core/dbus-unit.c", 517 , __PRETTY_FUNCTION__); } while (0); |
518 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 518, __PRETTY_FUNCTION__ ); } while (0); |
519 | |
520 | r = mac_selinux_unit_access_check(u, message, "reload", error)mac_selinux_generic_access_check((message), unit_label_path(u ), ("reload"), (error)); |
521 | if (r < 0) |
522 | return r; |
523 | |
524 | r = bus_verify_manage_units_async_full( |
525 | u, |
526 | "reset-failed", |
527 | CAP_SYS_ADMIN21, |
528 | N_("Authentication is required to reset the \"failed\" state of '$(unit)'.")"Authentication is required to reset the \"failed\" state of '$(unit)'.", |
529 | true1, |
530 | message, |
531 | error); |
532 | if (r < 0) |
533 | return r; |
534 | if (r == 0) |
535 | return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ |
536 | |
537 | unit_reset_failed(u); |
538 | |
539 | return sd_bus_reply_method_return(message, NULL((void*)0)); |
540 | } |
541 | |
542 | int bus_unit_method_set_properties(sd_bus_message *message, void *userdata, sd_bus_error *error) { |
543 | Unit *u = userdata; |
544 | int runtime, r; |
545 | |
546 | assert(message)do { if ((__builtin_expect(!!(!(message)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("message"), "../src/core/dbus-unit.c", 546 , __PRETTY_FUNCTION__); } while (0); |
547 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 547, __PRETTY_FUNCTION__ ); } while (0); |
548 | |
549 | r = mac_selinux_unit_access_check(u, message, "start", error)mac_selinux_generic_access_check((message), unit_label_path(u ), ("start"), (error)); |
550 | if (r < 0) |
551 | return r; |
552 | |
553 | r = sd_bus_message_read(message, "b", &runtime); |
554 | if (r < 0) |
555 | return r; |
556 | |
557 | r = bus_verify_manage_units_async_full( |
558 | u, |
559 | "set-property", |
560 | CAP_SYS_ADMIN21, |
561 | N_("Authentication is required to set properties on '$(unit)'.")"Authentication is required to set properties on '$(unit)'.", |
562 | true1, |
563 | message, |
564 | error); |
565 | if (r < 0) |
566 | return r; |
567 | if (r == 0) |
568 | return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ |
569 | |
570 | r = bus_unit_set_properties(u, message, runtime ? UNIT_RUNTIME : UNIT_PERSISTENT, true1, error); |
571 | if (r < 0) |
572 | return r; |
573 | |
574 | return sd_bus_reply_method_return(message, NULL((void*)0)); |
575 | } |
576 | |
577 | int bus_unit_method_ref(sd_bus_message *message, void *userdata, sd_bus_error *error) { |
578 | Unit *u = userdata; |
579 | int r; |
580 | |
581 | assert(message)do { if ((__builtin_expect(!!(!(message)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("message"), "../src/core/dbus-unit.c", 581 , __PRETTY_FUNCTION__); } while (0); |
582 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 582, __PRETTY_FUNCTION__ ); } while (0); |
583 | |
584 | r = mac_selinux_unit_access_check(u, message, "start", error)mac_selinux_generic_access_check((message), unit_label_path(u ), ("start"), (error)); |
585 | if (r < 0) |
586 | return r; |
587 | |
588 | r = bus_verify_manage_units_async_full( |
589 | u, |
590 | "ref", |
591 | CAP_SYS_ADMIN21, |
592 | NULL((void*)0), |
593 | false0, |
594 | message, |
595 | error); |
596 | if (r < 0) |
597 | return r; |
598 | if (r == 0) |
599 | return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ |
600 | |
601 | r = bus_unit_track_add_sender(u, message); |
602 | if (r < 0) |
603 | return r; |
604 | |
605 | return sd_bus_reply_method_return(message, NULL((void*)0)); |
606 | } |
607 | |
608 | int bus_unit_method_unref(sd_bus_message *message, void *userdata, sd_bus_error *error) { |
609 | Unit *u = userdata; |
610 | int r; |
611 | |
612 | assert(message)do { if ((__builtin_expect(!!(!(message)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("message"), "../src/core/dbus-unit.c", 612 , __PRETTY_FUNCTION__); } while (0); |
613 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 613, __PRETTY_FUNCTION__ ); } while (0); |
614 | |
615 | r = bus_unit_track_remove_sender(u, message); |
616 | if (r == -EUNATCH49) |
617 | return sd_bus_error_setf(error, BUS_ERROR_NOT_REFERENCED"org.freedesktop.systemd1.NotReferenced", "Unit has not been referenced yet."); |
618 | if (r < 0) |
619 | return r; |
620 | |
621 | return sd_bus_reply_method_return(message, NULL((void*)0)); |
622 | } |
623 | |
624 | static int bus_unit_method_freezer_generic(sd_bus_message *message, void *userdata, sd_bus_error *error, FreezerAction action) { |
625 | const char* perm; |
626 | int (*method)(Unit*); |
627 | Unit *u = userdata; |
628 | bool_Bool reply_no_delay = false0; |
629 | int r; |
630 | |
631 | assert(message)do { if ((__builtin_expect(!!(!(message)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("message"), "../src/core/dbus-unit.c", 631 , __PRETTY_FUNCTION__); } while (0); |
632 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 632, __PRETTY_FUNCTION__ ); } while (0); |
633 | assert(IN_SET(action, FREEZER_FREEZE, FREEZER_THAW))do { if ((__builtin_expect(!!(!(({ _Bool _found = 0; static __attribute__ ((unused)) char _static_assert__macros_need_to_be_extended[20 - sizeof((int[]){FREEZER_FREEZE, FREEZER_THAW})/sizeof(int)] ; switch(action) { case FREEZER_FREEZE: case FREEZER_THAW: _found = 1; break; default: break; } _found; }))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("IN_SET(action, FREEZER_FREEZE, FREEZER_THAW)" ), "../src/core/dbus-unit.c", 633, __PRETTY_FUNCTION__); } while (0); |
634 | |
635 | if (action == FREEZER_FREEZE) { |
636 | perm = "stop"; |
637 | method = unit_freeze; |
638 | } else { |
639 | perm = "start"; |
640 | method = unit_thaw; |
641 | } |
642 | |
643 | r = mac_selinux_unit_access_check(u, message, perm, error)mac_selinux_generic_access_check((message), unit_label_path(u ), (perm), (error)); |
644 | if (r < 0) |
645 | return r; |
646 | |
647 | r = bus_verify_manage_units_async_full( |
648 | u, |
649 | perm, |
650 | CAP_SYS_ADMIN21, |
651 | N_("Authentication is required to freeze or thaw the processes of '$(unit)' unit.")"Authentication is required to freeze or thaw the processes of '$(unit)' unit.", |
652 | true1, |
653 | message, |
654 | error); |
655 | if (r < 0) |
656 | return r; |
657 | if (r == 0) |
658 | return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ |
659 | |
660 | r = method(u); |
661 | if (r == -EOPNOTSUPP95) |
662 | return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED"org.freedesktop.DBus.Error.NotSupported", "Unit '%s' does not support freezing.", u->id); |
663 | if (r == -EBUSY16) |
664 | return sd_bus_error_setf(error, BUS_ERROR_UNIT_BUSY"org.freedesktop.systemd1.UnitBusy", "Unit has a pending job."); |
665 | if (r == -EHOSTDOWN112) |
666 | return sd_bus_error_setf(error, BUS_ERROR_UNIT_INACTIVE"org.freedesktop.systemd1.UnitInactive", "Unit is inactive."); |
667 | if (r == -EALREADY114) |
668 | return sd_bus_error_setf(error, SD_BUS_ERROR_FAILED"org.freedesktop.DBus.Error.Failed", "Previously requested freezer operation for unit '%s' is still in progress.", u->id); |
669 | if (r < 0) |
670 | return r; |
671 | if (r == 0) |
672 | reply_no_delay = true1; |
673 | |
674 | assert(!u->pending_freezer_message)do { if ((__builtin_expect(!!(!(!u->pending_freezer_message )),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("!u->pending_freezer_message" ), "../src/core/dbus-unit.c", 674, __PRETTY_FUNCTION__); } while (0); |
675 | |
676 | r = sd_bus_message_new_method_return(message, &u->pending_freezer_message); |
677 | if (r < 0) |
678 | return r; |
679 | |
680 | if (reply_no_delay) { |
681 | r = bus_unit_send_pending_freezer_message(u); |
682 | if (r < 0) |
683 | return r; |
684 | } |
685 | |
686 | return 1; |
687 | } |
688 | |
689 | int bus_unit_method_thaw(sd_bus_message *message, void *userdata, sd_bus_error *error) { |
690 | return bus_unit_method_freezer_generic(message, userdata, error, FREEZER_THAW); |
691 | } |
692 | |
693 | int bus_unit_method_freeze(sd_bus_message *message, void *userdata, sd_bus_error *error) { |
694 | return bus_unit_method_freezer_generic(message, userdata, error, FREEZER_FREEZE); |
695 | } |
696 | |
697 | const sd_bus_vtable bus_unit_vtable[] = { |
698 | SD_BUS_VTABLE_START(0){ .type = _SD_BUS_VTABLE_START, .flags = 0, .x = { .start = { .element_size = sizeof(sd_bus_vtable) }, }, }, |
699 | |
700 | SD_BUS_PROPERTY("Id", "s", NULL, offsetof(Unit, id), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "Id", .signature = "s", .get = ((void*)0), .set = ((void*)0), .offset = __builtin_offsetof (Unit, id), }, }, }, |
701 | SD_BUS_PROPERTY("Names", "as", property_get_names, offsetof(Unit, names), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "Names", .signature = "as", . get = property_get_names, .set = ((void*)0), .offset = __builtin_offsetof (Unit, names), }, }, }, |
702 | SD_BUS_PROPERTY("Following", "s", property_get_following, 0, 0){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = 0, .x = { .property = { .member = "Following", .signature = "s", .get = property_get_following , .set = ((void*)0), .offset = 0, }, }, }, |
703 | SD_BUS_PROPERTY("Requires", "as", property_get_dependencies, offsetof(Unit, dependencies[UNIT_REQUIRES]), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "Requires", .signature = "as" , .get = property_get_dependencies, .set = ((void*)0), .offset = __builtin_offsetof(Unit, dependencies[UNIT_REQUIRES]), }, } , }, |
704 | SD_BUS_PROPERTY("Requisite", "as", property_get_dependencies, offsetof(Unit, dependencies[UNIT_REQUISITE]), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "Requisite", .signature = "as" , .get = property_get_dependencies, .set = ((void*)0), .offset = __builtin_offsetof(Unit, dependencies[UNIT_REQUISITE]), }, }, }, |
705 | SD_BUS_PROPERTY("Wants", "as", property_get_dependencies, offsetof(Unit, dependencies[UNIT_WANTS]), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "Wants", .signature = "as", . get = property_get_dependencies, .set = ((void*)0), .offset = __builtin_offsetof(Unit, dependencies[UNIT_WANTS]), }, }, }, |
706 | SD_BUS_PROPERTY("BindsTo", "as", property_get_dependencies, offsetof(Unit, dependencies[UNIT_BINDS_TO]), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "BindsTo", .signature = "as" , .get = property_get_dependencies, .set = ((void*)0), .offset = __builtin_offsetof(Unit, dependencies[UNIT_BINDS_TO]), }, } , }, |
707 | SD_BUS_PROPERTY("PartOf", "as", property_get_dependencies, offsetof(Unit, dependencies[UNIT_PART_OF]), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "PartOf", .signature = "as", .get = property_get_dependencies, .set = ((void*)0), .offset = __builtin_offsetof(Unit, dependencies[UNIT_PART_OF]), }, } , }, |
708 | SD_BUS_PROPERTY("RequiredBy", "as", property_get_dependencies, offsetof(Unit, dependencies[UNIT_REQUIRED_BY]), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "RequiredBy", .signature = "as" , .get = property_get_dependencies, .set = ((void*)0), .offset = __builtin_offsetof(Unit, dependencies[UNIT_REQUIRED_BY]), } , }, }, |
709 | SD_BUS_PROPERTY("RequisiteOf", "as", property_get_dependencies, offsetof(Unit, dependencies[UNIT_REQUISITE_OF]), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "RequisiteOf", .signature = "as" , .get = property_get_dependencies, .set = ((void*)0), .offset = __builtin_offsetof(Unit, dependencies[UNIT_REQUISITE_OF]), }, }, }, |
710 | SD_BUS_PROPERTY("WantedBy", "as", property_get_dependencies, offsetof(Unit, dependencies[UNIT_WANTED_BY]), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "WantedBy", .signature = "as" , .get = property_get_dependencies, .set = ((void*)0), .offset = __builtin_offsetof(Unit, dependencies[UNIT_WANTED_BY]), }, }, }, |
711 | SD_BUS_PROPERTY("BoundBy", "as", property_get_dependencies, offsetof(Unit, dependencies[UNIT_BOUND_BY]), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "BoundBy", .signature = "as" , .get = property_get_dependencies, .set = ((void*)0), .offset = __builtin_offsetof(Unit, dependencies[UNIT_BOUND_BY]), }, } , }, |
712 | SD_BUS_PROPERTY("ConsistsOf", "as", property_get_dependencies, offsetof(Unit, dependencies[UNIT_CONSISTS_OF]), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "ConsistsOf", .signature = "as" , .get = property_get_dependencies, .set = ((void*)0), .offset = __builtin_offsetof(Unit, dependencies[UNIT_CONSISTS_OF]), } , }, }, |
713 | SD_BUS_PROPERTY("Conflicts", "as", property_get_dependencies, offsetof(Unit, dependencies[UNIT_CONFLICTS]), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "Conflicts", .signature = "as" , .get = property_get_dependencies, .set = ((void*)0), .offset = __builtin_offsetof(Unit, dependencies[UNIT_CONFLICTS]), }, }, }, |
714 | SD_BUS_PROPERTY("ConflictedBy", "as", property_get_dependencies, offsetof(Unit, dependencies[UNIT_CONFLICTED_BY]), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "ConflictedBy", .signature = "as", .get = property_get_dependencies, .set = ((void*)0), . offset = __builtin_offsetof(Unit, dependencies[UNIT_CONFLICTED_BY ]), }, }, }, |
715 | SD_BUS_PROPERTY("Before", "as", property_get_dependencies, offsetof(Unit, dependencies[UNIT_BEFORE]), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "Before", .signature = "as", .get = property_get_dependencies, .set = ((void*)0), .offset = __builtin_offsetof(Unit, dependencies[UNIT_BEFORE]), }, }, }, |
716 | SD_BUS_PROPERTY("After", "as", property_get_dependencies, offsetof(Unit, dependencies[UNIT_AFTER]), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "After", .signature = "as", . get = property_get_dependencies, .set = ((void*)0), .offset = __builtin_offsetof(Unit, dependencies[UNIT_AFTER]), }, }, }, |
717 | SD_BUS_PROPERTY("OnFailure", "as", property_get_dependencies, offsetof(Unit, dependencies[UNIT_ON_FAILURE]), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "OnFailure", .signature = "as" , .get = property_get_dependencies, .set = ((void*)0), .offset = __builtin_offsetof(Unit, dependencies[UNIT_ON_FAILURE]), } , }, }, |
718 | SD_BUS_PROPERTY("Triggers", "as", property_get_dependencies, offsetof(Unit, dependencies[UNIT_TRIGGERS]), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "Triggers", .signature = "as" , .get = property_get_dependencies, .set = ((void*)0), .offset = __builtin_offsetof(Unit, dependencies[UNIT_TRIGGERS]), }, } , }, |
719 | SD_BUS_PROPERTY("TriggeredBy", "as", property_get_dependencies, offsetof(Unit, dependencies[UNIT_TRIGGERED_BY]), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "TriggeredBy", .signature = "as" , .get = property_get_dependencies, .set = ((void*)0), .offset = __builtin_offsetof(Unit, dependencies[UNIT_TRIGGERED_BY]), }, }, }, |
720 | SD_BUS_PROPERTY("PropagatesReloadTo", "as", property_get_dependencies, offsetof(Unit, dependencies[UNIT_PROPAGATES_RELOAD_TO]), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "PropagatesReloadTo", .signature = "as", .get = property_get_dependencies, .set = ((void*)0), .offset = __builtin_offsetof(Unit, dependencies[UNIT_PROPAGATES_RELOAD_TO ]), }, }, }, |
721 | SD_BUS_PROPERTY("ReloadPropagatedFrom", "as", property_get_dependencies, offsetof(Unit, dependencies[UNIT_RELOAD_PROPAGATED_FROM]), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "ReloadPropagatedFrom", .signature = "as", .get = property_get_dependencies, .set = ((void*)0), .offset = __builtin_offsetof(Unit, dependencies[UNIT_RELOAD_PROPAGATED_FROM ]), }, }, }, |
722 | SD_BUS_PROPERTY("JoinsNamespaceOf", "as", property_get_dependencies, offsetof(Unit, dependencies[UNIT_JOINS_NAMESPACE_OF]), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "JoinsNamespaceOf", .signature = "as", .get = property_get_dependencies, .set = ((void*)0), .offset = __builtin_offsetof(Unit, dependencies[UNIT_JOINS_NAMESPACE_OF ]), }, }, }, |
723 | SD_BUS_PROPERTY("RequiresMountsFor", "as", property_get_requires_mounts_for, offsetof(Unit, requires_mounts_for), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "RequiresMountsFor", .signature = "as", .get = property_get_requires_mounts_for, .set = ((void *)0), .offset = __builtin_offsetof(Unit, requires_mounts_for) , }, }, }, |
724 | SD_BUS_PROPERTY("Documentation", "as", NULL, offsetof(Unit, documentation), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "Documentation", .signature = "as", .get = ((void*)0), .set = ((void*)0), .offset = __builtin_offsetof (Unit, documentation), }, }, }, |
725 | SD_BUS_PROPERTY("Description", "s", property_get_description, 0, SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "Description", .signature = "s" , .get = property_get_description, .set = ((void*)0), .offset = 0, }, }, }, |
726 | SD_BUS_PROPERTY("LoadState", "s", property_get_load_state, offsetof(Unit, load_state), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "LoadState", .signature = "s" , .get = property_get_load_state, .set = ((void*)0), .offset = __builtin_offsetof(Unit, load_state), }, }, }, |
727 | SD_BUS_PROPERTY("ActiveState", "s", property_get_active_state, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE , .x = { .property = { .member = "ActiveState", .signature = "s" , .get = property_get_active_state, .set = ((void*)0), .offset = 0, }, }, }, |
728 | SD_BUS_PROPERTY("FreezerState", "s", property_get_freezer_state, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE , .x = { .property = { .member = "FreezerState", .signature = "s", .get = property_get_freezer_state, .set = ((void*)0), . offset = 0, }, }, }, |
729 | SD_BUS_PROPERTY("SubState", "s", property_get_sub_state, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE , .x = { .property = { .member = "SubState", .signature = "s" , .get = property_get_sub_state, .set = ((void*)0), .offset = 0, }, }, }, |
730 | SD_BUS_PROPERTY("FragmentPath", "s", NULL, offsetof(Unit, fragment_path), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "FragmentPath", .signature = "s", .get = ((void*)0), .set = ((void*)0), .offset = __builtin_offsetof (Unit, fragment_path), }, }, }, |
731 | SD_BUS_PROPERTY("SourcePath", "s", NULL, offsetof(Unit, source_path), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "SourcePath", .signature = "s" , .get = ((void*)0), .set = ((void*)0), .offset = __builtin_offsetof (Unit, source_path), }, }, }, |
732 | SD_BUS_PROPERTY("DropInPaths", "as", NULL, offsetof(Unit, dropin_paths), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "DropInPaths", .signature = "as" , .get = ((void*)0), .set = ((void*)0), .offset = __builtin_offsetof (Unit, dropin_paths), }, }, }, |
733 | SD_BUS_PROPERTY("UnitFileState", "s", property_get_unit_file_state, 0, 0){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = 0, .x = { .property = { .member = "UnitFileState", .signature = "s", .get = property_get_unit_file_state , .set = ((void*)0), .offset = 0, }, }, }, |
734 | SD_BUS_PROPERTY("UnitFilePreset", "s", property_get_unit_file_preset, 0, 0){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = 0, .x = { .property = { .member = "UnitFilePreset", .signature = "s", .get = property_get_unit_file_preset , .set = ((void*)0), .offset = 0, }, }, }, |
735 | BUS_PROPERTY_DUAL_TIMESTAMP("StateChangeTimestamp", offsetof(Unit, state_change_timestamp), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = (SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE ), .x = { .property = { .member = "StateChangeTimestamp", .signature = "t", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ( (void*)0), .offset = (__builtin_offsetof(Unit, state_change_timestamp )) + __builtin_offsetof(struct dual_timestamp, realtime), }, } , }, { .type = _SD_BUS_VTABLE_PROPERTY, .flags = (SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE ), .x = { .property = { .member = "StateChangeTimestamp" "Monotonic" , .signature = "t", .get = ((sd_bus_property_get_t) ((void*)0 )), .set = ((void*)0), .offset = (__builtin_offsetof(Unit, state_change_timestamp )) + __builtin_offsetof(struct dual_timestamp, monotonic), }, }, }, |
736 | BUS_PROPERTY_DUAL_TIMESTAMP("InactiveExitTimestamp", offsetof(Unit, inactive_exit_timestamp), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = (SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE ), .x = { .property = { .member = "InactiveExitTimestamp", .signature = "t", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ( (void*)0), .offset = (__builtin_offsetof(Unit, inactive_exit_timestamp )) + __builtin_offsetof(struct dual_timestamp, realtime), }, } , }, { .type = _SD_BUS_VTABLE_PROPERTY, .flags = (SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE ), .x = { .property = { .member = "InactiveExitTimestamp" "Monotonic" , .signature = "t", .get = ((sd_bus_property_get_t) ((void*)0 )), .set = ((void*)0), .offset = (__builtin_offsetof(Unit, inactive_exit_timestamp )) + __builtin_offsetof(struct dual_timestamp, monotonic), }, }, }, |
737 | BUS_PROPERTY_DUAL_TIMESTAMP("ActiveEnterTimestamp", offsetof(Unit, active_enter_timestamp), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = (SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE ), .x = { .property = { .member = "ActiveEnterTimestamp", .signature = "t", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ( (void*)0), .offset = (__builtin_offsetof(Unit, active_enter_timestamp )) + __builtin_offsetof(struct dual_timestamp, realtime), }, } , }, { .type = _SD_BUS_VTABLE_PROPERTY, .flags = (SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE ), .x = { .property = { .member = "ActiveEnterTimestamp" "Monotonic" , .signature = "t", .get = ((sd_bus_property_get_t) ((void*)0 )), .set = ((void*)0), .offset = (__builtin_offsetof(Unit, active_enter_timestamp )) + __builtin_offsetof(struct dual_timestamp, monotonic), }, }, }, |
738 | BUS_PROPERTY_DUAL_TIMESTAMP("ActiveExitTimestamp", offsetof(Unit, active_exit_timestamp), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = (SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE ), .x = { .property = { .member = "ActiveExitTimestamp", .signature = "t", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ( (void*)0), .offset = (__builtin_offsetof(Unit, active_exit_timestamp )) + __builtin_offsetof(struct dual_timestamp, realtime), }, } , }, { .type = _SD_BUS_VTABLE_PROPERTY, .flags = (SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE ), .x = { .property = { .member = "ActiveExitTimestamp" "Monotonic" , .signature = "t", .get = ((sd_bus_property_get_t) ((void*)0 )), .set = ((void*)0), .offset = (__builtin_offsetof(Unit, active_exit_timestamp )) + __builtin_offsetof(struct dual_timestamp, monotonic), }, }, }, |
739 | BUS_PROPERTY_DUAL_TIMESTAMP("InactiveEnterTimestamp", offsetof(Unit, inactive_enter_timestamp), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = (SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE ), .x = { .property = { .member = "InactiveEnterTimestamp", . signature = "t", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ((void*)0), .offset = (__builtin_offsetof(Unit, inactive_enter_timestamp )) + __builtin_offsetof(struct dual_timestamp, realtime), }, } , }, { .type = _SD_BUS_VTABLE_PROPERTY, .flags = (SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE ), .x = { .property = { .member = "InactiveEnterTimestamp" "Monotonic" , .signature = "t", .get = ((sd_bus_property_get_t) ((void*)0 )), .set = ((void*)0), .offset = (__builtin_offsetof(Unit, inactive_enter_timestamp )) + __builtin_offsetof(struct dual_timestamp, monotonic), }, }, }, |
740 | SD_BUS_PROPERTY("CanStart", "b", property_get_can_start, 0, SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "CanStart", .signature = "b" , .get = property_get_can_start, .set = ((void*)0), .offset = 0, }, }, }, |
741 | SD_BUS_PROPERTY("CanStop", "b", property_get_can_stop, 0, SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "CanStop", .signature = "b", .get = property_get_can_stop, .set = ((void*)0), .offset = 0 , }, }, }, |
742 | SD_BUS_PROPERTY("CanReload", "b", property_get_can_reload, 0, SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "CanReload", .signature = "b" , .get = property_get_can_reload, .set = ((void*)0), .offset = 0, }, }, }, |
743 | SD_BUS_PROPERTY("CanIsolate", "b", property_get_can_isolate, 0, SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "CanIsolate", .signature = "b" , .get = property_get_can_isolate, .set = ((void*)0), .offset = 0, }, }, }, |
744 | SD_BUS_PROPERTY("CanFreeze", "b", property_get_can_freeze, 0, SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "CanFreeze", .signature = "b" , .get = property_get_can_freeze, .set = ((void*)0), .offset = 0, }, }, }, |
745 | SD_BUS_PROPERTY("Job", "(uo)", property_get_job, offsetof(Unit, job), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE , .x = { .property = { .member = "Job", .signature = "(uo)", . get = property_get_job, .set = ((void*)0), .offset = __builtin_offsetof (Unit, job), }, }, }, |
746 | SD_BUS_PROPERTY("StopWhenUnneeded", "b", bus_property_get_bool, offsetof(Unit, stop_when_unneeded), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "StopWhenUnneeded", .signature = "b", .get = bus_property_get_bool, .set = ((void*)0), .offset = __builtin_offsetof(Unit, stop_when_unneeded), }, }, }, |
747 | SD_BUS_PROPERTY("RefuseManualStart", "b", bus_property_get_bool, offsetof(Unit, refuse_manual_start), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "RefuseManualStart", .signature = "b", .get = bus_property_get_bool, .set = ((void*)0), .offset = __builtin_offsetof(Unit, refuse_manual_start), }, }, }, |
748 | SD_BUS_PROPERTY("RefuseManualStop", "b", bus_property_get_bool, offsetof(Unit, refuse_manual_stop), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "RefuseManualStop", .signature = "b", .get = bus_property_get_bool, .set = ((void*)0), .offset = __builtin_offsetof(Unit, refuse_manual_stop), }, }, }, |
749 | SD_BUS_PROPERTY("AllowIsolate", "b", bus_property_get_bool, offsetof(Unit, allow_isolate), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "AllowIsolate", .signature = "b", .get = bus_property_get_bool, .set = ((void*)0), .offset = __builtin_offsetof(Unit, allow_isolate), }, }, }, |
750 | SD_BUS_PROPERTY("DefaultDependencies", "b", bus_property_get_bool, offsetof(Unit, default_dependencies), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "DefaultDependencies", .signature = "b", .get = bus_property_get_bool, .set = ((void*)0), .offset = __builtin_offsetof(Unit, default_dependencies), }, }, }, |
751 | SD_BUS_PROPERTY("OnFailureJobMode", "s", property_get_job_mode, offsetof(Unit, on_failure_job_mode), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "OnFailureJobMode", .signature = "s", .get = property_get_job_mode, .set = ((void*)0), .offset = __builtin_offsetof(Unit, on_failure_job_mode), }, }, }, |
752 | SD_BUS_PROPERTY("IgnoreOnIsolate", "b", bus_property_get_bool, offsetof(Unit, ignore_on_isolate), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "IgnoreOnIsolate", .signature = "b", .get = bus_property_get_bool, .set = ((void*)0), .offset = __builtin_offsetof(Unit, ignore_on_isolate), }, }, }, |
753 | SD_BUS_PROPERTY("NeedDaemonReload", "b", property_get_need_daemon_reload, 0, SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "NeedDaemonReload", .signature = "b", .get = property_get_need_daemon_reload, .set = ((void *)0), .offset = 0, }, }, }, |
754 | SD_BUS_PROPERTY("JobTimeoutUSec", "t", bus_property_get_usec, offsetof(Unit, job_timeout), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "JobTimeoutUSec", .signature = "t", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ( (void*)0), .offset = __builtin_offsetof(Unit, job_timeout), } , }, }, |
755 | SD_BUS_PROPERTY("JobRunningTimeoutUSec", "t", bus_property_get_usec, offsetof(Unit, job_running_timeout), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "JobRunningTimeoutUSec", .signature = "t", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ( (void*)0), .offset = __builtin_offsetof(Unit, job_running_timeout ), }, }, }, |
756 | SD_BUS_PROPERTY("JobTimeoutAction", "s", property_get_emergency_action, offsetof(Unit, job_timeout_action), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "JobTimeoutAction", .signature = "s", .get = property_get_emergency_action, .set = ((void*) 0), .offset = __builtin_offsetof(Unit, job_timeout_action), } , }, }, |
757 | SD_BUS_PROPERTY("JobTimeoutRebootArgument", "s", NULL, offsetof(Unit, job_timeout_reboot_arg), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "JobTimeoutRebootArgument", . signature = "s", .get = ((void*)0), .set = ((void*)0), .offset = __builtin_offsetof(Unit, job_timeout_reboot_arg), }, }, }, |
758 | SD_BUS_PROPERTY("ConditionResult", "b", bus_property_get_bool, offsetof(Unit, condition_result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE , .x = { .property = { .member = "ConditionResult", .signature = "b", .get = bus_property_get_bool, .set = ((void*)0), .offset = __builtin_offsetof(Unit, condition_result), }, }, }, |
759 | SD_BUS_PROPERTY("AssertResult", "b", bus_property_get_bool, offsetof(Unit, assert_result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE , .x = { .property = { .member = "AssertResult", .signature = "b", .get = bus_property_get_bool, .set = ((void*)0), .offset = __builtin_offsetof(Unit, assert_result), }, }, }, |
760 | BUS_PROPERTY_DUAL_TIMESTAMP("ConditionTimestamp", offsetof(Unit, condition_timestamp), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = (SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE ), .x = { .property = { .member = "ConditionTimestamp", .signature = "t", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ( (void*)0), .offset = (__builtin_offsetof(Unit, condition_timestamp )) + __builtin_offsetof(struct dual_timestamp, realtime), }, } , }, { .type = _SD_BUS_VTABLE_PROPERTY, .flags = (SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE ), .x = { .property = { .member = "ConditionTimestamp" "Monotonic" , .signature = "t", .get = ((sd_bus_property_get_t) ((void*)0 )), .set = ((void*)0), .offset = (__builtin_offsetof(Unit, condition_timestamp )) + __builtin_offsetof(struct dual_timestamp, monotonic), }, }, }, |
761 | BUS_PROPERTY_DUAL_TIMESTAMP("AssertTimestamp", offsetof(Unit, assert_timestamp), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = (SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE ), .x = { .property = { .member = "AssertTimestamp", .signature = "t", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ( (void*)0), .offset = (__builtin_offsetof(Unit, assert_timestamp )) + __builtin_offsetof(struct dual_timestamp, realtime), }, } , }, { .type = _SD_BUS_VTABLE_PROPERTY, .flags = (SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE ), .x = { .property = { .member = "AssertTimestamp" "Monotonic" , .signature = "t", .get = ((sd_bus_property_get_t) ((void*)0 )), .set = ((void*)0), .offset = (__builtin_offsetof(Unit, assert_timestamp )) + __builtin_offsetof(struct dual_timestamp, monotonic), }, }, }, |
762 | SD_BUS_PROPERTY("Conditions", "a(sbbsi)", property_get_conditions, offsetof(Unit, conditions), 0){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = 0, .x = { .property = { .member = "Conditions", .signature = "a(sbbsi)", .get = property_get_conditions , .set = ((void*)0), .offset = __builtin_offsetof(Unit, conditions ), }, }, }, |
763 | SD_BUS_PROPERTY("Asserts", "a(sbbsi)", property_get_conditions, offsetof(Unit, asserts), 0){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = 0, .x = { .property = { .member = "Asserts", .signature = "a(sbbsi)", .get = property_get_conditions , .set = ((void*)0), .offset = __builtin_offsetof(Unit, asserts ), }, }, }, |
764 | SD_BUS_PROPERTY("LoadError", "(ss)", property_get_load_error, 0, SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "LoadError", .signature = "(ss)" , .get = property_get_load_error, .set = ((void*)0), .offset = 0, }, }, }, |
765 | SD_BUS_PROPERTY("Transient", "b", bus_property_get_bool, offsetof(Unit, transient), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "Transient", .signature = "b" , .get = bus_property_get_bool, .set = ((void*)0), .offset = __builtin_offsetof (Unit, transient), }, }, }, |
766 | SD_BUS_PROPERTY("Perpetual", "b", bus_property_get_bool, offsetof(Unit, perpetual), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "Perpetual", .signature = "b" , .get = bus_property_get_bool, .set = ((void*)0), .offset = __builtin_offsetof (Unit, perpetual), }, }, }, |
767 | SD_BUS_PROPERTY("StartLimitIntervalUSec", "t", bus_property_get_usec, offsetof(Unit, start_limit.interval), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "StartLimitIntervalUSec", .signature = "t", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ( (void*)0), .offset = __builtin_offsetof(Unit, start_limit.interval ), }, }, }, |
768 | SD_BUS_PROPERTY("StartLimitBurst", "u", bus_property_get_unsigned, offsetof(Unit, start_limit.burst), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "StartLimitBurst", .signature = "u", .get = ((sd_bus_property_get_t) ((void*)0)), .set = ( (void*)0), .offset = __builtin_offsetof(Unit, start_limit.burst ), }, }, }, |
769 | SD_BUS_PROPERTY("StartLimitAction", "s", property_get_emergency_action, offsetof(Unit, start_limit_action), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "StartLimitAction", .signature = "s", .get = property_get_emergency_action, .set = ((void*) 0), .offset = __builtin_offsetof(Unit, start_limit_action), } , }, }, |
770 | SD_BUS_PROPERTY("FailureAction", "s", property_get_emergency_action, offsetof(Unit, failure_action), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "FailureAction", .signature = "s", .get = property_get_emergency_action, .set = ((void*)0) , .offset = __builtin_offsetof(Unit, failure_action), }, }, }, |
771 | SD_BUS_PROPERTY("SuccessAction", "s", property_get_emergency_action, offsetof(Unit, success_action), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "SuccessAction", .signature = "s", .get = property_get_emergency_action, .set = ((void*)0) , .offset = __builtin_offsetof(Unit, success_action), }, }, }, |
772 | SD_BUS_PROPERTY("RebootArgument", "s", NULL, offsetof(Unit, reboot_arg), SD_BUS_VTABLE_PROPERTY_CONST){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST , .x = { .property = { .member = "RebootArgument", .signature = "s", .get = ((void*)0), .set = ((void*)0), .offset = __builtin_offsetof (Unit, reboot_arg), }, }, }, |
773 | SD_BUS_PROPERTY("InvocationID", "ay", bus_property_get_id128, offsetof(Unit, invocation_id), 0){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = 0, .x = { .property = { .member = "InvocationID", .signature = "ay", .get = bus_property_get_id128 , .set = ((void*)0), .offset = __builtin_offsetof(Unit, invocation_id ), }, }, }, |
774 | SD_BUS_PROPERTY("CollectMode", "s", property_get_collect_mode, offsetof(Unit, collect_mode), 0){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = 0, .x = { .property = { .member = "CollectMode", .signature = "s", .get = property_get_collect_mode , .set = ((void*)0), .offset = __builtin_offsetof(Unit, collect_mode ), }, }, }, |
775 | |
776 | SD_BUS_METHOD("Start", "s", "o", method_start, SD_BUS_VTABLE_UNPRIVILEGED){ .type = _SD_BUS_VTABLE_METHOD, .flags = SD_BUS_VTABLE_UNPRIVILEGED , .x = { .method = { .member = "Start", .signature = "s", .result = "o", .handler = method_start, .offset = 0, }, }, }, |
777 | SD_BUS_METHOD("Stop", "s", "o", method_stop, SD_BUS_VTABLE_UNPRIVILEGED){ .type = _SD_BUS_VTABLE_METHOD, .flags = SD_BUS_VTABLE_UNPRIVILEGED , .x = { .method = { .member = "Stop", .signature = "s", .result = "o", .handler = method_stop, .offset = 0, }, }, }, |
778 | SD_BUS_METHOD("Reload", "s", "o", method_reload, SD_BUS_VTABLE_UNPRIVILEGED){ .type = _SD_BUS_VTABLE_METHOD, .flags = SD_BUS_VTABLE_UNPRIVILEGED , .x = { .method = { .member = "Reload", .signature = "s", .result = "o", .handler = method_reload, .offset = 0, }, }, }, |
779 | SD_BUS_METHOD("Restart", "s", "o", method_restart, SD_BUS_VTABLE_UNPRIVILEGED){ .type = _SD_BUS_VTABLE_METHOD, .flags = SD_BUS_VTABLE_UNPRIVILEGED , .x = { .method = { .member = "Restart", .signature = "s", . result = "o", .handler = method_restart, .offset = 0, }, }, }, |
780 | SD_BUS_METHOD("TryRestart", "s", "o", method_try_restart, SD_BUS_VTABLE_UNPRIVILEGED){ .type = _SD_BUS_VTABLE_METHOD, .flags = SD_BUS_VTABLE_UNPRIVILEGED , .x = { .method = { .member = "TryRestart", .signature = "s" , .result = "o", .handler = method_try_restart, .offset = 0, } , }, }, |
781 | SD_BUS_METHOD("ReloadOrRestart", "s", "o", method_reload_or_restart, SD_BUS_VTABLE_UNPRIVILEGED){ .type = _SD_BUS_VTABLE_METHOD, .flags = SD_BUS_VTABLE_UNPRIVILEGED , .x = { .method = { .member = "ReloadOrRestart", .signature = "s", .result = "o", .handler = method_reload_or_restart, .offset = 0, }, }, }, |
782 | SD_BUS_METHOD("ReloadOrTryRestart", "s", "o", method_reload_or_try_restart, SD_BUS_VTABLE_UNPRIVILEGED){ .type = _SD_BUS_VTABLE_METHOD, .flags = SD_BUS_VTABLE_UNPRIVILEGED , .x = { .method = { .member = "ReloadOrTryRestart", .signature = "s", .result = "o", .handler = method_reload_or_try_restart , .offset = 0, }, }, }, |
783 | SD_BUS_METHOD("EnqueueJob", "ss", "uososa(uosos)", bus_unit_method_enqueue_job, SD_BUS_VTABLE_UNPRIVILEGED){ .type = _SD_BUS_VTABLE_METHOD, .flags = SD_BUS_VTABLE_UNPRIVILEGED , .x = { .method = { .member = "EnqueueJob", .signature = "ss" , .result = "uososa(uosos)", .handler = bus_unit_method_enqueue_job , .offset = 0, }, }, }, |
784 | SD_BUS_METHOD("Kill", "si", NULL, bus_unit_method_kill, SD_BUS_VTABLE_UNPRIVILEGED){ .type = _SD_BUS_VTABLE_METHOD, .flags = SD_BUS_VTABLE_UNPRIVILEGED , .x = { .method = { .member = "Kill", .signature = "si", .result = ((void*)0), .handler = bus_unit_method_kill, .offset = 0, } , }, }, |
785 | SD_BUS_METHOD("ResetFailed", NULL, NULL, bus_unit_method_reset_failed, SD_BUS_VTABLE_UNPRIVILEGED){ .type = _SD_BUS_VTABLE_METHOD, .flags = SD_BUS_VTABLE_UNPRIVILEGED , .x = { .method = { .member = "ResetFailed", .signature = (( void*)0), .result = ((void*)0), .handler = bus_unit_method_reset_failed , .offset = 0, }, }, }, |
786 | SD_BUS_METHOD("SetProperties", "ba(sv)", NULL, bus_unit_method_set_properties, SD_BUS_VTABLE_UNPRIVILEGED){ .type = _SD_BUS_VTABLE_METHOD, .flags = SD_BUS_VTABLE_UNPRIVILEGED , .x = { .method = { .member = "SetProperties", .signature = "ba(sv)" , .result = ((void*)0), .handler = bus_unit_method_set_properties , .offset = 0, }, }, }, |
787 | SD_BUS_METHOD("Ref", NULL, NULL, bus_unit_method_ref, SD_BUS_VTABLE_UNPRIVILEGED){ .type = _SD_BUS_VTABLE_METHOD, .flags = SD_BUS_VTABLE_UNPRIVILEGED , .x = { .method = { .member = "Ref", .signature = ((void*)0) , .result = ((void*)0), .handler = bus_unit_method_ref, .offset = 0, }, }, }, |
788 | SD_BUS_METHOD("Unref", NULL, NULL, bus_unit_method_unref, SD_BUS_VTABLE_UNPRIVILEGED){ .type = _SD_BUS_VTABLE_METHOD, .flags = SD_BUS_VTABLE_UNPRIVILEGED , .x = { .method = { .member = "Unref", .signature = ((void*) 0), .result = ((void*)0), .handler = bus_unit_method_unref, . offset = 0, }, }, }, |
789 | SD_BUS_METHOD("Freeze", NULL, NULL, bus_unit_method_freeze, SD_BUS_VTABLE_UNPRIVILEGED){ .type = _SD_BUS_VTABLE_METHOD, .flags = SD_BUS_VTABLE_UNPRIVILEGED , .x = { .method = { .member = "Freeze", .signature = ((void* )0), .result = ((void*)0), .handler = bus_unit_method_freeze, .offset = 0, }, }, }, |
790 | SD_BUS_METHOD("Thaw", NULL, NULL, bus_unit_method_thaw, SD_BUS_VTABLE_UNPRIVILEGED){ .type = _SD_BUS_VTABLE_METHOD, .flags = SD_BUS_VTABLE_UNPRIVILEGED , .x = { .method = { .member = "Thaw", .signature = ((void*)0 ), .result = ((void*)0), .handler = bus_unit_method_thaw, .offset = 0, }, }, }, |
791 | |
792 | /* For dependency types we don't support anymore always return an empty array */ |
793 | SD_BUS_PROPERTY("RequiresOverridable", "as", property_get_empty_strv, 0, SD_BUS_VTABLE_HIDDEN){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_HIDDEN , .x = { .property = { .member = "RequiresOverridable", .signature = "as", .get = property_get_empty_strv, .set = ((void*)0), . offset = 0, }, }, }, |
794 | SD_BUS_PROPERTY("RequisiteOverridable", "as", property_get_empty_strv, 0, SD_BUS_VTABLE_HIDDEN){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_HIDDEN , .x = { .property = { .member = "RequisiteOverridable", .signature = "as", .get = property_get_empty_strv, .set = ((void*)0), . offset = 0, }, }, }, |
795 | SD_BUS_PROPERTY("RequiredByOverridable", "as", property_get_empty_strv, 0, SD_BUS_VTABLE_HIDDEN){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_HIDDEN , .x = { .property = { .member = "RequiredByOverridable", .signature = "as", .get = property_get_empty_strv, .set = ((void*)0), . offset = 0, }, }, }, |
796 | SD_BUS_PROPERTY("RequisiteOfOverridable", "as", property_get_empty_strv, 0, SD_BUS_VTABLE_HIDDEN){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_HIDDEN , .x = { .property = { .member = "RequisiteOfOverridable", .signature = "as", .get = property_get_empty_strv, .set = ((void*)0), . offset = 0, }, }, }, |
797 | /* Obsolete alias names */ |
798 | SD_BUS_PROPERTY("StartLimitInterval", "t", bus_property_get_usec, offsetof(Unit, start_limit.interval), SD_BUS_VTABLE_PROPERTY_CONST|SD_BUS_VTABLE_HIDDEN){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST |SD_BUS_VTABLE_HIDDEN, .x = { .property = { .member = "StartLimitInterval" , .signature = "t", .get = ((sd_bus_property_get_t) ((void*)0 )), .set = ((void*)0), .offset = __builtin_offsetof(Unit, start_limit .interval), }, }, }, |
799 | SD_BUS_PROPERTY("StartLimitIntervalSec", "t", bus_property_get_usec, offsetof(Unit, start_limit.interval), SD_BUS_VTABLE_PROPERTY_CONST|SD_BUS_VTABLE_HIDDEN){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = SD_BUS_VTABLE_PROPERTY_CONST |SD_BUS_VTABLE_HIDDEN, .x = { .property = { .member = "StartLimitIntervalSec" , .signature = "t", .get = ((sd_bus_property_get_t) ((void*)0 )), .set = ((void*)0), .offset = __builtin_offsetof(Unit, start_limit .interval), }, }, }, |
800 | SD_BUS_VTABLE_END{ .type = _SD_BUS_VTABLE_END, .flags = 0, .x = { { 0 } }, } |
801 | }; |
802 | |
803 | static int property_get_slice( |
804 | sd_bus *bus, |
805 | const char *path, |
806 | const char *interface, |
807 | const char *property, |
808 | sd_bus_message *reply, |
809 | void *userdata, |
810 | sd_bus_error *error) { |
811 | |
812 | Unit *u = userdata; |
813 | |
814 | assert(bus)do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 814, __PRETTY_FUNCTION__ ); } while (0); |
815 | assert(reply)do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 815 , __PRETTY_FUNCTION__); } while (0); |
816 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 816, __PRETTY_FUNCTION__ ); } while (0); |
817 | |
818 | return sd_bus_message_append(reply, "s", unit_slice_name(u)); |
819 | } |
820 | |
821 | static int property_get_current_memory( |
822 | sd_bus *bus, |
823 | const char *path, |
824 | const char *interface, |
825 | const char *property, |
826 | sd_bus_message *reply, |
827 | void *userdata, |
828 | sd_bus_error *error) { |
829 | |
830 | uint64_t sz = (uint64_t) -1; |
831 | Unit *u = userdata; |
832 | int r; |
833 | |
834 | assert(bus)do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 834, __PRETTY_FUNCTION__ ); } while (0); |
835 | assert(reply)do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 835 , __PRETTY_FUNCTION__); } while (0); |
836 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 836, __PRETTY_FUNCTION__ ); } while (0); |
837 | |
838 | r = unit_get_memory_current(u, &sz); |
839 | if (r < 0 && r != -ENODATA61) |
840 | log_unit_warning_errno(u, r, "Failed to get memory.usage_in_bytes attribute: %m")({ const Unit *_u = (u); _u ? log_object_internal(4, r, "../src/core/dbus-unit.c" , 840, __func__, _u->manager->unit_log_field, _u->id , _u->manager->invocation_log_field, _u->invocation_id_string , "Failed to get memory.usage_in_bytes attribute: %m") : log_internal_realm (((LOG_REALM_SYSTEMD) << 10 | ((4))), r, "../src/core/dbus-unit.c" , 840, __func__, "Failed to get memory.usage_in_bytes attribute: %m" ); }); |
841 | |
842 | return sd_bus_message_append(reply, "t", sz); |
843 | } |
844 | |
845 | static int property_get_current_tasks( |
846 | sd_bus *bus, |
847 | const char *path, |
848 | const char *interface, |
849 | const char *property, |
850 | sd_bus_message *reply, |
851 | void *userdata, |
852 | sd_bus_error *error) { |
853 | |
854 | uint64_t cn = (uint64_t) -1; |
855 | Unit *u = userdata; |
856 | int r; |
857 | |
858 | assert(bus)do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 858, __PRETTY_FUNCTION__ ); } while (0); |
859 | assert(reply)do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 859 , __PRETTY_FUNCTION__); } while (0); |
860 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 860, __PRETTY_FUNCTION__ ); } while (0); |
861 | |
862 | r = unit_get_tasks_current(u, &cn); |
863 | if (r < 0 && r != -ENODATA61) |
864 | log_unit_warning_errno(u, r, "Failed to get pids.current attribute: %m")({ const Unit *_u = (u); _u ? log_object_internal(4, r, "../src/core/dbus-unit.c" , 864, __func__, _u->manager->unit_log_field, _u->id , _u->manager->invocation_log_field, _u->invocation_id_string , "Failed to get pids.current attribute: %m") : log_internal_realm (((LOG_REALM_SYSTEMD) << 10 | ((4))), r, "../src/core/dbus-unit.c" , 864, __func__, "Failed to get pids.current attribute: %m"); }); |
865 | |
866 | return sd_bus_message_append(reply, "t", cn); |
867 | } |
868 | |
869 | static int property_get_cpu_usage( |
870 | sd_bus *bus, |
871 | const char *path, |
872 | const char *interface, |
873 | const char *property, |
874 | sd_bus_message *reply, |
875 | void *userdata, |
876 | sd_bus_error *error) { |
877 | |
878 | nsec_t ns = (nsec_t) -1; |
879 | Unit *u = userdata; |
880 | int r; |
881 | |
882 | assert(bus)do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 882, __PRETTY_FUNCTION__ ); } while (0); |
883 | assert(reply)do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 883 , __PRETTY_FUNCTION__); } while (0); |
884 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 884, __PRETTY_FUNCTION__ ); } while (0); |
885 | |
886 | r = unit_get_cpu_usage(u, &ns); |
887 | if (r < 0 && r != -ENODATA61) |
888 | log_unit_warning_errno(u, r, "Failed to get cpuacct.usage attribute: %m")({ const Unit *_u = (u); _u ? log_object_internal(4, r, "../src/core/dbus-unit.c" , 888, __func__, _u->manager->unit_log_field, _u->id , _u->manager->invocation_log_field, _u->invocation_id_string , "Failed to get cpuacct.usage attribute: %m") : log_internal_realm (((LOG_REALM_SYSTEMD) << 10 | ((4))), r, "../src/core/dbus-unit.c" , 888, __func__, "Failed to get cpuacct.usage attribute: %m") ; }); |
889 | |
890 | return sd_bus_message_append(reply, "t", ns); |
891 | } |
892 | |
893 | static int property_get_cpuset_cpus( |
894 | sd_bus *bus, |
895 | const char *path, |
896 | const char *interface, |
897 | const char *property, |
898 | sd_bus_message *reply, |
899 | void *userdata, |
900 | sd_bus_error *error) { |
901 | |
902 | Unit *u = userdata; |
903 | _cleanup_(cpu_set_reset)__attribute__((cleanup(cpu_set_reset))) CPUSet cpus = {}; |
904 | _cleanup_free___attribute__((cleanup(freep))) uint8_t *array = NULL((void*)0); |
905 | size_t allocated; |
906 | |
907 | assert(bus)do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 907, __PRETTY_FUNCTION__ ); } while (0); |
908 | assert(reply)do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 908 , __PRETTY_FUNCTION__); } while (0); |
909 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 909, __PRETTY_FUNCTION__ ); } while (0); |
910 | |
911 | (void) unit_get_cpuset(u, &cpus, "cpuset.cpus.effective"); |
912 | (void) cpu_set_to_dbus(&cpus, &array, &allocated); |
913 | return sd_bus_message_append_array(reply, 'y', array, allocated); |
914 | } |
915 | |
916 | static int property_get_cpuset_mems( |
917 | sd_bus *bus, |
918 | const char *path, |
919 | const char *interface, |
920 | const char *property, |
921 | sd_bus_message *reply, |
922 | void *userdata, |
923 | sd_bus_error *error) { |
924 | |
925 | Unit *u = userdata; |
926 | _cleanup_(cpu_set_reset)__attribute__((cleanup(cpu_set_reset))) CPUSet mems = {}; |
927 | _cleanup_free___attribute__((cleanup(freep))) uint8_t *array = NULL((void*)0); |
928 | size_t allocated; |
929 | |
930 | assert(bus)do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 930, __PRETTY_FUNCTION__ ); } while (0); |
931 | assert(reply)do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 931 , __PRETTY_FUNCTION__); } while (0); |
932 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 932, __PRETTY_FUNCTION__ ); } while (0); |
933 | |
934 | (void) unit_get_cpuset(u, &mems, "cpuset.mems.effective"); |
935 | (void) cpu_set_to_dbus(&mems, &array, &allocated); |
936 | return sd_bus_message_append_array(reply, 'y', array, allocated); |
937 | } |
938 | |
939 | static int property_get_cgroup( |
940 | sd_bus *bus, |
941 | const char *path, |
942 | const char *interface, |
943 | const char *property, |
944 | sd_bus_message *reply, |
945 | void *userdata, |
946 | sd_bus_error *error) { |
947 | |
948 | Unit *u = userdata; |
949 | const char *t = NULL((void*)0); |
950 | |
951 | assert(bus)do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 951, __PRETTY_FUNCTION__ ); } while (0); |
952 | assert(reply)do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 952 , __PRETTY_FUNCTION__); } while (0); |
953 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 953, __PRETTY_FUNCTION__ ); } while (0); |
954 | |
955 | /* Three cases: a) u->cgroup_path is NULL, in which case the |
956 | * unit has no control group, which we report as the empty |
957 | * string. b) u->cgroup_path is the empty string, which |
958 | * indicates the root cgroup, which we report as "/". c) all |
959 | * other cases we report as-is. */ |
960 | |
961 | if (u->cgroup_path) |
962 | t = empty_to_root(u->cgroup_path); |
963 | |
964 | return sd_bus_message_append(reply, "s", t); |
965 | } |
966 | |
967 | static int append_process(sd_bus_message *reply, const char *p, pid_t pid, Set *pids) { |
968 | _cleanup_free___attribute__((cleanup(freep))) char *buf = NULL((void*)0), *cmdline = NULL((void*)0); |
969 | int r; |
970 | |
971 | assert(reply)do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 971 , __PRETTY_FUNCTION__); } while (0); |
972 | assert(pid > 0)do { if ((__builtin_expect(!!(!(pid > 0)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("pid > 0"), "../src/core/dbus-unit.c" , 972, __PRETTY_FUNCTION__); } while (0); |
973 | |
974 | r = set_put(pids, PID_TO_PTR(pid)); |
975 | if (IN_SET(r, 0, -EEXIST)({ _Bool _found = 0; static __attribute__ ((unused)) char _static_assert__macros_need_to_be_extended [20 - sizeof((int[]){0, -17})/sizeof(int)]; switch(r) { case 0 : case -17: _found = 1; break; default: break; } _found; })) |
976 | return 0; |
977 | if (r < 0) |
978 | return r; |
979 | |
980 | if (!p) { |
981 | r = cg_pid_get_path(SYSTEMD_CGROUP_CONTROLLER"_systemd", pid, &buf); |
982 | if (r == -ESRCH3) |
983 | return 0; |
984 | if (r < 0) |
985 | return r; |
986 | |
987 | p = buf; |
988 | } |
989 | |
990 | (void) get_process_cmdline(pid, 0, true1, &cmdline); |
991 | |
992 | return sd_bus_message_append(reply, |
993 | "(sus)", |
994 | p, |
995 | (uint32_t) pid, |
996 | cmdline); |
997 | } |
998 | |
999 | static int append_cgroup(sd_bus_message *reply, const char *p, Set *pids) { |
1000 | _cleanup_closedir___attribute__((cleanup(closedirp))) DIR *d = NULL((void*)0); |
1001 | _cleanup_fclose___attribute__((cleanup(fclosep))) FILE *f = NULL((void*)0); |
1002 | int r; |
1003 | |
1004 | assert(reply)do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 1004 , __PRETTY_FUNCTION__); } while (0); |
1005 | assert(p)do { if ((__builtin_expect(!!(!(p)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("p"), "../src/core/dbus-unit.c", 1005, __PRETTY_FUNCTION__ ); } while (0); |
1006 | |
1007 | r = cg_enumerate_processes(SYSTEMD_CGROUP_CONTROLLER"_systemd", p, &f); |
1008 | if (r == -ENOENT2) |
1009 | return 0; |
1010 | if (r < 0) |
1011 | return r; |
1012 | |
1013 | for (;;) { |
1014 | pid_t pid; |
1015 | |
1016 | r = cg_read_pid(f, &pid); |
1017 | if (r < 0) |
1018 | return r; |
1019 | if (r == 0) |
1020 | break; |
1021 | |
1022 | if (is_kernel_thread(pid) > 0) |
1023 | continue; |
1024 | |
1025 | r = append_process(reply, p, pid, pids); |
1026 | if (r < 0) |
1027 | return r; |
1028 | } |
1029 | |
1030 | r = cg_enumerate_subgroups(SYSTEMD_CGROUP_CONTROLLER"_systemd", p, &d); |
1031 | if (r == -ENOENT2) |
1032 | return 0; |
1033 | if (r < 0) |
1034 | return r; |
1035 | |
1036 | for (;;) { |
1037 | _cleanup_free___attribute__((cleanup(freep))) char *g = NULL((void*)0), *j = NULL((void*)0); |
1038 | |
1039 | r = cg_read_subgroup(d, &g); |
1040 | if (r < 0) |
1041 | return r; |
1042 | if (r == 0) |
1043 | break; |
1044 | |
1045 | j = strjoin(p, "/", g)strjoin_real((p), "/", g, ((void*)0)); |
1046 | if (!j) |
1047 | return -ENOMEM12; |
1048 | |
1049 | r = append_cgroup(reply, j, pids); |
1050 | if (r < 0) |
1051 | return r; |
1052 | } |
1053 | |
1054 | return 0; |
1055 | } |
1056 | |
1057 | int bus_unit_method_get_processes(sd_bus_message *message, void *userdata, sd_bus_error *error) { |
1058 | _cleanup_(sd_bus_message_unrefp)__attribute__((cleanup(sd_bus_message_unrefp))) sd_bus_message *reply = NULL((void*)0); |
1059 | _cleanup_set_free___attribute__((cleanup(set_freep))) Set *pids = NULL((void*)0); |
1060 | Unit *u = userdata; |
1061 | pid_t pid; |
1062 | int r; |
1063 | |
1064 | assert(message)do { if ((__builtin_expect(!!(!(message)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("message"), "../src/core/dbus-unit.c", 1064 , __PRETTY_FUNCTION__); } while (0); |
1065 | |
1066 | r = mac_selinux_unit_access_check(u, message, "status", error)mac_selinux_generic_access_check((message), unit_label_path(u ), ("status"), (error)); |
1067 | if (r < 0) |
1068 | return r; |
1069 | |
1070 | pids = set_new(NULL)internal_set_new(((void*)0) ); |
1071 | if (!pids) |
1072 | return -ENOMEM12; |
1073 | |
1074 | r = sd_bus_message_new_method_return(message, &reply); |
1075 | if (r < 0) |
1076 | return r; |
1077 | |
1078 | r = sd_bus_message_open_container(reply, 'a', "(sus)"); |
1079 | if (r < 0) |
1080 | return r; |
1081 | |
1082 | if (u->cgroup_path) { |
1083 | r = append_cgroup(reply, u->cgroup_path, pids); |
1084 | if (r < 0) |
1085 | return r; |
1086 | } |
1087 | |
1088 | /* The main and control pids might live outside of the cgroup, hence fetch them separately */ |
1089 | pid = unit_main_pid(u); |
1090 | if (pid > 0) { |
1091 | r = append_process(reply, NULL((void*)0), pid, pids); |
1092 | if (r < 0) |
1093 | return r; |
1094 | } |
1095 | |
1096 | pid = unit_control_pid(u); |
1097 | if (pid > 0) { |
1098 | r = append_process(reply, NULL((void*)0), pid, pids); |
1099 | if (r < 0) |
1100 | return r; |
1101 | } |
1102 | |
1103 | r = sd_bus_message_close_container(reply); |
1104 | if (r < 0) |
1105 | return r; |
1106 | |
1107 | return sd_bus_send(NULL((void*)0), reply, NULL((void*)0)); |
1108 | } |
1109 | |
1110 | static int property_get_ip_counter( |
1111 | sd_bus *bus, |
1112 | const char *path, |
1113 | const char *interface, |
1114 | const char *property, |
1115 | sd_bus_message *reply, |
1116 | void *userdata, |
1117 | sd_bus_error *error) { |
1118 | |
1119 | CGroupIPAccountingMetric metric; |
1120 | uint64_t value = (uint64_t) -1; |
1121 | Unit *u = userdata; |
1122 | |
1123 | assert(bus)do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 1123, __PRETTY_FUNCTION__); } while (0); |
1124 | assert(reply)do { if ((__builtin_expect(!!(!(reply)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("reply"), "../src/core/dbus-unit.c", 1124 , __PRETTY_FUNCTION__); } while (0); |
1125 | assert(property)do { if ((__builtin_expect(!!(!(property)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("property"), "../src/core/dbus-unit.c", 1125 , __PRETTY_FUNCTION__); } while (0); |
1126 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 1126, __PRETTY_FUNCTION__ ); } while (0); |
1127 | |
1128 | if (streq(property, "IPIngressBytes")(strcmp((property),("IPIngressBytes")) == 0)) |
1129 | metric = CGROUP_IP_INGRESS_BYTES; |
1130 | else if (streq(property, "IPIngressPackets")(strcmp((property),("IPIngressPackets")) == 0)) |
1131 | metric = CGROUP_IP_INGRESS_PACKETS; |
1132 | else if (streq(property, "IPEgressBytes")(strcmp((property),("IPEgressBytes")) == 0)) |
1133 | metric = CGROUP_IP_EGRESS_BYTES; |
1134 | else { |
1135 | assert(streq(property, "IPEgressPackets"))do { if ((__builtin_expect(!!(!((strcmp((property),("IPEgressPackets" )) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq(property, \"IPEgressPackets\")" ), "../src/core/dbus-unit.c", 1135, __PRETTY_FUNCTION__); } while (0); |
1136 | metric = CGROUP_IP_EGRESS_PACKETS; |
1137 | } |
1138 | |
1139 | (void) unit_get_ip_accounting(u, metric, &value); |
1140 | return sd_bus_message_append(reply, "t", value); |
1141 | } |
1142 | |
1143 | int bus_unit_method_attach_processes(sd_bus_message *message, void *userdata, sd_bus_error *error) { |
1144 | |
1145 | _cleanup_(sd_bus_creds_unrefp)__attribute__((cleanup(sd_bus_creds_unrefp))) sd_bus_creds *creds = NULL((void*)0); |
1146 | _cleanup_set_free___attribute__((cleanup(set_freep))) Set *pids = NULL((void*)0); |
1147 | Unit *u = userdata; |
1148 | const char *path; |
1149 | int r; |
1150 | |
1151 | assert(message)do { if ((__builtin_expect(!!(!(message)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("message"), "../src/core/dbus-unit.c", 1151 , __PRETTY_FUNCTION__); } while (0); |
1152 | |
1153 | /* This migrates the processes with the specified PIDs into the cgroup of this unit, optionally below a |
1154 | * specified cgroup path. Obviously this only works for units that actually maintain a cgroup |
1155 | * representation. If a process is already in the cgroup no operation is executed – in this case the specified |
1156 | * subcgroup path has no effect! */ |
1157 | |
1158 | r = mac_selinux_unit_access_check(u, message, "start", error)mac_selinux_generic_access_check((message), unit_label_path(u ), ("start"), (error)); |
1159 | if (r < 0) |
1160 | return r; |
1161 | |
1162 | r = sd_bus_message_read(message, "s", &path); |
1163 | if (r < 0) |
1164 | return r; |
1165 | |
1166 | path = empty_to_null(path); |
1167 | if (path) { |
1168 | if (!path_is_absolute(path)) |
1169 | return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS"org.freedesktop.DBus.Error.InvalidArgs", "Control group path is not absolute: %s", path); |
1170 | |
1171 | if (!path_is_normalized(path)) |
1172 | return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS"org.freedesktop.DBus.Error.InvalidArgs", "Control group path is not normalized: %s", path); |
1173 | } |
1174 | |
1175 | if (!unit_cgroup_delegate(u)) |
1176 | return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS"org.freedesktop.DBus.Error.InvalidArgs", "Process migration not available on non-delegated units."); |
1177 | |
1178 | if (UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(u))) |
1179 | return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS"org.freedesktop.DBus.Error.InvalidArgs", "Unit is not active, refusing."); |
1180 | |
1181 | r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_EUID|SD_BUS_CREDS_PID, &creds); |
1182 | if (r < 0) |
1183 | return r; |
1184 | |
1185 | r = sd_bus_message_enter_container(message, 'a', "u"); |
1186 | if (r < 0) |
1187 | return r; |
1188 | for (;;) { |
1189 | uid_t process_uid, sender_uid; |
1190 | uint32_t upid; |
1191 | pid_t pid; |
1192 | |
1193 | r = sd_bus_message_read(message, "u", &upid); |
1194 | if (r < 0) |
1195 | return r; |
1196 | if (r == 0) |
1197 | break; |
1198 | |
1199 | if (upid == 0) { |
1200 | r = sd_bus_creds_get_pid(creds, &pid); |
1201 | if (r < 0) |
1202 | return r; |
1203 | } else |
1204 | pid = (uid_t) upid; |
1205 | |
1206 | /* Filter out duplicates */ |
1207 | if (set_contains(pids, PID_TO_PTR(pid))) |
1208 | continue; |
1209 | |
1210 | /* Check if this process is suitable for attaching to this unit */ |
1211 | r = unit_pid_attachable(u, pid, error); |
1212 | if (r < 0) |
1213 | return r; |
1214 | |
1215 | /* Let's query the sender's UID, so that we can make our security decisions */ |
1216 | r = sd_bus_creds_get_euid(creds, &sender_uid); |
1217 | if (r < 0) |
1218 | return r; |
1219 | |
1220 | /* Let's validate security: if the sender is root, then all is OK. If the sender is is any other unit, |
1221 | * then the process' UID and the target unit's UID have to match the sender's UID */ |
1222 | if (sender_uid != 0 && sender_uid != getuid()) { |
1223 | r = get_process_uid(pid, &process_uid); |
1224 | if (r < 0) |
1225 | return sd_bus_error_set_errnof(error, r, "Failed to retrieve process UID: %m"); |
1226 | |
1227 | if (process_uid != sender_uid) |
1228 | return sd_bus_error_setf(error, SD_BUS_ERROR_ACCESS_DENIED"org.freedesktop.DBus.Error.AccessDenied", "Process " PID_FMT"%" "i" " not owned by client's UID. Refusing.", pid); |
1229 | if (process_uid != u->ref_uid) |
1230 | return sd_bus_error_setf(error, SD_BUS_ERROR_ACCESS_DENIED"org.freedesktop.DBus.Error.AccessDenied", "Process " PID_FMT"%" "i" " not owned by target unit's UID. Refusing.", pid); |
1231 | } |
1232 | |
1233 | if (!pids) { |
1234 | pids = set_new(NULL)internal_set_new(((void*)0) ); |
1235 | if (!pids) |
1236 | return -ENOMEM12; |
1237 | } |
1238 | |
1239 | r = set_put(pids, PID_TO_PTR(pid)); |
1240 | if (r < 0) |
1241 | return r; |
1242 | } |
1243 | |
1244 | r = sd_bus_message_exit_container(message); |
1245 | if (r < 0) |
1246 | return r; |
1247 | |
1248 | r = unit_attach_pids_to_cgroup(u, pids, path); |
1249 | if (r < 0) |
1250 | return sd_bus_error_set_errnof(error, r, "Failed to attach processes to control group: %m"); |
1251 | |
1252 | return sd_bus_reply_method_return(message, NULL((void*)0)); |
1253 | } |
1254 | |
1255 | const sd_bus_vtable bus_unit_cgroup_vtable[] = { |
1256 | SD_BUS_VTABLE_START(0){ .type = _SD_BUS_VTABLE_START, .flags = 0, .x = { .start = { .element_size = sizeof(sd_bus_vtable) }, }, }, |
1257 | SD_BUS_PROPERTY("Slice", "s", property_get_slice, 0, 0){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = 0, .x = { .property = { .member = "Slice", .signature = "s", .get = property_get_slice , .set = ((void*)0), .offset = 0, }, }, }, |
1258 | SD_BUS_PROPERTY("ControlGroup", "s", property_get_cgroup, 0, 0){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = 0, .x = { .property = { .member = "ControlGroup", .signature = "s", .get = property_get_cgroup , .set = ((void*)0), .offset = 0, }, }, }, |
1259 | SD_BUS_PROPERTY("MemoryCurrent", "t", property_get_current_memory, 0, 0){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = 0, .x = { .property = { .member = "MemoryCurrent", .signature = "t", .get = property_get_current_memory , .set = ((void*)0), .offset = 0, }, }, }, |
1260 | SD_BUS_PROPERTY("CPUUsageNSec", "t", property_get_cpu_usage, 0, 0){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = 0, .x = { .property = { .member = "CPUUsageNSec", .signature = "t", .get = property_get_cpu_usage , .set = ((void*)0), .offset = 0, }, }, }, |
1261 | SD_BUS_PROPERTY("EffectiveCPUs", "ay", property_get_cpuset_cpus, 0, 0){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = 0, .x = { .property = { .member = "EffectiveCPUs", .signature = "ay", .get = property_get_cpuset_cpus , .set = ((void*)0), .offset = 0, }, }, }, |
1262 | SD_BUS_PROPERTY("EffectiveMemoryNodes", "ay", property_get_cpuset_mems, 0, 0){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = 0, .x = { .property = { .member = "EffectiveMemoryNodes", .signature = "ay", .get = property_get_cpuset_mems, .set = ((void*)0), .offset = 0, } , }, }, |
1263 | SD_BUS_PROPERTY("TasksCurrent", "t", property_get_current_tasks, 0, 0){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = 0, .x = { .property = { .member = "TasksCurrent", .signature = "t", .get = property_get_current_tasks , .set = ((void*)0), .offset = 0, }, }, }, |
1264 | SD_BUS_PROPERTY("IPIngressBytes", "t", property_get_ip_counter, 0, 0){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = 0, .x = { .property = { .member = "IPIngressBytes", .signature = "t", .get = property_get_ip_counter , .set = ((void*)0), .offset = 0, }, }, }, |
1265 | SD_BUS_PROPERTY("IPIngressPackets", "t", property_get_ip_counter, 0, 0){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = 0, .x = { .property = { .member = "IPIngressPackets", .signature = "t", .get = property_get_ip_counter , .set = ((void*)0), .offset = 0, }, }, }, |
1266 | SD_BUS_PROPERTY("IPEgressBytes", "t", property_get_ip_counter, 0, 0){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = 0, .x = { .property = { .member = "IPEgressBytes", .signature = "t", .get = property_get_ip_counter , .set = ((void*)0), .offset = 0, }, }, }, |
1267 | SD_BUS_PROPERTY("IPEgressPackets", "t", property_get_ip_counter, 0, 0){ .type = _SD_BUS_VTABLE_PROPERTY, .flags = 0, .x = { .property = { .member = "IPEgressPackets", .signature = "t", .get = property_get_ip_counter , .set = ((void*)0), .offset = 0, }, }, }, |
1268 | SD_BUS_METHOD("GetProcesses", NULL, "a(sus)", bus_unit_method_get_processes, SD_BUS_VTABLE_UNPRIVILEGED){ .type = _SD_BUS_VTABLE_METHOD, .flags = SD_BUS_VTABLE_UNPRIVILEGED , .x = { .method = { .member = "GetProcesses", .signature = ( (void*)0), .result = "a(sus)", .handler = bus_unit_method_get_processes , .offset = 0, }, }, }, |
1269 | SD_BUS_METHOD("AttachProcesses", "sau", NULL, bus_unit_method_attach_processes, SD_BUS_VTABLE_UNPRIVILEGED){ .type = _SD_BUS_VTABLE_METHOD, .flags = SD_BUS_VTABLE_UNPRIVILEGED , .x = { .method = { .member = "AttachProcesses", .signature = "sau", .result = ((void*)0), .handler = bus_unit_method_attach_processes , .offset = 0, }, }, }, |
1270 | SD_BUS_VTABLE_END{ .type = _SD_BUS_VTABLE_END, .flags = 0, .x = { { 0 } }, } |
1271 | }; |
1272 | |
1273 | static int send_new_signal(sd_bus *bus, void *userdata) { |
1274 | _cleanup_(sd_bus_message_unrefp)__attribute__((cleanup(sd_bus_message_unrefp))) sd_bus_message *m = NULL((void*)0); |
1275 | _cleanup_free___attribute__((cleanup(freep))) char *p = NULL((void*)0); |
1276 | Unit *u = userdata; |
1277 | int r; |
1278 | |
1279 | assert(bus)do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 1279, __PRETTY_FUNCTION__); } while (0); |
1280 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 1280, __PRETTY_FUNCTION__ ); } while (0); |
1281 | |
1282 | p = unit_dbus_path(u); |
1283 | if (!p) |
1284 | return -ENOMEM12; |
1285 | |
1286 | r = sd_bus_message_new_signal( |
1287 | bus, |
1288 | &m, |
1289 | "/org/freedesktop/systemd1", |
1290 | "org.freedesktop.systemd1.Manager", |
1291 | "UnitNew"); |
1292 | if (r < 0) |
1293 | return r; |
1294 | |
1295 | r = sd_bus_message_append(m, "so", u->id, p); |
1296 | if (r < 0) |
1297 | return r; |
1298 | |
1299 | return sd_bus_send(bus, m, NULL((void*)0)); |
1300 | } |
1301 | |
1302 | static int send_changed_signal(sd_bus *bus, void *userdata) { |
1303 | _cleanup_free___attribute__((cleanup(freep))) char *p = NULL((void*)0); |
1304 | Unit *u = userdata; |
1305 | int r; |
1306 | |
1307 | assert(bus)do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 1307, __PRETTY_FUNCTION__); } while (0); |
1308 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 1308, __PRETTY_FUNCTION__ ); } while (0); |
1309 | |
1310 | p = unit_dbus_path(u); |
1311 | if (!p) |
1312 | return -ENOMEM12; |
1313 | |
1314 | /* Send a properties changed signal. First for the specific |
1315 | * type, then for the generic unit. The clients may rely on |
1316 | * this order to get atomic behavior if needed. */ |
1317 | |
1318 | r = sd_bus_emit_properties_changed_strv( |
1319 | bus, p, |
1320 | unit_dbus_interface_from_type(u->type), |
1321 | NULL((void*)0)); |
1322 | if (r < 0) |
1323 | return r; |
1324 | |
1325 | return sd_bus_emit_properties_changed_strv( |
1326 | bus, p, |
1327 | "org.freedesktop.systemd1.Unit", |
1328 | NULL((void*)0)); |
1329 | } |
1330 | |
1331 | void bus_unit_send_change_signal(Unit *u) { |
1332 | int r; |
1333 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 1333, __PRETTY_FUNCTION__ ); } while (0); |
1334 | |
1335 | if (u->in_dbus_queue) { |
1336 | LIST_REMOVE(dbus_queue, u->manager->dbus_unit_queue, u)do { typeof(*(u->manager->dbus_unit_queue)) **_head = & (u->manager->dbus_unit_queue), *_item = (u); do { if (( __builtin_expect(!!(!(_item)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("_item"), "../src/core/dbus-unit.c", 1336, __PRETTY_FUNCTION__ ); } while (0); if (_item->dbus_queue_next) _item->dbus_queue_next ->dbus_queue_prev = _item->dbus_queue_prev; if (_item-> dbus_queue_prev) _item->dbus_queue_prev->dbus_queue_next = _item->dbus_queue_next; else { do { if ((__builtin_expect (!!(!(*_head == _item)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("*_head == _item"), "../src/core/dbus-unit.c", 1336, __PRETTY_FUNCTION__ ); } while (0); *_head = _item->dbus_queue_next; } _item-> dbus_queue_next = _item->dbus_queue_prev = ((void*)0); } while (0); |
1337 | u->in_dbus_queue = false0; |
1338 | } |
1339 | |
1340 | if (!u->id) |
1341 | return; |
1342 | |
1343 | r = bus_foreach_bus(u->manager, u->bus_track, u->sent_dbus_new_signal ? send_changed_signal : send_new_signal, u); |
1344 | if (r < 0) |
1345 | log_unit_debug_errno(u, r, "Failed to send unit change signal for %s: %m", u->id)({ const Unit *_u = (u); _u ? log_object_internal(7, r, "../src/core/dbus-unit.c" , 1345, __func__, _u->manager->unit_log_field, _u->id , _u->manager->invocation_log_field, _u->invocation_id_string , "Failed to send unit change signal for %s: %m", u->id) : log_internal_realm(((LOG_REALM_SYSTEMD) << 10 | ((7))) , r, "../src/core/dbus-unit.c", 1345, __func__, "Failed to send unit change signal for %s: %m" , u->id); }); |
1346 | |
1347 | u->sent_dbus_new_signal = true1; |
1348 | } |
1349 | |
1350 | int bus_unit_send_pending_freezer_message(Unit *u) { |
1351 | int r; |
1352 | |
1353 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 1353, __PRETTY_FUNCTION__ ); } while (0); |
1354 | |
1355 | if (!u->pending_freezer_message) |
1356 | return 0; |
1357 | |
1358 | r = sd_bus_send(NULL((void*)0), u->pending_freezer_message, NULL((void*)0)); |
1359 | if (r < 0) |
1360 | log_warning_errno(r, "Failed to send queued message, ignoring: %m")({ int _level = ((4)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD ); (log_get_max_level_realm(_realm) >= ((_level) & 0x07 )) ? log_internal_realm(((_realm) << 10 | (_level)), _e , "../src/core/dbus-unit.c", 1360, __func__, "Failed to send queued message, ignoring: %m" ) : -abs(_e); }); |
1361 | |
1362 | u->pending_freezer_message = sd_bus_message_unref(u->pending_freezer_message); |
1363 | |
1364 | return 0; |
1365 | } |
1366 | |
1367 | static int send_removed_signal(sd_bus *bus, void *userdata) { |
1368 | _cleanup_(sd_bus_message_unrefp)__attribute__((cleanup(sd_bus_message_unrefp))) sd_bus_message *m = NULL((void*)0); |
1369 | _cleanup_free___attribute__((cleanup(freep))) char *p = NULL((void*)0); |
1370 | Unit *u = userdata; |
1371 | int r; |
1372 | |
1373 | assert(bus)do { if ((__builtin_expect(!!(!(bus)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("bus"), "../src/core/dbus-unit.c", 1373, __PRETTY_FUNCTION__); } while (0); |
1374 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 1374, __PRETTY_FUNCTION__ ); } while (0); |
1375 | |
1376 | p = unit_dbus_path(u); |
1377 | if (!p) |
1378 | return -ENOMEM12; |
1379 | |
1380 | r = sd_bus_message_new_signal( |
1381 | bus, |
1382 | &m, |
1383 | "/org/freedesktop/systemd1", |
1384 | "org.freedesktop.systemd1.Manager", |
1385 | "UnitRemoved"); |
1386 | if (r < 0) |
1387 | return r; |
1388 | |
1389 | r = sd_bus_message_append(m, "so", u->id, p); |
1390 | if (r < 0) |
1391 | return r; |
1392 | |
1393 | return sd_bus_send(bus, m, NULL((void*)0)); |
1394 | } |
1395 | |
1396 | void bus_unit_send_removed_signal(Unit *u) { |
1397 | int r; |
1398 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 1398, __PRETTY_FUNCTION__ ); } while (0); |
1399 | |
1400 | if (!u->sent_dbus_new_signal || u->in_dbus_queue) |
1401 | bus_unit_send_change_signal(u); |
1402 | |
1403 | if (!u->id) |
1404 | return; |
1405 | |
1406 | r = bus_foreach_bus(u->manager, u->bus_track, send_removed_signal, u); |
1407 | if (r < 0) |
1408 | log_unit_debug_errno(u, r, "Failed to send unit remove signal for %s: %m", u->id)({ const Unit *_u = (u); _u ? log_object_internal(7, r, "../src/core/dbus-unit.c" , 1408, __func__, _u->manager->unit_log_field, _u->id , _u->manager->invocation_log_field, _u->invocation_id_string , "Failed to send unit remove signal for %s: %m", u->id) : log_internal_realm(((LOG_REALM_SYSTEMD) << 10 | ((7))) , r, "../src/core/dbus-unit.c", 1408, __func__, "Failed to send unit remove signal for %s: %m" , u->id); }); |
1409 | } |
1410 | |
1411 | int bus_unit_queue_job( |
1412 | sd_bus_message *message, |
1413 | Unit *u, |
1414 | JobType type, |
1415 | JobMode mode, |
1416 | BusUnitQueueFlags flags, |
1417 | sd_bus_error *error) { |
1418 | |
1419 | _cleanup_(sd_bus_message_unrefp)__attribute__((cleanup(sd_bus_message_unrefp))) sd_bus_message *reply = NULL((void*)0); |
1420 | _cleanup_free___attribute__((cleanup(freep))) char *job_path = NULL((void*)0), *unit_path = NULL((void*)0); |
1421 | _cleanup_(set_freep)__attribute__((cleanup(set_freep))) Set *affected = NULL((void*)0); |
1422 | Iterator i; |
1423 | Job *j, *a; |
1424 | int r; |
1425 | |
1426 | assert(message)do { if ((__builtin_expect(!!(!(message)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("message"), "../src/core/dbus-unit.c", 1426 , __PRETTY_FUNCTION__); } while (0); |
1427 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 1427, __PRETTY_FUNCTION__ ); } while (0); |
1428 | assert(type >= 0 && type < _JOB_TYPE_MAX)do { if ((__builtin_expect(!!(!(type >= 0 && type < _JOB_TYPE_MAX)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("type >= 0 && type < _JOB_TYPE_MAX"), "../src/core/dbus-unit.c" , 1428, __PRETTY_FUNCTION__); } while (0); |
1429 | assert(mode >= 0 && mode < _JOB_MODE_MAX)do { if ((__builtin_expect(!!(!(mode >= 0 && mode < _JOB_MODE_MAX)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD , ("mode >= 0 && mode < _JOB_MODE_MAX"), "../src/core/dbus-unit.c" , 1429, __PRETTY_FUNCTION__); } while (0); |
1430 | |
1431 | r = mac_selinux_unit_access_check(mac_selinux_generic_access_check((message), unit_label_path(u ), (job_type_to_access_method(type)), (error)) |
1432 | u, message,mac_selinux_generic_access_check((message), unit_label_path(u ), (job_type_to_access_method(type)), (error)) |
1433 | job_type_to_access_method(type),mac_selinux_generic_access_check((message), unit_label_path(u ), (job_type_to_access_method(type)), (error)) |
1434 | error)mac_selinux_generic_access_check((message), unit_label_path(u ), (job_type_to_access_method(type)), (error)); |
1435 | if (r < 0) |
1436 | return r; |
1437 | |
1438 | if (FLAGS_SET(flags, BUS_UNIT_QUEUE_RELOAD_IF_POSSIBLE)(((flags) & (BUS_UNIT_QUEUE_RELOAD_IF_POSSIBLE)) == (BUS_UNIT_QUEUE_RELOAD_IF_POSSIBLE )) && unit_can_reload(u)) { |
1439 | if (type == JOB_RESTART) |
1440 | type = JOB_RELOAD_OR_START; |
1441 | else if (type == JOB_TRY_RESTART) |
1442 | type = JOB_TRY_RELOAD; |
1443 | } |
1444 | |
1445 | if (type == JOB_STOP && |
1446 | IN_SET(u->load_state, UNIT_NOT_FOUND, UNIT_ERROR, UNIT_BAD_SETTING)({ _Bool _found = 0; static __attribute__ ((unused)) char _static_assert__macros_need_to_be_extended [20 - sizeof((int[]){UNIT_NOT_FOUND, UNIT_ERROR, UNIT_BAD_SETTING })/sizeof(int)]; switch(u->load_state) { case UNIT_NOT_FOUND : case UNIT_ERROR: case UNIT_BAD_SETTING: _found = 1; break; default : break; } _found; }) && |
1447 | unit_active_state(u) == UNIT_INACTIVE) |
1448 | return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT"org.freedesktop.systemd1.NoSuchUnit", "Unit %s not loaded.", u->id); |
1449 | |
1450 | if ((type == JOB_START && u->refuse_manual_start) || |
1451 | (type == JOB_STOP && u->refuse_manual_stop) || |
1452 | (IN_SET(type, JOB_RESTART, JOB_TRY_RESTART)({ _Bool _found = 0; static __attribute__ ((unused)) char _static_assert__macros_need_to_be_extended [20 - sizeof((int[]){JOB_RESTART, JOB_TRY_RESTART})/sizeof(int )]; switch(type) { case JOB_RESTART: case JOB_TRY_RESTART: _found = 1; break; default: break; } _found; }) && (u->refuse_manual_start || u->refuse_manual_stop)) || |
1453 | (type == JOB_RELOAD_OR_START && job_type_collapse(type, u) == JOB_START && u->refuse_manual_start)) |
1454 | return sd_bus_error_setf(error, BUS_ERROR_ONLY_BY_DEPENDENCY"org.freedesktop.systemd1.OnlyByDependency", "Operation refused, unit %s may be requested by dependency only (it is configured to refuse manual start/stop).", u->id); |
1455 | |
1456 | if (FLAGS_SET(flags, BUS_UNIT_QUEUE_VERBOSE_REPLY)(((flags) & (BUS_UNIT_QUEUE_VERBOSE_REPLY)) == (BUS_UNIT_QUEUE_VERBOSE_REPLY ))) { |
1457 | affected = set_new(NULL)internal_set_new(((void*)0) ); |
1458 | if (!affected) |
1459 | return -ENOMEM12; |
1460 | } |
1461 | |
1462 | r = manager_add_job(u->manager, type, u, mode, affected, error, &j); |
1463 | if (r < 0) |
1464 | return r; |
1465 | |
1466 | r = bus_job_track_sender(j, message); |
1467 | if (r < 0) |
1468 | return r; |
1469 | |
1470 | job_path = job_dbus_path(j); |
1471 | if (!job_path) |
1472 | return -ENOMEM12; |
1473 | |
1474 | /* The classic response is just a job object path */ |
1475 | if (!FLAGS_SET(flags, BUS_UNIT_QUEUE_VERBOSE_REPLY)(((flags) & (BUS_UNIT_QUEUE_VERBOSE_REPLY)) == (BUS_UNIT_QUEUE_VERBOSE_REPLY ))) |
1476 | return sd_bus_reply_method_return(message, "o", job_path); |
1477 | |
1478 | /* In verbose mode respond with the anchor job plus everything that has been affected */ |
1479 | r = sd_bus_message_new_method_return(message, &reply); |
1480 | if (r < 0) |
1481 | return r; |
1482 | |
1483 | unit_path = unit_dbus_path(j->unit); |
1484 | if (!unit_path) |
1485 | return -ENOMEM12; |
1486 | |
1487 | r = sd_bus_message_append(reply, "uosos", |
1488 | j->id, job_path, |
1489 | j->unit->id, unit_path, |
1490 | job_type_to_string(j->type)); |
1491 | if (r < 0) |
1492 | return r; |
1493 | |
1494 | r = sd_bus_message_open_container(reply, 'a', "(uosos)"); |
1495 | if (r < 0) |
1496 | return r; |
1497 | |
1498 | SET_FOREACH(a, affected, i)for ((i) = ((Iterator) { .idx = ((2147483647 *2U +1U) - 1), . next_key = ((void*)0) }); set_iterate((affected), &(i), ( void**)&(a)); ) { |
1499 | |
1500 | if (a->id == j->id) |
1501 | continue; |
1502 | |
1503 | /* Free paths from previous iteration */ |
1504 | job_path = mfree(job_path); |
1505 | unit_path = mfree(unit_path); |
Value stored to 'unit_path' is never read | |
1506 | |
1507 | job_path = job_dbus_path(a); |
1508 | if (!job_path) |
1509 | return -ENOMEM12; |
1510 | |
1511 | unit_path = unit_dbus_path(a->unit); |
1512 | if (!unit_path) |
1513 | return -ENOMEM12; |
1514 | |
1515 | r = sd_bus_message_append(reply, "(uosos)", |
1516 | a->id, job_path, |
1517 | a->unit->id, unit_path, |
1518 | job_type_to_string(a->type)); |
1519 | if (r < 0) |
1520 | return r; |
1521 | } |
1522 | |
1523 | r = sd_bus_message_close_container(reply); |
1524 | if (r < 0) |
1525 | return r; |
1526 | |
1527 | return sd_bus_send(NULL((void*)0), reply, NULL((void*)0)); |
1528 | } |
1529 | |
1530 | static int bus_unit_set_live_property( |
1531 | Unit *u, |
1532 | const char *name, |
1533 | sd_bus_message *message, |
1534 | UnitWriteFlags flags, |
1535 | sd_bus_error *error) { |
1536 | |
1537 | int r; |
1538 | |
1539 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 1539, __PRETTY_FUNCTION__ ); } while (0); |
1540 | assert(name)do { if ((__builtin_expect(!!(!(name)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("name"), "../src/core/dbus-unit.c", 1540 , __PRETTY_FUNCTION__); } while (0); |
1541 | assert(message)do { if ((__builtin_expect(!!(!(message)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("message"), "../src/core/dbus-unit.c", 1541 , __PRETTY_FUNCTION__); } while (0); |
1542 | |
1543 | /* Handles setting properties both "live" (i.e. at any time during runtime), and during creation (for transient |
1544 | * units that are being created). */ |
1545 | |
1546 | if (streq(name, "Description")(strcmp((name),("Description")) == 0)) { |
1547 | const char *d; |
1548 | |
1549 | r = sd_bus_message_read(message, "s", &d); |
1550 | if (r < 0) |
1551 | return r; |
1552 | |
1553 | if (!UNIT_WRITE_FLAGS_NOOP(flags)(((flags) & (UNIT_RUNTIME|UNIT_PERSISTENT)) == 0)) { |
1554 | r = unit_set_description(u, d); |
1555 | if (r < 0) |
1556 | return r; |
1557 | |
1558 | unit_write_settingf(u, flags|UNIT_ESCAPE_SPECIFIERS, name, "Description=%s", d); |
1559 | } |
1560 | |
1561 | return 1; |
1562 | } |
1563 | |
1564 | return 0; |
1565 | } |
1566 | |
1567 | static BUS_DEFINE_SET_TRANSIENT_PARSE(collect_mode, CollectMode, collect_mode_from_string)int bus_set_transient_collect_mode( Unit *u, const char *name , CollectMode *p, sd_bus_message *message, UnitWriteFlags flags , sd_bus_error *error) { const char *s; CollectMode v; int r; do { if ((__builtin_expect(!!(!(p)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("p"), "../src/core/dbus-unit.c", 1567, __PRETTY_FUNCTION__ ); } while (0); r = sd_bus_message_read(message, "s", &s) ; if (r < 0) return r; v = collect_mode_from_string(s); if (v < 0) return sd_bus_error_setf(error, "org.freedesktop.DBus.Error.InvalidArgs" , "Invalid %s setting: %s", name, s); if (!(((flags) & (UNIT_RUNTIME |UNIT_PERSISTENT)) == 0)) { *p = v; unit_write_settingf(u, flags , name, "%s=%s", name, s); } return 1; }; |
1568 | static BUS_DEFINE_SET_TRANSIENT_PARSE(emergency_action, EmergencyAction, emergency_action_from_string)int bus_set_transient_emergency_action( Unit *u, const char * name, EmergencyAction *p, sd_bus_message *message, UnitWriteFlags flags, sd_bus_error *error) { const char *s; EmergencyAction v; int r; do { if ((__builtin_expect(!!(!(p)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("p"), "../src/core/dbus-unit.c", 1568, __PRETTY_FUNCTION__ ); } while (0); r = sd_bus_message_read(message, "s", &s) ; if (r < 0) return r; v = emergency_action_from_string(s) ; if (v < 0) return sd_bus_error_setf(error, "org.freedesktop.DBus.Error.InvalidArgs" , "Invalid %s setting: %s", name, s); if (!(((flags) & (UNIT_RUNTIME |UNIT_PERSISTENT)) == 0)) { *p = v; unit_write_settingf(u, flags , name, "%s=%s", name, s); } return 1; }; |
1569 | static BUS_DEFINE_SET_TRANSIENT_PARSE(job_mode, JobMode, job_mode_from_string)int bus_set_transient_job_mode( Unit *u, const char *name, JobMode *p, sd_bus_message *message, UnitWriteFlags flags, sd_bus_error *error) { const char *s; JobMode v; int r; do { if ((__builtin_expect (!!(!(p)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("p" ), "../src/core/dbus-unit.c", 1569, __PRETTY_FUNCTION__); } while (0); r = sd_bus_message_read(message, "s", &s); if (r < 0) return r; v = job_mode_from_string(s); if (v < 0) return sd_bus_error_setf(error, "org.freedesktop.DBus.Error.InvalidArgs" , "Invalid %s setting: %s", name, s); if (!(((flags) & (UNIT_RUNTIME |UNIT_PERSISTENT)) == 0)) { *p = v; unit_write_settingf(u, flags , name, "%s=%s", name, s); } return 1; }; |
1570 | |
1571 | static int bus_set_transient_conditions( |
1572 | Unit *u, |
1573 | const char *name, |
1574 | Condition **list, |
1575 | bool_Bool is_condition, |
1576 | sd_bus_message *message, |
1577 | UnitWriteFlags flags, |
1578 | sd_bus_error *error) { |
1579 | |
1580 | const char *type_name, *param; |
1581 | int trigger, negate, r; |
1582 | bool_Bool empty = true1; |
1583 | |
1584 | assert(list)do { if ((__builtin_expect(!!(!(list)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("list"), "../src/core/dbus-unit.c", 1584 , __PRETTY_FUNCTION__); } while (0); |
1585 | |
1586 | r = sd_bus_message_enter_container(message, 'a', "(sbbs)"); |
1587 | if (r < 0) |
1588 | return r; |
1589 | |
1590 | while ((r = sd_bus_message_read(message, "(sbbs)", &type_name, &trigger, &negate, ¶m)) > 0) { |
1591 | ConditionType t; |
1592 | |
1593 | t = is_condition ? condition_type_from_string(type_name) : assert_type_from_string(type_name); |
1594 | if (t < 0) |
1595 | return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS"org.freedesktop.DBus.Error.InvalidArgs", "Invalid condition type: %s", type_name); |
1596 | |
1597 | if (t != CONDITION_NULL) { |
1598 | if (isempty(param)) |
1599 | return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS"org.freedesktop.DBus.Error.InvalidArgs", "Condition parameter in %s is empty", type_name); |
1600 | |
1601 | if (condition_takes_path(t) && !path_is_absolute(param)) |
1602 | return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS"org.freedesktop.DBus.Error.InvalidArgs", "Path in condition %s is not absolute: %s", type_name, param); |
1603 | } else |
1604 | param = NULL((void*)0); |
1605 | |
1606 | if (!UNIT_WRITE_FLAGS_NOOP(flags)(((flags) & (UNIT_RUNTIME|UNIT_PERSISTENT)) == 0)) { |
1607 | Condition *c; |
1608 | |
1609 | c = condition_new(t, param, trigger, negate); |
1610 | if (!c) |
1611 | return -ENOMEM12; |
1612 | |
1613 | LIST_PREPEND(conditions, *list, c)do { typeof(*(*list)) **_head = &(*list), *_item = (c); do { if ((__builtin_expect(!!(!(_item)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("_item"), "../src/core/dbus-unit.c", 1613 , __PRETTY_FUNCTION__); } while (0); if ((_item->conditions_next = *_head)) _item->conditions_next->conditions_prev = _item ; _item->conditions_prev = ((void*)0); *_head = _item; } while (0); |
1614 | |
1615 | if (t != CONDITION_NULL) |
1616 | unit_write_settingf(u, flags|UNIT_ESCAPE_SPECIFIERS, name, |
1617 | "%s=%s%s%s", type_name, |
1618 | trigger ? "|" : "", negate ? "!" : "", param); |
1619 | else |
1620 | unit_write_settingf(u, flags, name, |
1621 | "%s=%s%s", type_name, |
1622 | trigger ? "|" : "", yes_no(!negate)); |
1623 | } |
1624 | |
1625 | empty = false0; |
1626 | } |
1627 | if (r < 0) |
1628 | return r; |
1629 | |
1630 | r = sd_bus_message_exit_container(message); |
1631 | if (r < 0) |
1632 | return r; |
1633 | |
1634 | if (!UNIT_WRITE_FLAGS_NOOP(flags)(((flags) & (UNIT_RUNTIME|UNIT_PERSISTENT)) == 0) && empty) { |
1635 | *list = condition_free_list(*list); |
1636 | unit_write_settingf(u, flags, name, "%sNull=", is_condition ? "Condition" : "Assert"); |
1637 | } |
1638 | |
1639 | return 1; |
1640 | } |
1641 | |
1642 | static int bus_unit_set_transient_property( |
1643 | Unit *u, |
1644 | const char *name, |
1645 | sd_bus_message *message, |
1646 | UnitWriteFlags flags, |
1647 | sd_bus_error *error) { |
1648 | |
1649 | UnitDependency d = _UNIT_DEPENDENCY_INVALID; |
1650 | int r; |
1651 | |
1652 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 1652, __PRETTY_FUNCTION__ ); } while (0); |
1653 | assert(name)do { if ((__builtin_expect(!!(!(name)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("name"), "../src/core/dbus-unit.c", 1653 , __PRETTY_FUNCTION__); } while (0); |
1654 | assert(message)do { if ((__builtin_expect(!!(!(message)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("message"), "../src/core/dbus-unit.c", 1654 , __PRETTY_FUNCTION__); } while (0); |
1655 | |
1656 | /* Handles settings when transient units are created. This settings cannot be altered anymore after the unit |
1657 | * has been created. */ |
1658 | |
1659 | if (streq(name, "SourcePath")(strcmp((name),("SourcePath")) == 0)) |
1660 | return bus_set_transient_path(u, name, &u->source_path, message, flags, error); |
1661 | |
1662 | if (streq(name, "StopWhenUnneeded")(strcmp((name),("StopWhenUnneeded")) == 0)) |
1663 | return bus_set_transient_bool(u, name, &u->stop_when_unneeded, message, flags, error); |
1664 | |
1665 | if (streq(name, "RefuseManualStart")(strcmp((name),("RefuseManualStart")) == 0)) |
1666 | return bus_set_transient_bool(u, name, &u->refuse_manual_start, message, flags, error); |
1667 | |
1668 | if (streq(name, "RefuseManualStop")(strcmp((name),("RefuseManualStop")) == 0)) |
1669 | return bus_set_transient_bool(u, name, &u->refuse_manual_stop, message, flags, error); |
1670 | |
1671 | if (streq(name, "AllowIsolate")(strcmp((name),("AllowIsolate")) == 0)) |
1672 | return bus_set_transient_bool(u, name, &u->allow_isolate, message, flags, error); |
1673 | |
1674 | if (streq(name, "DefaultDependencies")(strcmp((name),("DefaultDependencies")) == 0)) |
1675 | return bus_set_transient_bool(u, name, &u->default_dependencies, message, flags, error); |
1676 | |
1677 | if (streq(name, "OnFailureJobMode")(strcmp((name),("OnFailureJobMode")) == 0)) |
1678 | return bus_set_transient_job_mode(u, name, &u->on_failure_job_mode, message, flags, error); |
1679 | |
1680 | if (streq(name, "IgnoreOnIsolate")(strcmp((name),("IgnoreOnIsolate")) == 0)) |
1681 | return bus_set_transient_bool(u, name, &u->ignore_on_isolate, message, flags, error); |
1682 | |
1683 | if (streq(name, "JobTimeoutUSec")(strcmp((name),("JobTimeoutUSec")) == 0)) { |
1684 | r = bus_set_transient_usec_fix_0(u, name, &u->job_timeout, message, flags, error); |
1685 | if (r >= 0 && !UNIT_WRITE_FLAGS_NOOP(flags)(((flags) & (UNIT_RUNTIME|UNIT_PERSISTENT)) == 0) && !u->job_running_timeout_set) |
1686 | u->job_running_timeout = u->job_timeout; |
1687 | } |
1688 | |
1689 | if (streq(name, "JobRunningTimeoutUSec")(strcmp((name),("JobRunningTimeoutUSec")) == 0)) { |
1690 | r = bus_set_transient_usec_fix_0(u, name, &u->job_running_timeout, message, flags, error); |
1691 | if (r >= 0 && !UNIT_WRITE_FLAGS_NOOP(flags)(((flags) & (UNIT_RUNTIME|UNIT_PERSISTENT)) == 0)) |
1692 | u->job_running_timeout_set = true1; |
1693 | |
1694 | return r; |
1695 | } |
1696 | |
1697 | if (streq(name, "JobTimeoutAction")(strcmp((name),("JobTimeoutAction")) == 0)) |
1698 | return bus_set_transient_emergency_action(u, name, &u->job_timeout_action, message, flags, error); |
1699 | |
1700 | if (streq(name, "JobTimeoutRebootArgument")(strcmp((name),("JobTimeoutRebootArgument")) == 0)) |
1701 | return bus_set_transient_string(u, name, &u->job_timeout_reboot_arg, message, flags, error); |
1702 | |
1703 | if (streq(name, "StartLimitIntervalUSec")(strcmp((name),("StartLimitIntervalUSec")) == 0)) |
1704 | return bus_set_transient_usec(u, name, &u->start_limit.interval, message, flags, error); |
1705 | |
1706 | if (streq(name, "StartLimitBurst")(strcmp((name),("StartLimitBurst")) == 0)) |
1707 | return bus_set_transient_unsigned(u, name, &u->start_limit.burst, message, flags, error); |
1708 | |
1709 | if (streq(name, "StartLimitAction")(strcmp((name),("StartLimitAction")) == 0)) |
1710 | return bus_set_transient_emergency_action(u, name, &u->start_limit_action, message, flags, error); |
1711 | |
1712 | if (streq(name, "FailureAction")(strcmp((name),("FailureAction")) == 0)) |
1713 | return bus_set_transient_emergency_action(u, name, &u->failure_action, message, flags, error); |
1714 | |
1715 | if (streq(name, "SuccessAction")(strcmp((name),("SuccessAction")) == 0)) |
1716 | return bus_set_transient_emergency_action(u, name, &u->success_action, message, flags, error); |
1717 | |
1718 | if (streq(name, "RebootArgument")(strcmp((name),("RebootArgument")) == 0)) |
1719 | return bus_set_transient_string(u, name, &u->reboot_arg, message, flags, error); |
1720 | |
1721 | if (streq(name, "CollectMode")(strcmp((name),("CollectMode")) == 0)) |
1722 | return bus_set_transient_collect_mode(u, name, &u->collect_mode, message, flags, error); |
1723 | |
1724 | if (streq(name, "Conditions")(strcmp((name),("Conditions")) == 0)) |
1725 | return bus_set_transient_conditions(u, name, &u->conditions, true1, message, flags, error); |
1726 | |
1727 | if (streq(name, "Asserts")(strcmp((name),("Asserts")) == 0)) |
1728 | return bus_set_transient_conditions(u, name, &u->asserts, false0, message, flags, error); |
1729 | |
1730 | if (streq(name, "Documentation")(strcmp((name),("Documentation")) == 0)) { |
1731 | _cleanup_strv_free___attribute__((cleanup(strv_freep))) char **l = NULL((void*)0); |
1732 | char **p; |
1733 | |
1734 | r = sd_bus_message_read_strv(message, &l); |
1735 | if (r < 0) |
1736 | return r; |
1737 | |
1738 | STRV_FOREACH(p, l)for ((p) = (l); (p) && *(p); (p)++) { |
1739 | if (!documentation_url_is_valid(*p)) |
1740 | return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS"org.freedesktop.DBus.Error.InvalidArgs", "Invalid URL in %s: %s", name, *p); |
1741 | } |
1742 | |
1743 | if (!UNIT_WRITE_FLAGS_NOOP(flags)(((flags) & (UNIT_RUNTIME|UNIT_PERSISTENT)) == 0)) { |
1744 | if (strv_isempty(l)) { |
1745 | u->documentation = strv_free(u->documentation); |
1746 | unit_write_settingf(u, flags, name, "%s=", name); |
1747 | } else { |
1748 | strv_extend_strv(&u->documentation, l, false0); |
1749 | |
1750 | STRV_FOREACH(p, l)for ((p) = (l); (p) && *(p); (p)++) |
1751 | unit_write_settingf(u, flags, name, "%s=%s", name, *p); |
1752 | } |
1753 | } |
1754 | |
1755 | return 1; |
1756 | |
1757 | } else if (streq(name, "Slice")(strcmp((name),("Slice")) == 0)) { |
1758 | Unit *slice; |
1759 | const char *s; |
1760 | |
1761 | if (!UNIT_HAS_CGROUP_CONTEXT(u)(unit_vtable[(u)->type]->cgroup_context_offset > 0)) |
1762 | return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS"org.freedesktop.DBus.Error.InvalidArgs", "The slice property is only available for units with control groups."); |
1763 | if (u->type == UNIT_SLICE) |
1764 | return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS"org.freedesktop.DBus.Error.InvalidArgs", "Slice may not be set for slice units."); |
1765 | if (unit_has_name(u, SPECIAL_INIT_SCOPE"init.scope")) |
1766 | return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS"org.freedesktop.DBus.Error.InvalidArgs", "Cannot set slice for init.scope"); |
1767 | |
1768 | r = sd_bus_message_read(message, "s", &s); |
1769 | if (r < 0) |
1770 | return r; |
1771 | |
1772 | if (!unit_name_is_valid(s, UNIT_NAME_PLAIN)) |
1773 | return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS"org.freedesktop.DBus.Error.InvalidArgs", "Invalid unit name '%s'", s); |
1774 | |
1775 | /* Note that we do not dispatch the load queue here yet, as we don't want our own transient unit to be |
1776 | * loaded while we are still setting it up. Or in other words, we use manager_load_unit_prepare() |
1777 | * instead of manager_load_unit() on purpose, here. */ |
1778 | r = manager_load_unit_prepare(u->manager, s, NULL((void*)0), error, &slice); |
1779 | if (r < 0) |
1780 | return r; |
1781 | |
1782 | if (slice->type != UNIT_SLICE) |
1783 | return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS"org.freedesktop.DBus.Error.InvalidArgs", "Unit name '%s' is not a slice", s); |
1784 | |
1785 | if (!UNIT_WRITE_FLAGS_NOOP(flags)(((flags) & (UNIT_RUNTIME|UNIT_PERSISTENT)) == 0)) { |
1786 | r = unit_set_slice(u, slice); |
1787 | if (r < 0) |
1788 | return r; |
1789 | |
1790 | unit_write_settingf(u, flags|UNIT_PRIVATE, name, "Slice=%s", s); |
1791 | } |
1792 | |
1793 | return 1; |
1794 | |
1795 | } else if (streq(name, "RequiresMountsFor")(strcmp((name),("RequiresMountsFor")) == 0)) { |
1796 | _cleanup_strv_free___attribute__((cleanup(strv_freep))) char **l = NULL((void*)0); |
1797 | char **p; |
1798 | |
1799 | r = sd_bus_message_read_strv(message, &l); |
1800 | if (r < 0) |
1801 | return r; |
1802 | |
1803 | STRV_FOREACH(p, l)for ((p) = (l); (p) && *(p); (p)++) { |
1804 | if (!path_is_absolute(*p)) |
1805 | return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS"org.freedesktop.DBus.Error.InvalidArgs", "Path specified in %s is not absolute: %s", name, *p); |
1806 | |
1807 | if (!UNIT_WRITE_FLAGS_NOOP(flags)(((flags) & (UNIT_RUNTIME|UNIT_PERSISTENT)) == 0)) { |
1808 | r = unit_require_mounts_for(u, *p, UNIT_DEPENDENCY_FILE); |
1809 | if (r < 0) |
1810 | return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS"org.freedesktop.DBus.Error.InvalidArgs", "Failed to add required mount \"%s\": %m", *p); |
1811 | |
1812 | unit_write_settingf(u, flags, name, "%s=%s", name, *p); |
1813 | } |
1814 | } |
1815 | |
1816 | return 1; |
1817 | } |
1818 | |
1819 | if (streq(name, "RequiresOverridable")(strcmp((name),("RequiresOverridable")) == 0)) |
1820 | d = UNIT_REQUIRES; /* redirect for obsolete unit dependency type */ |
1821 | else if (streq(name, "RequisiteOverridable")(strcmp((name),("RequisiteOverridable")) == 0)) |
1822 | d = UNIT_REQUISITE; /* same here */ |
1823 | else |
1824 | d = unit_dependency_from_string(name); |
1825 | |
1826 | if (d >= 0) { |
1827 | const char *other; |
1828 | |
1829 | r = sd_bus_message_enter_container(message, 'a', "s"); |
1830 | if (r < 0) |
1831 | return r; |
1832 | |
1833 | while ((r = sd_bus_message_read(message, "s", &other)) > 0) { |
1834 | if (!unit_name_is_valid(other, UNIT_NAME_PLAIN|UNIT_NAME_INSTANCE)) |
1835 | return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS"org.freedesktop.DBus.Error.InvalidArgs", "Invalid unit name %s", other); |
1836 | |
1837 | if (!UNIT_WRITE_FLAGS_NOOP(flags)(((flags) & (UNIT_RUNTIME|UNIT_PERSISTENT)) == 0)) { |
1838 | _cleanup_free___attribute__((cleanup(freep))) char *label = NULL((void*)0); |
1839 | |
1840 | r = unit_add_dependency_by_name(u, d, other, NULL((void*)0), true1, UNIT_DEPENDENCY_FILE); |
1841 | if (r < 0) |
1842 | return r; |
1843 | |
1844 | label = strjoin(name, "-", other)strjoin_real((name), "-", other, ((void*)0)); |
1845 | if (!label) |
1846 | return -ENOMEM12; |
1847 | |
1848 | unit_write_settingf(u, flags, label, "%s=%s", unit_dependency_to_string(d), other); |
1849 | } |
1850 | |
1851 | } |
1852 | if (r < 0) |
1853 | return r; |
1854 | |
1855 | r = sd_bus_message_exit_container(message); |
1856 | if (r < 0) |
1857 | return r; |
1858 | |
1859 | return 1; |
1860 | |
1861 | } else if (streq(name, "AddRef")(strcmp((name),("AddRef")) == 0)) { |
1862 | |
1863 | int b; |
1864 | |
1865 | /* Why is this called "AddRef" rather than just "Ref", or "Reference"? There's already a "Ref()" method |
1866 | * on the Unit interface, and it's probably not a good idea to expose a property and a method on the |
1867 | * same interface (well, strictly speaking AddRef isn't exposed as full property, we just read it for |
1868 | * transient units, but still). And "References" and "ReferencedBy" is already used as unit reference |
1869 | * dependency type, hence let's not confuse things with that. |
1870 | * |
1871 | * Note that we don't acually add the reference to the bus track. We do that only after the setup of |
1872 | * the transient unit is complete, so that setting this property multiple times in the same transient |
1873 | * unit creation call doesn't count as individual references. */ |
1874 | |
1875 | r = sd_bus_message_read(message, "b", &b); |
1876 | if (r < 0) |
1877 | return r; |
1878 | |
1879 | if (!UNIT_WRITE_FLAGS_NOOP(flags)(((flags) & (UNIT_RUNTIME|UNIT_PERSISTENT)) == 0)) |
1880 | u->bus_track_add = b; |
1881 | |
1882 | return 1; |
1883 | } |
1884 | |
1885 | return 0; |
1886 | } |
1887 | |
1888 | int bus_unit_set_properties( |
1889 | Unit *u, |
1890 | sd_bus_message *message, |
1891 | UnitWriteFlags flags, |
1892 | bool_Bool commit, |
1893 | sd_bus_error *error) { |
1894 | |
1895 | bool_Bool for_real = false0; |
1896 | unsigned n = 0; |
1897 | int r; |
1898 | |
1899 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 1899, __PRETTY_FUNCTION__ ); } while (0); |
1900 | assert(message)do { if ((__builtin_expect(!!(!(message)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("message"), "../src/core/dbus-unit.c", 1900 , __PRETTY_FUNCTION__); } while (0); |
1901 | |
1902 | /* We iterate through the array twice. First run we just check |
1903 | * if all passed data is valid, second run actually applies |
1904 | * it. This is to implement transaction-like behaviour without |
1905 | * actually providing full transactions. */ |
1906 | |
1907 | r = sd_bus_message_enter_container(message, 'a', "(sv)"); |
1908 | if (r < 0) |
1909 | return r; |
1910 | |
1911 | for (;;) { |
1912 | const char *name; |
1913 | UnitWriteFlags f; |
1914 | |
1915 | r = sd_bus_message_enter_container(message, 'r', "sv"); |
1916 | if (r < 0) |
1917 | return r; |
1918 | if (r == 0) { |
1919 | if (for_real || UNIT_WRITE_FLAGS_NOOP(flags)(((flags) & (UNIT_RUNTIME|UNIT_PERSISTENT)) == 0)) |
1920 | break; |
1921 | |
1922 | /* Reached EOF. Let's try again, and this time for realz... */ |
1923 | r = sd_bus_message_rewind(message, false0); |
1924 | if (r < 0) |
1925 | return r; |
1926 | |
1927 | for_real = true1; |
1928 | continue; |
1929 | } |
1930 | |
1931 | r = sd_bus_message_read(message, "s", &name); |
1932 | if (r < 0) |
1933 | return r; |
1934 | |
1935 | if (!UNIT_VTABLE(u)unit_vtable[(u)->type]->bus_set_property) |
1936 | return sd_bus_error_setf(error, SD_BUS_ERROR_PROPERTY_READ_ONLY"org.freedesktop.DBus.Error.PropertyReadOnly", "Objects of this type do not support setting properties."); |
1937 | |
1938 | r = sd_bus_message_enter_container(message, 'v', NULL((void*)0)); |
1939 | if (r < 0) |
1940 | return r; |
1941 | |
1942 | /* If not for real, then mask out the two target flags */ |
1943 | f = for_real ? flags : (flags & ~(UNIT_RUNTIME|UNIT_PERSISTENT)); |
1944 | |
1945 | r = UNIT_VTABLE(u)unit_vtable[(u)->type]->bus_set_property(u, name, message, f, error); |
1946 | if (r == 0 && u->transient && u->load_state == UNIT_STUB) |
1947 | r = bus_unit_set_transient_property(u, name, message, f, error); |
1948 | if (r == 0) |
1949 | r = bus_unit_set_live_property(u, name, message, f, error); |
1950 | if (r < 0) |
1951 | return r; |
1952 | |
1953 | if (r == 0) |
1954 | return sd_bus_error_setf(error, SD_BUS_ERROR_PROPERTY_READ_ONLY"org.freedesktop.DBus.Error.PropertyReadOnly", "Cannot set property %s, or unknown property.", name); |
1955 | |
1956 | r = sd_bus_message_exit_container(message); |
1957 | if (r < 0) |
1958 | return r; |
1959 | |
1960 | r = sd_bus_message_exit_container(message); |
1961 | if (r < 0) |
1962 | return r; |
1963 | |
1964 | n += for_real; |
1965 | } |
1966 | |
1967 | r = sd_bus_message_exit_container(message); |
1968 | if (r < 0) |
1969 | return r; |
1970 | |
1971 | if (commit && n > 0 && UNIT_VTABLE(u)unit_vtable[(u)->type]->bus_commit_properties) |
1972 | UNIT_VTABLE(u)unit_vtable[(u)->type]->bus_commit_properties(u); |
1973 | |
1974 | return n; |
1975 | } |
1976 | |
1977 | int bus_unit_validate_load_state(Unit *u, sd_bus_error *error) { |
1978 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 1978, __PRETTY_FUNCTION__ ); } while (0); |
1979 | |
1980 | /* Generates a pretty error if a unit isn't properly loaded. */ |
1981 | |
1982 | switch (u->load_state) { |
1983 | |
1984 | case UNIT_LOADED: |
1985 | return 0; |
1986 | |
1987 | case UNIT_NOT_FOUND: |
1988 | return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT"org.freedesktop.systemd1.NoSuchUnit", "Unit %s not found.", u->id); |
1989 | |
1990 | case UNIT_BAD_SETTING: |
1991 | return sd_bus_error_setf(error, BUS_ERROR_BAD_UNIT_SETTING"org.freedesktop.systemd1.BadUnitSetting", "Unit %s has a bad unit file setting.", u->id); |
1992 | |
1993 | case UNIT_ERROR: /* Only show .load_error in UNIT_ERROR state */ |
1994 | return sd_bus_error_set_errnof(error, u->load_error, "Unit %s failed to loaded properly: %m.", u->id); |
1995 | |
1996 | case UNIT_MASKED: |
1997 | return sd_bus_error_setf(error, BUS_ERROR_UNIT_MASKED"org.freedesktop.systemd1.UnitMasked", "Unit %s is masked.", u->id); |
1998 | |
1999 | case UNIT_STUB: |
2000 | case UNIT_MERGED: |
2001 | default: |
2002 | return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT"org.freedesktop.systemd1.NoSuchUnit", "Unexpected load state of unit %s", u->id); |
2003 | } |
2004 | } |
2005 | |
2006 | static int bus_unit_track_handler(sd_bus_track *t, void *userdata) { |
2007 | Unit *u = userdata; |
2008 | |
2009 | assert(t)do { if ((__builtin_expect(!!(!(t)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("t"), "../src/core/dbus-unit.c", 2009, __PRETTY_FUNCTION__ ); } while (0); |
2010 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 2010, __PRETTY_FUNCTION__ ); } while (0); |
2011 | |
2012 | u->bus_track = sd_bus_track_unref(u->bus_track); /* make sure we aren't called again */ |
2013 | |
2014 | /* If the client that tracks us disappeared, then there's reason to believe that the cgroup is empty now too, |
2015 | * let's see */ |
2016 | unit_add_to_cgroup_empty_queue(u); |
2017 | |
2018 | /* Also add the unit to the GC queue, after all if the client left it might be time to GC this unit */ |
2019 | unit_add_to_gc_queue(u); |
2020 | |
2021 | return 0; |
2022 | } |
2023 | |
2024 | static int bus_unit_allocate_bus_track(Unit *u) { |
2025 | int r; |
2026 | |
2027 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 2027, __PRETTY_FUNCTION__ ); } while (0); |
2028 | |
2029 | if (u->bus_track) |
2030 | return 0; |
2031 | |
2032 | r = sd_bus_track_new(u->manager->api_bus, &u->bus_track, bus_unit_track_handler, u); |
2033 | if (r < 0) |
2034 | return r; |
2035 | |
2036 | r = sd_bus_track_set_recursive(u->bus_track, true1); |
2037 | if (r < 0) { |
2038 | u->bus_track = sd_bus_track_unref(u->bus_track); |
2039 | return r; |
2040 | } |
2041 | |
2042 | return 0; |
2043 | } |
2044 | |
2045 | int bus_unit_track_add_name(Unit *u, const char *name) { |
2046 | int r; |
2047 | |
2048 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 2048, __PRETTY_FUNCTION__ ); } while (0); |
2049 | |
2050 | r = bus_unit_allocate_bus_track(u); |
2051 | if (r < 0) |
2052 | return r; |
2053 | |
2054 | return sd_bus_track_add_name(u->bus_track, name); |
2055 | } |
2056 | |
2057 | int bus_unit_track_add_sender(Unit *u, sd_bus_message *m) { |
2058 | int r; |
2059 | |
2060 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 2060, __PRETTY_FUNCTION__ ); } while (0); |
2061 | |
2062 | r = bus_unit_allocate_bus_track(u); |
2063 | if (r < 0) |
2064 | return r; |
2065 | |
2066 | return sd_bus_track_add_sender(u->bus_track, m); |
2067 | } |
2068 | |
2069 | int bus_unit_track_remove_sender(Unit *u, sd_bus_message *m) { |
2070 | assert(u)do { if ((__builtin_expect(!!(!(u)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("u"), "../src/core/dbus-unit.c", 2070, __PRETTY_FUNCTION__ ); } while (0); |
2071 | |
2072 | /* If we haven't allocated the bus track object yet, then there's definitely no reference taken yet, return an |
2073 | * error */ |
2074 | if (!u->bus_track) |
2075 | return -EUNATCH49; |
2076 | |
2077 | return sd_bus_track_remove_sender(u->bus_track, m); |
2078 | } |