Skip to content

Commit

Permalink
socket_activated_responders: check confdb
Browse files Browse the repository at this point in the history
(instead of sssd.conf) using new helper to take into
account implictly configured services.

Resolves: SSSD#5013
  • Loading branch information
alexey-tikhonov committed Oct 9, 2024
1 parent 904a414 commit 16604ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 42 deletions.
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
48 changes: 6 additions & 42 deletions src/tools/sssd_check_socket_activated_responders.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,71 +24,35 @@
#include <stdio.h>

#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);
Expand Down

0 comments on commit 16604ca

Please sign in to comment.