From d74a754310b4b44ded71ba8f8bd91af0ded6d9b7 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: May 30 2018 22:03:33 +0000 Subject: MONITOR: Do not use two configuration databases confdb was initialized twice in monitor. The 1st time in load_configuration and the 2nd time in server_setup. libldb-1.4.0 contains stricter checking of PID which created db. ldb_tdb: Prevent ldb_tdb reuse after a fork() We may relax this restriction in the future, but for now do not assume that the caller has done a tdb_reopen_all() at the right time. Signed-off-by: Andrew Bartlett It did not cause any problem when sssd was stared in interactive mode (used by systemd) But it cause failures in daemon mode which is used in cwrap integration [sssd] [ldb] (0x4000): Destroying timer event 0x5555557b1d30 "ltdb_timeout" [sssd] [ldb] (0x4000): Ending timer event 0x5555557cbdd0 "ltdb_callback" [sssd] [server_setup] (0x0400): CONFDB: /var/lib/sss/db/config.ldb [sssd] [ldb] (0x0010): Failed to unlock db: ../ldb_tdb/ldb_tdb.c:147: Reusing ldb opend by pid 28889 in process 28893 / Protocol error [sssd] [confdb_get_param] (0x0020): Failed to get [krb5_rcache_dir] from [config/sssd], error [5] (Input/output error) [sssd] [confdb_get_string] (0x0020): Failed to get [krb5_rcache_dir] from [config/sssd], error [5] (Input/output error) Merges: https://pagure.io/SSSD/sssd/pull-request/3751 --- diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c index a080870..ca5c799 100644 --- a/src/monitor/monitor.c +++ b/src/monitor/monitor.c @@ -2663,6 +2663,20 @@ int main(int argc, const char *argv[]) monitor->conf_path, &main_ctx); if (ret != EOK) return 2; + /* Use confd initialized in server_setup. ldb_tdb module (1.4.0) check PID + * of process which initialized db for locking purposes. + * Failed to unlock db: ../ldb_tdb/ldb_tdb.c:147: + * Reusing ldb opened by pid 28889 in process 28893 + */ + talloc_zfree(monitor->cdb); + monitor->cdb = main_ctx->confdb_ctx; + + ret = confdb_get_domains(monitor->cdb, &monitor->domains); + if (ret != EOK) { + DEBUG(SSSDBG_FATAL_FAILURE, "No domains configured.\n"); + return 4; + } + monitor->is_daemon = !opt_interactive; monitor->parent_pid = main_ctx->parent_pid; monitor->ev = main_ctx->event_ctx;