1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 #include <sys/stat.h>
4 #include <sys/types.h>
5
6 #include "bus-log-control-api.h"
7 #include "daemon-util.h"
8 #include "homed-manager.h"
9 #include "homed-manager-bus.h"
10 #include "log.h"
11 #include "main-func.h"
12 #include "service-util.h"
13 #include "signal-util.h"
14
run(int argc,char * argv[])15 static int run(int argc, char *argv[]) {
16 _cleanup_(manager_freep) Manager *m = NULL;
17 _unused_ _cleanup_(notify_on_cleanup) const char *notify_stop = NULL;
18 int r;
19
20 log_setup();
21
22 r = service_parse_argv("systemd-homed.service",
23 "A service to create, remove, change or inspect home areas.",
24 BUS_IMPLEMENTATIONS(&manager_object,
25 &log_control_object),
26 argc, argv);
27 if (r <= 0)
28 return r;
29
30 umask(0022);
31
32 assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD, SIGTERM, SIGINT, -1) >= 0);
33
34 r = manager_new(&m);
35 if (r < 0)
36 return log_error_errno(r, "Could not create manager: %m");
37
38 r = manager_startup(m);
39 if (r < 0)
40 return log_error_errno(r, "Failed to start up daemon: %m");
41
42 notify_stop = notify_start(NOTIFY_READY, NOTIFY_STOPPING);
43
44 r = sd_event_loop(m->event);
45 if (r < 0)
46 return log_error_errno(r, "Event loop failed: %m");
47
48 return 0;
49 }
50
51 DEFINE_MAIN_FUNCTION(run);
52