From e9715b172725720ff63db31d35b54c2a8d86d39e Mon Sep 17 00:00:00 2001 From: Alexey Tikhonov Date: Wed, 9 Oct 2024 13:12:54 +0200 Subject: [PATCH] socket_activated_responders: check confdb (instead of sssd.conf) using new helper to take into account implictly configured services. Resolves: https://github.com/SSSD/sssd/issues/5013 --- Makefile.am | 1 + .../sssd_check_socket_activated_responders.c | 48 +++---------------- 2 files changed, 7 insertions(+), 42 deletions(-) diff --git a/Makefile.am b/Makefile.am index f13bc3799bf..839b25eae0e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2004,6 +2004,7 @@ endif if HAVE_SYSTEMD_UNIT sssd_check_socket_activated_responders_SOURCES = \ src/tools/sssd_check_socket_activated_responders.c \ + src/tools/common/sss_tools.c \ $(NULL) sssd_check_socket_activated_responders_CFLAGS = \ $(AM_CFLAGS) \ diff --git a/src/tools/sssd_check_socket_activated_responders.c b/src/tools/sssd_check_socket_activated_responders.c index dddc02ee24e..3e880ccb4ef 100644 --- a/src/tools/sssd_check_socket_activated_responders.c +++ b/src/tools/sssd_check_socket_activated_responders.c @@ -24,71 +24,35 @@ #include #include "util/util.h" -#include "util/sss_ini.h" #include "confdb/confdb.h" +#include "common/sss_tools.h" static errno_t check_socket_activated_responder(const char *responder) { errno_t ret; - char *services = NULL; - const char *str; TALLOC_CTX *tmp_ctx; - struct sss_ini *init_data; + struct confdb_ctx *confdb; + char **services = NULL; tmp_ctx = talloc_new(NULL); if (tmp_ctx == NULL) { return ENOMEM; } - init_data = sss_ini_new(tmp_ctx); - if (init_data == NULL) { - ret = ENOMEM; - goto done; - } - - ret = sss_ini_read_sssd_conf(init_data, - SSSD_CONFIG_FILE, - CONFDB_DEFAULT_CONFIG_DIR); + ret = sss_tool_confdb_init(tmp_ctx, &confdb); if (ret != EOK) { - DEBUG(SSSDBG_DEFAULT, - "Failed to read configuration: [%d] [%s]. No reason to run " - "a responder if SSSD isn't configured.", - ret, - sss_strerror(ret)); goto done; } - ret = sss_ini_get_cfgobj(init_data, "sssd", "services"); - + ret = confdb_get_services_as_list(confdb, tmp_ctx, &services); if (ret != EOK) { - DEBUG(SSSDBG_CRIT_FAILURE, - "sss_ini_get_cfgobj() failed [%d].\n", ret); - goto done; - } - - ret = sss_ini_check_config_obj(init_data); - if (ret == ENOENT) { - /* In case there's no services' line at all, just return EOK. */ - ret = EOK; goto done; } - services = sss_ini_get_string_config_value(init_data, &ret); - if (ret != EOK) { - DEBUG(SSSDBG_CRIT_FAILURE, - "sss_ini_get_string_config_value() failed [%d]\n", - ret); - goto done; - } - - str = strstr(services, responder); - if (str != NULL) { + if (string_in_list(responder, services, false)) { ret = EEXIST; - goto done; } - ret = EOK; - done: free(services); talloc_free(tmp_ctx);