From: Tomas Krizek Date: Wed, 15 Jan 2020 13:16:56 +0000 (+0100) Subject: daemon: remove systemd socket activation support X-Git-Tag: v5.0.0~3^2~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=60179f46d6aa2b03705fb619ce73f3681edb7678;p=thirdparty%2Fknot-resolver.git daemon: remove systemd socket activation support --- diff --git a/daemon/main.c b/daemon/main.c index 0b62f6051..d322e22ed 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -304,16 +304,6 @@ static int run_worker(uv_loop_t *loop, struct engine *engine, fd_array_t *ipc_se 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)); @@ -546,55 +536,6 @@ int main(int argc, char **argv) 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 */ diff --git a/meson.build b/meson.build index 9527acafa..7e1b3cd7b 100644 --- a/meson.build +++ b/meson.build @@ -98,12 +98,8 @@ else 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 @@ -257,7 +253,6 @@ run_target( # 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' @@ -284,7 +279,6 @@ message(''' 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) + '''