Skip to content

Commit

Permalink
UTILS: Add the db file name to server_setup()'s parameters
Browse files Browse the repository at this point in the history
The db file was forced to CONFDB_FILE and there was no possibility of
changing it. Now it is passed as an argument.
  • Loading branch information
aplopez committed Sep 27, 2023
1 parent 5346f5b commit 6e7d9db
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/monitor/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -2226,7 +2226,7 @@ int main(int argc, const char *argv[])
ret = close(STDIN_FILENO);
if (ret != EOK) return 6;

ret = server_setup(SSSD_MONITOR_NAME, false, flags, 0, 0,
ret = server_setup(SSSD_MONITOR_NAME, false, flags, 0, 0, CONFDB_FILE,
monitor->conf_path, &main_ctx, false);
if (ret != EOK) return 2;

Expand Down
3 changes: 2 additions & 1 deletion src/providers/data_provider_be.c
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,8 @@ int main(int argc, const char *argv[])
confdb_path = talloc_asprintf(NULL, CONFDB_DOMAIN_PATH_TMPL, be_domain);
if (!confdb_path) return 2;

ret = server_setup(srv_name, false, 0, 0, 0, confdb_path, &main_ctx, false);
ret = server_setup(srv_name, false, 0, 0, 0, CONFDB_FILE,
confdb_path, &main_ctx, false);
if (ret != EOK) {
DEBUG(SSSDBG_FATAL_FAILURE, "Could not set up mainloop [%d]\n", ret);
return 2;
Expand Down
3 changes: 2 additions & 1 deletion src/providers/proxy/proxy_child.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,8 @@ int main(int argc, const char *argv[])
conf_entry = talloc_asprintf(NULL, CONFDB_DOMAIN_PATH_TMPL, domain);
if (!conf_entry) return 2;

ret = server_setup(srv_name, false, 0, 0, 0, conf_entry, &main_ctx, true);
ret = server_setup(srv_name, false, 0, 0, 0, CONFDB_FILE, conf_entry,
&main_ctx, true);
if (ret != EOK) {
DEBUG(SSSDBG_FATAL_FAILURE, "Could not set up mainloop [%d]\n", ret);
return 2;
Expand Down
2 changes: 1 addition & 1 deletion src/responder/autofs/autofssrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ int main(int argc, const char *argv[])
debug_log_file = "sssd_autofs";
DEBUG_INIT(debug_level, opt_logger);

ret = server_setup("autofs", true, 0, uid, gid,
ret = server_setup("autofs", true, 0, uid, gid, CONFDB_FILE,
CONFDB_AUTOFS_CONF_ENTRY, &main_ctx, true);
if (ret != EOK) {
return 2;
Expand Down
2 changes: 1 addition & 1 deletion src/responder/ifp/ifpsrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ int main(int argc, const char *argv[])
debug_log_file = "sssd_ifp";
DEBUG_INIT(debug_level, opt_logger);

ret = server_setup("ifp", true, 0, uid, gid,
ret = server_setup("ifp", true, 0, uid, gid, CONFDB_FILE,
CONFDB_IFP_CONF_ENTRY, &main_ctx, true);
if (ret != EOK) return 2;

Expand Down
4 changes: 2 additions & 2 deletions src/responder/kcm/kcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ int main(int argc, const char *argv[])
debug_log_file = "sssd_kcm";
DEBUG_INIT(debug_level, opt_logger);

ret = server_setup("kcm", true, 0, uid, gid, CONFDB_KCM_CONF_ENTRY,
&main_ctx, true);
ret = server_setup("kcm", true, 0, uid, gid, CONFDB_FILE,
CONFDB_KCM_CONF_ENTRY, &main_ctx, true);
if (ret != EOK) return 2;

ret = die_if_parent_died();
Expand Down
4 changes: 2 additions & 2 deletions src/responder/nss/nsssrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,8 +716,8 @@ int main(int argc, const char *argv[])
debug_log_file = "sssd_nss";
DEBUG_INIT(debug_level, opt_logger);

ret = server_setup("nss", true, 0, uid, gid, CONFDB_NSS_CONF_ENTRY,
&main_ctx, false);
ret = server_setup("nss", true, 0, uid, gid, CONFDB_FILE,
CONFDB_NSS_CONF_ENTRY, &main_ctx, false);
if (ret != EOK) return 2;

ret = die_if_parent_died();
Expand Down
2 changes: 1 addition & 1 deletion src/responder/pac/pacsrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ int main(int argc, const char *argv[])
debug_log_file = "sssd_pac";
DEBUG_INIT(debug_level, opt_logger);

ret = server_setup("pac", true, 0, uid, gid,
ret = server_setup("pac", true, 0, uid, gid, CONFDB_FILE,
CONFDB_PAC_CONF_ENTRY, &main_ctx, true);
if (ret != EOK) return 2;

Expand Down
4 changes: 2 additions & 2 deletions src/responder/pam/pamsrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,8 @@ int main(int argc, const char *argv[])
"debugging might not work!\n");
}

ret = server_setup("pam", true, 0, uid, gid, CONFDB_PAM_CONF_ENTRY,
&main_ctx, false);
ret = server_setup("pam", true, 0, uid, gid, CONFDB_FILE,
CONFDB_PAM_CONF_ENTRY, &main_ctx, false);
if (ret != EOK) return 2;

ret = die_if_parent_died();
Expand Down
2 changes: 1 addition & 1 deletion src/responder/ssh/sshsrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ int main(int argc, const char *argv[])
"debugging might not work!\n");
}

ret = server_setup("ssh", true, 0, uid, gid,
ret = server_setup("ssh", true, 0, uid, gid, CONFDB_FILE,
CONFDB_SSH_CONF_ENTRY, &main_ctx, true);
if (ret != EOK) {
return 2;
Expand Down
4 changes: 2 additions & 2 deletions src/responder/sudo/sudosrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ int main(int argc, const char *argv[])
}
}

ret = server_setup("sudo", true, 0, uid, gid, CONFDB_SUDO_CONF_ENTRY,
&main_ctx, true);
ret = server_setup("sudo", true, 0, uid, gid, CONFDB_FILE,
CONFDB_SUDO_CONF_ENTRY, &main_ctx, true);
if (ret != EOK) {
return 2;
}
Expand Down
8 changes: 4 additions & 4 deletions src/tests/cwrap/test_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void test_run_as_root_fg(void **state)

pid = fork();
if (pid == 0) {
ret = server_setup(__FUNCTION__, false, 0, 0, 0,
ret = server_setup(__FUNCTION__, false, 0, 0, 0, CONFDB_FILE,
__FUNCTION__, &main_ctx, true);
assert_int_equal(ret, 0);
exit(0);
Expand All @@ -125,7 +125,7 @@ void test_run_as_sssd_fg(void **state)
pid = fork();
if (pid == 0) {
ret = server_setup(__FUNCTION__, false, 0, sssd->pw_uid, sssd->pw_gid,
__FUNCTION__, &main_ctx, true);
CONFDB_FILE, __FUNCTION__, &main_ctx, true);
assert_int_equal(ret, 0);
exit(0);
}
Expand All @@ -149,8 +149,8 @@ void test_run_as_root_daemon(void **state)

pid = fork();
if (pid == 0) {
ret = server_setup(__FUNCTION__, false, FLAGS_PID_FILE,
0, 0, __FUNCTION__, &main_ctx, true);
ret = server_setup(__FUNCTION__, false, FLAGS_PID_FILE, 0, 0,
CONFDB_FILE, __FUNCTION__, &main_ctx, true);
assert_int_equal(ret, 0);

server_loop(main_ctx);
Expand Down
4 changes: 2 additions & 2 deletions src/util/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ static const char *get_pid_path(void)
int server_setup(const char *name, bool is_responder,
int flags,
uid_t uid, gid_t gid,
const char *db_file,
const char *conf_entry,
struct main_context **main_ctx,
bool allow_sss_loop)
Expand Down Expand Up @@ -622,8 +623,7 @@ int server_setup(const char *name, bool is_responder,
return EIO;
}

conf_db = talloc_asprintf(ctx, "%s/%s",
get_db_path(), CONFDB_FILE);
conf_db = talloc_asprintf(ctx, "%s/%s", get_db_path(), db_file);
if (conf_db == NULL) {
DEBUG(SSSDBG_FATAL_FAILURE, "Out of memory, aborting!\n");
return ENOMEM;
Expand Down
1 change: 1 addition & 0 deletions src/util/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ int pidfile(const char *file);
int server_setup(const char *name, bool is_responder,
int flags,
uid_t uid, gid_t gid,
const char *db_file,
const char *conf_entry,
struct main_context **main_ctx,
bool allow_sss_loop);
Expand Down

0 comments on commit 6e7d9db

Please sign in to comment.