return EXIT_SUCCESS;
}
-#if SYSTEMD_VERSION >= 227
-static void free_sd_socket_names(char **socket_names, int count)
-{
- for (int i = 0; i < count; i++) {
- free(socket_names[i]);
- }
- free(socket_names);
-}
-#endif
-
static void args_init(struct args *args)
{
memset(args, 0, sizeof(struct args));
ret = bind_sockets(&the_args->addrs_tls, true, &the_args->fds);
if (ret) goto cleanup_args;
-#if SYSTEMD_VERSION >= 227
- /* Accept passed sockets from systemd supervisor. */
- char **socket_names = NULL;
- int sd_nsocks = sd_listen_fds_with_names(0, &socket_names);
- if (sd_nsocks < 0) {
- kr_log_error("[system] failed passing sockets from systemd: %s\n",
- kr_strerror(sd_nsocks));
- free_sd_socket_names(socket_names, sd_nsocks);
- ret = EXIT_FAILURE;
- goto cleanup_args;
- }
- if (sd_nsocks > 0 && the_args->forks != 1) {
- kr_log_error("[system] when run under systemd-style supervision, "
- "use single-process only (bad: --forks=%d).\n", the_args->forks);
- free_sd_socket_names(socket_names, sd_nsocks);
- ret = EXIT_FAILURE;
- goto cleanup_args;
- }
- for (int i = 0; i < sd_nsocks; ++i) {
- /* when run under systemd supervision, do not use interactive mode */
- the_args->interactive = false;
- flagged_fd_t ffd = { .fd = SD_LISTEN_FDS_START + i };
-
- if (!strcasecmp("control", socket_names[i])) {
- if (the_args->control_fd != -1) {
- kr_log_error("[system] multiple control sockets passed from systemd\n");
- ret = EXIT_FAILURE;
- break;
- }
- the_args->control_fd = ffd.fd;
- free(socket_names[i]);
- } else {
- if (!strcasecmp("dns", socket_names[i])) {
- free(socket_names[i]);
- } else if (!strcasecmp("tls", socket_names[i])) {
- ffd.flags.tls = true;
- free(socket_names[i]);
- } else {
- ffd.flags.kind = socket_names[i];
- }
- array_push(the_args->fds, ffd);
- }
- /* Either freed or passed ownership. */
- socket_names[i] = NULL;
- }
- free_sd_socket_names(socket_names, sd_nsocks);
- if (ret) goto cleanup_args;
-#endif
-
/* Switch to rundir. */
if (the_args->rundir != NULL) {
/* FIXME: access isn't a good way if we start as root and drop privileges later */
endif
### Systemd
-libsystemd = dependency('libsystemd', required: false)
systemd_files = get_option('systemd_files')
-if systemd_files == 'enabled' and (
- not libsystemd.found() or libsystemd.version().version_compare('<227'))
- error('systemd_files=enabled requires libsystemd >= 227')
-endif
+libsystemd = dependency('libsystemd', required: systemd_files == 'enabled')
message('---------------------------')
## Compiler args
# https://github.com/mesonbuild/meson/issues/2404
s_managed_ta = managed_ta ? 'enabled' : 'disabled'
s_install_root_keys = install_root_keys ? 'enabled' : 'disabled'
-s_systemd_socket = libsystemd.found() ? 'enabled' : 'disabled'
s_build_client = build_client ? 'enabled' : 'disabled'
s_build_utils = build_utils ? 'enabled' : 'disabled'
s_build_dnstap = build_dnstap ? 'enabled' : 'disabled'
install_root_keys: @0@'''.format(s_install_root_keys) + '''
systemd:
- socket activation: @0@'''.format(s_systemd_socket) + '''
files: @0@'''.format(systemd_files) + '''
work_dir: @0@'''.format(systemd_work_dir) + '''