Bug Summary

File:build-scan/../src/machine/machined.c
Warning:line 42, column 25
Potential leak of memory pointed to by 'm'

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name machined.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -relaxed-aliasing -menable-no-infs -menable-no-nans -menable-unsafe-fp-math -fno-signed-zeros -mreassociate -freciprocal-math -fdenormal-fp-math=preserve-sign,preserve-sign -ffp-contract=fast -fno-rounding-math -ffast-math -ffinite-math-only -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/12.0.0 -include config.h -I systemd-machined.p -I . -I .. -I src/basic -I ../src/basic -I src/shared -I ../src/shared -I src/systemd -I ../src/systemd -I src/journal -I ../src/journal -I src/journal-remote -I ../src/journal-remote -I src/nspawn -I ../src/nspawn -I src/resolve -I ../src/resolve -I src/timesync -I ../src/timesync -I ../src/time-wait-sync -I src/login -I ../src/login -I src/udev -I ../src/udev -I src/libudev -I ../src/libudev -I src/core -I ../src/core -I ../src/libsystemd/sd-bus -I ../src/libsystemd/sd-device -I ../src/libsystemd/sd-hwdb -I ../src/libsystemd/sd-id128 -I ../src/libsystemd/sd-netlink -I ../src/libsystemd/sd-network -I src/libsystemd-network -I ../src/libsystemd-network -D _FILE_OFFSET_BITS=64 -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/12.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wwrite-strings -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-result -Wno-format-signedness -Wno-error=nonnull -std=gnu99 -fconst-strings -fdebug-compilation-dir /home/mrc0mmand/repos/@redhat-plumbers/systemd-rhel8/build-scan -ferror-limit 19 -fvisibility hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcolor-diagnostics -analyzer-output=html -faddrsig -o /tmp/scan-build-2021-07-16-221226-1465241-1 -x c ../src/machine/machined.c
1/* SPDX-License-Identifier: LGPL-2.1+ */
2
3#include <errno(*__errno_location ()).h>
4#include <string.h>
5#include <unistd.h>
6
7#include "sd-daemon.h"
8
9#include "alloc-util.h"
10#include "bus-error.h"
11#include "bus-util.h"
12#include "cgroup-util.h"
13#include "dirent-util.h"
14#include "fd-util.h"
15#include "format-util.h"
16#include "hostname-util.h"
17#include "label.h"
18#include "machine-image.h"
19#include "machined.h"
20#include "process-util.h"
21#include "signal-util.h"
22#include "special.h"
23
24static Manager* manager_unref(Manager *m);
25DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_unref)static inline void manager_unrefp(Manager* *p) { if (*p) manager_unref
(*p); }
;
26
27static int manager_new(Manager **ret) {
28 _cleanup_(manager_unrefp)__attribute__((cleanup(manager_unrefp))) Manager *m = NULL((void*)0);
29 int r;
30
31 assert(ret)do { if ((__builtin_expect(!!(!(ret)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("ret"), "../src/machine/machined.c", 31,
__PRETTY_FUNCTION__); } while (0)
;
7
Taking false branch
8
Loop condition is false. Exiting loop
32
33 m = new0(Manager, 1)((Manager*) calloc((1), sizeof(Manager)));
9
Memory is allocated
34 if (!m)
10
Assuming 'm' is non-null
11
Taking false branch
35 return -ENOMEM12;
36
37 m->machines = hashmap_new(&string_hash_ops)internal_hashmap_new(&string_hash_ops );
38 m->machine_units = hashmap_new(&string_hash_ops)internal_hashmap_new(&string_hash_ops );
39 m->machine_leaders = hashmap_new(NULL)internal_hashmap_new(((void*)0) );
40
41 if (!m->machines || !m->machine_units || !m->machine_leaders)
12
Assuming field 'machines' is null
42 return -ENOMEM12;
13
Potential leak of memory pointed to by 'm'
43
44 r = sd_event_default(&m->event);
45 if (r < 0)
46 return r;
47
48 r = sd_event_add_signal(m->event, NULL((void*)0), SIGINT2, NULL((void*)0), NULL((void*)0));
49 if (r < 0)
50 return r;
51
52 r = sd_event_add_signal(m->event, NULL((void*)0), SIGTERM15, NULL((void*)0), NULL((void*)0));
53 if (r < 0)
54 return r;
55
56 (void) sd_event_set_watchdog(m->event, true1);
57
58 *ret = TAKE_PTR(m)({ typeof(m) _ptr_ = (m); (m) = ((void*)0); _ptr_; });
59 return 0;
60}
61
62static Manager* manager_unref(Manager *m) {
63 Machine *machine;
64
65 if (!m)
66 return NULL((void*)0);
67
68 while (m->operations)
69 operation_free(m->operations);
70
71 assert(m->n_operations == 0)do { if ((__builtin_expect(!!(!(m->n_operations == 0)),0))
) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("m->n_operations == 0"
), "../src/machine/machined.c", 71, __PRETTY_FUNCTION__); } while
(0)
;
72
73 while ((machine = hashmap_first(m->machines)))
74 machine_free(machine);
75
76 hashmap_free(m->machines);
77 hashmap_free(m->machine_units);
78 hashmap_free(m->machine_leaders);
79
80 hashmap_free_with_destructor(m->image_cache, image_unref)({ ({ void *_item; while ((_item = hashmap_steal_first(m->
image_cache))) image_unref(_item); }); hashmap_free(m->image_cache
); })
;
81
82 sd_event_source_unref(m->image_cache_defer_event);
83
84 bus_verify_polkit_async_registry_free(m->polkit_registry);
85
86 sd_bus_unref(m->bus);
87 sd_event_unref(m->event);
88
89 return mfree(m);
90}
91
92static int manager_add_host_machine(Manager *m) {
93 _cleanup_free___attribute__((cleanup(freep))) char *rd = NULL((void*)0), *unit = NULL((void*)0);
94 sd_id128_t mid;
95 Machine *t;
96 int r;
97
98 if (m->host_machine)
99 return 0;
100
101 r = sd_id128_get_machine(&mid);
102 if (r < 0)
103 return log_error_errno(r, "Failed to get machine ID: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/machine/machined.c", 103, __func__, "Failed to get machine ID: %m"
) : -abs(_e); })
;
104
105 rd = strdup("/");
106 if (!rd)
107 return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/machine/machined.c"
, 107, __func__)
;
108
109 unit = strdup(SPECIAL_ROOT_SLICE"-.slice");
110 if (!unit)
111 return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/machine/machined.c"
, 111, __func__)
;
112
113 t = machine_new(m, MACHINE_HOST, ".host");
114 if (!t)
115 return log_oom()log_oom_internal(LOG_REALM_SYSTEMD, "../src/machine/machined.c"
, 115, __func__)
;
116
117 t->leader = 1;
118 t->id = mid;
119
120 t->root_directory = TAKE_PTR(rd)({ typeof(rd) _ptr_ = (rd); (rd) = ((void*)0); _ptr_; });
121 t->unit = TAKE_PTR(unit)({ typeof(unit) _ptr_ = (unit); (unit) = ((void*)0); _ptr_; }
)
;
122
123 dual_timestamp_from_boottime_or_monotonic(&t->timestamp, 0);
124
125 m->host_machine = t;
126
127 return 0;
128}
129
130static int manager_enumerate_machines(Manager *m) {
131 _cleanup_closedir___attribute__((cleanup(closedirp))) DIR *d = NULL((void*)0);
132 struct dirent *de;
133 int r = 0;
134
135 assert(m)do { if ((__builtin_expect(!!(!(m)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("m"), "../src/machine/machined.c", 135, __PRETTY_FUNCTION__
); } while (0)
;
136
137 r = manager_add_host_machine(m);
138 if (r < 0)
139 return r;
140
141 /* Read in machine data stored on disk */
142 d = opendir("/run/systemd/machines");
143 if (!d) {
144 if (errno(*__errno_location ()) == ENOENT2)
145 return 0;
146
147 return log_error_errno(errno, "Failed to open /run/systemd/machines: %m")({ int _level = ((3)), _e = (((*__errno_location ()))), _realm
= (LOG_REALM_SYSTEMD); (log_get_max_level_realm(_realm) >=
((_level) & 0x07)) ? log_internal_realm(((_realm) <<
10 | (_level)), _e, "../src/machine/machined.c", 147, __func__
, "Failed to open /run/systemd/machines: %m") : -abs(_e); })
;
148 }
149
150 FOREACH_DIRENT(de, d, return -errno)for ((*__errno_location ()) = 0, de = readdir(d);; (*__errno_location
()) = 0, de = readdir(d)) if (!de) { if ((*__errno_location (
)) > 0) { return -(*__errno_location ()); } break; } else if
(hidden_or_backup_file((de)->d_name)) continue; else
{
151 struct Machine *machine;
152 int k;
153
154 if (!dirent_is_file(de))
155 continue;
156
157 /* Ignore symlinks that map the unit name to the machine */
158 if (startswith(de->d_name, "unit:"))
159 continue;
160
161 if (!machine_name_is_valid(de->d_name)hostname_is_valid(de->d_name, 0))
162 continue;
163
164 k = manager_add_machine(m, de->d_name, &machine);
165 if (k < 0) {
166 r = log_error_errno(k, "Failed to add machine by file name %s: %m", de->d_name)({ int _level = ((3)), _e = ((k)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/machine/machined.c", 166, __func__, "Failed to add machine by file name %s: %m"
, de->d_name) : -abs(_e); })
;
167 continue;
168 }
169
170 machine_add_to_gc_queue(machine);
171
172 k = machine_load(machine);
173 if (k < 0)
174 r = k;
175 }
176
177 return r;
178}
179
180static int manager_connect_bus(Manager *m) {
181 int r;
182
183 assert(m)do { if ((__builtin_expect(!!(!(m)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("m"), "../src/machine/machined.c", 183, __PRETTY_FUNCTION__
); } while (0)
;
184 assert(!m->bus)do { if ((__builtin_expect(!!(!(!m->bus)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("!m->bus"), "../src/machine/machined.c"
, 184, __PRETTY_FUNCTION__); } while (0)
;
185
186 r = sd_bus_default_system(&m->bus);
187 if (r < 0)
188 return log_error_errno(r, "Failed to connect to system bus: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/machine/machined.c", 188, __func__, "Failed to connect to system bus: %m"
) : -abs(_e); })
;
189
190 r = sd_bus_add_object_vtable(m->bus, NULL((void*)0), "/org/freedesktop/machine1", "org.freedesktop.machine1.Manager", manager_vtable, m);
191 if (r < 0)
192 return log_error_errno(r, "Failed to add manager object vtable: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/machine/machined.c", 192, __func__, "Failed to add manager object vtable: %m"
) : -abs(_e); })
;
193
194 r = sd_bus_add_fallback_vtable(m->bus, NULL((void*)0), "/org/freedesktop/machine1/machine", "org.freedesktop.machine1.Machine", machine_vtable, machine_object_find, m);
195 if (r < 0)
196 return log_error_errno(r, "Failed to add machine object vtable: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/machine/machined.c", 196, __func__, "Failed to add machine object vtable: %m"
) : -abs(_e); })
;
197
198 r = sd_bus_add_node_enumerator(m->bus, NULL((void*)0), "/org/freedesktop/machine1/machine", machine_node_enumerator, m);
199 if (r < 0)
200 return log_error_errno(r, "Failed to add machine enumerator: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/machine/machined.c", 200, __func__, "Failed to add machine enumerator: %m"
) : -abs(_e); })
;
201
202 r = sd_bus_add_fallback_vtable(m->bus, NULL((void*)0), "/org/freedesktop/machine1/image", "org.freedesktop.machine1.Image", image_vtable, image_object_find, m);
203 if (r < 0)
204 return log_error_errno(r, "Failed to add image object vtable: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/machine/machined.c", 204, __func__, "Failed to add image object vtable: %m"
) : -abs(_e); })
;
205
206 r = sd_bus_add_node_enumerator(m->bus, NULL((void*)0), "/org/freedesktop/machine1/image", image_node_enumerator, m);
207 if (r < 0)
208 return log_error_errno(r, "Failed to add image enumerator: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/machine/machined.c", 208, __func__, "Failed to add image enumerator: %m"
) : -abs(_e); })
;
209
210 r = sd_bus_match_signal_async(
211 m->bus,
212 NULL((void*)0),
213 "org.freedesktop.systemd1",
214 "/org/freedesktop/systemd1",
215 "org.freedesktop.systemd1.Manager",
216 "JobRemoved",
217 match_job_removed, NULL((void*)0), m);
218 if (r < 0)
219 return log_error_errno(r, "Failed to add match for JobRemoved: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/machine/machined.c", 219, __func__, "Failed to add match for JobRemoved: %m"
) : -abs(_e); })
;
220
221 r = sd_bus_match_signal_async(
222 m->bus,
223 NULL((void*)0),
224 "org.freedesktop.systemd1",
225 "/org/freedesktop/systemd1",
226 "org.freedesktop.systemd1.Manager",
227 "UnitRemoved",
228 match_unit_removed, NULL((void*)0), m);
229 if (r < 0)
230 return log_error_errno(r, "Failed to request match for UnitRemoved: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/machine/machined.c", 230, __func__, "Failed to request match for UnitRemoved: %m"
) : -abs(_e); })
;
231
232 r = sd_bus_match_signal_async(
233 m->bus,
234 NULL((void*)0),
235 "org.freedesktop.systemd1",
236 NULL((void*)0),
237 "org.freedesktop.DBus.Properties",
238 "PropertiesChanged",
239 match_properties_changed, NULL((void*)0), m);
240 if (r < 0)
241 return log_error_errno(r, "Failed to request match for PropertiesChanged: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/machine/machined.c", 241, __func__, "Failed to request match for PropertiesChanged: %m"
) : -abs(_e); })
;
242
243 r = sd_bus_match_signal_async(
244 m->bus,
245 NULL((void*)0),
246 "org.freedesktop.systemd1",
247 "/org/freedesktop/systemd1",
248 "org.freedesktop.systemd1.Manager",
249 "Reloading",
250 match_reloading, NULL((void*)0), m);
251 if (r < 0)
252 return log_error_errno(r, "Failed to request match for Reloading: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/machine/machined.c", 252, __func__, "Failed to request match for Reloading: %m"
) : -abs(_e); })
;
253
254 r = sd_bus_call_method_async(
255 m->bus,
256 NULL((void*)0),
257 "org.freedesktop.systemd1",
258 "/org/freedesktop/systemd1",
259 "org.freedesktop.systemd1.Manager",
260 "Subscribe",
261 NULL((void*)0), NULL((void*)0),
262 NULL((void*)0));
263 if (r < 0)
264 return log_error_errno(r, "Failed to enable subscription: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/machine/machined.c", 264, __func__, "Failed to enable subscription: %m"
) : -abs(_e); })
;
265
266 r = sd_bus_request_name_async(m->bus, NULL((void*)0), "org.freedesktop.machine1", 0, NULL((void*)0), NULL((void*)0));
267 if (r < 0)
268 return log_error_errno(r, "Failed to request name: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/machine/machined.c", 268, __func__, "Failed to request name: %m"
) : -abs(_e); })
;
269
270 r = sd_bus_attach_event(m->bus, m->event, 0);
271 if (r < 0)
272 return log_error_errno(r, "Failed to attach bus to event loop: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/machine/machined.c", 272, __func__, "Failed to attach bus to event loop: %m"
) : -abs(_e); })
;
273
274 return 0;
275}
276
277static void manager_gc(Manager *m, bool_Bool drop_not_started) {
278 Machine *machine;
279
280 assert(m)do { if ((__builtin_expect(!!(!(m)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("m"), "../src/machine/machined.c", 280, __PRETTY_FUNCTION__
); } while (0)
;
281
282 while ((machine = m->machine_gc_queue)) {
283 LIST_REMOVE(gc_queue, m->machine_gc_queue, machine)do { typeof(*(m->machine_gc_queue)) **_head = &(m->
machine_gc_queue), *_item = (machine); do { if ((__builtin_expect
(!!(!(_item)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD,
("_item"), "../src/machine/machined.c", 283, __PRETTY_FUNCTION__
); } while (0); if (_item->gc_queue_next) _item->gc_queue_next
->gc_queue_prev = _item->gc_queue_prev; if (_item->gc_queue_prev
) _item->gc_queue_prev->gc_queue_next = _item->gc_queue_next
; else { do { if ((__builtin_expect(!!(!(*_head == _item)),0)
)) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("*_head == _item"
), "../src/machine/machined.c", 283, __PRETTY_FUNCTION__); } while
(0); *_head = _item->gc_queue_next; } _item->gc_queue_next
= _item->gc_queue_prev = ((void*)0); } while (0)
;
284 machine->in_gc_queue = false0;
285
286 /* First, if we are not closing yet, initiate stopping */
287 if (machine_may_gc(machine, drop_not_started) &&
288 machine_get_state(machine) != MACHINE_CLOSING)
289 machine_stop(machine);
290
291 /* Now, the stop probably made this referenced
292 * again, but if it didn't, then it's time to let it
293 * go entirely. */
294 if (machine_may_gc(machine, drop_not_started)) {
295 machine_finalize(machine);
296 machine_free(machine);
297 }
298 }
299}
300
301static int manager_startup(Manager *m) {
302 Machine *machine;
303 Iterator i;
304 int r;
305
306 assert(m)do { if ((__builtin_expect(!!(!(m)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("m"), "../src/machine/machined.c", 306, __PRETTY_FUNCTION__
); } while (0)
;
307
308 /* Connect to the bus */
309 r = manager_connect_bus(m);
310 if (r < 0)
311 return r;
312
313 /* Deserialize state */
314 manager_enumerate_machines(m);
315
316 /* Remove stale objects before we start them */
317 manager_gc(m, false0);
318
319 /* And start everything */
320 HASHMAP_FOREACH(machine, m->machines, i)for ((i) = ((Iterator) { .idx = ((2147483647 *2U +1U) - 1), .
next_key = ((void*)0) }); hashmap_iterate((m->machines), &
(i), (void**)&(machine), ((void*)0)); )
321 machine_start(machine, NULL((void*)0), NULL((void*)0));
322
323 return 0;
324}
325
326static bool_Bool check_idle(void *userdata) {
327 Manager *m = userdata;
328
329 if (m->operations)
330 return false0;
331
332 manager_gc(m, true1);
333
334 return hashmap_isempty(m->machines);
335}
336
337static int manager_run(Manager *m) {
338 assert(m)do { if ((__builtin_expect(!!(!(m)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("m"), "../src/machine/machined.c", 338, __PRETTY_FUNCTION__
); } while (0)
;
339
340 return bus_event_loop_with_idle(
341 m->event,
342 m->bus,
343 "org.freedesktop.machine1",
344 DEFAULT_EXIT_USEC(30*((usec_t) 1000000ULL)),
345 check_idle, m);
346}
347
348int main(int argc, char *argv[]) {
349 _cleanup_(manager_unrefp)__attribute__((cleanup(manager_unrefp))) Manager *m = NULL((void*)0);
350 int r;
351
352 log_set_target(LOG_TARGET_AUTO);
353 log_set_facility(LOG_AUTH(4<<3));
354 log_parse_environment()log_parse_environment_realm(LOG_REALM_SYSTEMD);
355 log_open();
356
357 umask(0022);
358
359 if (argc != 1) {
1
Assuming 'argc' is equal to 1
2
Taking false branch
360 log_error("This program takes no arguments.")({ int _level = (((3))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/machine/machined.c", 360, __func__, "This program takes no arguments."
) : -abs(_e); })
;
361 r = -EINVAL22;
362 goto finish;
363 }
364
365 /* Always create the directories people can create inotify watches in. Note that some applications might check
366 * for the existence of /run/systemd/machines/ to determine whether machined is available, so please always
367 * make sure this check stays in. */
368 (void) mkdir_label("/run/systemd/machines", 0755);
369
370 assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD, SIGTERM, SIGINT, -1) >= 0)do { if ((__builtin_expect(!!(!(sigprocmask_many(0, ((void*)0
), 17, 15, 2, -1) >= 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD, SIGTERM, SIGINT, -1) >= 0"
), "../src/machine/machined.c", 370, __PRETTY_FUNCTION__); } while
(0)
;
3
Assuming the condition is true
4
Taking false branch
5
Loop condition is false. Exiting loop
371
372 r = manager_new(&m);
6
Calling 'manager_new'
373 if (r < 0) {
374 log_error_errno(r, "Failed to allocate manager object: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/machine/machined.c", 374, __func__, "Failed to allocate manager object: %m"
) : -abs(_e); })
;
375 goto finish;
376 }
377
378 r = manager_startup(m);
379 if (r < 0) {
380 log_error_errno(r, "Failed to fully start up daemon: %m")({ int _level = ((3)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/machine/machined.c", 380, __func__, "Failed to fully start up daemon: %m"
) : -abs(_e); })
;
381 goto finish;
382 }
383
384 log_debug("systemd-machined running as pid "PID_FMT, getpid_cached())({ int _level = (((7))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/machine/machined.c", 384, __func__, "systemd-machined running as pid "
"%" "i", getpid_cached()) : -abs(_e); })
;
385
386 (void) sd_notify(false0,
387 "READY=1\n"
388 "STATUS=Processing requests...");
389
390 r = manager_run(m);
391
392 log_debug("systemd-machined stopped as pid "PID_FMT, getpid_cached())({ int _level = (((7))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/machine/machined.c", 392, __func__, "systemd-machined stopped as pid "
"%" "i", getpid_cached()) : -abs(_e); })
;
393
394 (void) sd_notify(false0,
395 "STOPPING=1\n"
396 "STATUS=Shutting down...");
397
398finish:
399 return r < 0 ? EXIT_FAILURE1 : EXIT_SUCCESS0;
400}