]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/userdb/userdbd.c
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
6 #include "daemon-util.h"
7 #include "userdbd-manager.h"
10 #include "signal-util.h"
12 /* This service offers two Varlink services, both implementing io.systemd.UserDatabase:
14 * → io.systemd.NameServiceSwitch: this is a compatibility interface for glibc NSS: it responds to
15 * name lookups by checking the classic NSS interfaces and responding that.
17 * → io.systemd.Multiplexer: this multiplexes lookup requests to all Varlink services that have a
18 * socket in /run/systemd/userdb/. It's supposed to simplify clients that don't want to implement
19 * the full iterative logic on their own.
21 * → io.systemd.DropIn: this makes JSON user/group records dropped into /run/userdb/ available as
25 static int run(int argc
, char *argv
[]) {
26 _cleanup_(manager_freep
) Manager
*m
= NULL
;
27 _unused_
_cleanup_(notify_on_cleanup
) const char *notify_stop
= NULL
;
35 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
), "This program takes no arguments.");
37 if (setenv("SYSTEMD_BYPASS_USERDB", "io.systemd.NameServiceSwitch:io.systemd.Multiplexer:io.systemd.DropIn", 1) < 0)
38 return log_error_errno(errno
, "Failed to set $SYSTEMD_BYPASS_USERDB: %m");
40 assert_se(sigprocmask_many(SIG_BLOCK
, NULL
, SIGCHLD
) >= 0);
44 return log_error_errno(r
, "Could not create manager: %m");
46 r
= manager_startup(m
);
48 return log_error_errno(r
, "Failed to start up daemon: %m");
50 notify_stop
= notify_start(NOTIFY_READY
, NOTIFY_STOPPING
);
52 r
= sd_event_loop(m
->event
);
54 return log_error_errno(r
, "Event loop failed: %m");
59 DEFINE_MAIN_FUNCTION(run
);