summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2009-03-06 19:28:24 -0500
committerStephen Gallagher <sgallagh@redhat.com>2009-03-07 09:06:49 -0500
commitecb8965f030eeb0cadf18394bccf8e760831e400 (patch)
tree4883be600468a2435a7447ce3d0dc9073b653ae2 /server
parent4042b9855a353a5d0727e69ae8957cc7f7e7e9bb (diff)
downloadsssd-ecb8965f030eeb0cadf18394bccf8e760831e400.tar.gz
sssd-ecb8965f030eeb0cadf18394bccf8e760831e400.tar.xz
sssd-ecb8965f030eeb0cadf18394bccf8e760831e400.zip
Fix race condition with initial sysdb creation
When the sysdb LDB file does not exist on the system, the first attempt to connect to it will invoke a creation routine. However, both the NSS and the InfoPipe are started in parallel by the monitor, resulting in a race condition as they both try to initialize the sysdb. The easiest fix for this is to simply have the monitor create the sysdb before it launches NSS and InfoPipe.
Diffstat (limited to 'server')
-rw-r--r--server/monitor/monitor.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/server/monitor/monitor.c b/server/monitor/monitor.c
index 3c393c97d..d797ae0e2 100644
--- a/server/monitor/monitor.c
+++ b/server/monitor/monitor.c
@@ -28,6 +28,7 @@
#include "popt.h"
#include "tevent.h"
#include "confdb/confdb.h"
+#include "db/sysdb.h"
#include "monitor/monitor.h"
#include "dbus/dbus.h"
#include "sbus/sssd_dbus.h"
@@ -365,6 +366,7 @@ int monitor_process_init(TALLOC_CTX *mem_ctx,
{
struct mt_ctx *ctx;
struct mt_svc *svc;
+ struct sysdb_ctx *sysdb;
const char **doms;
int dom_count;
char *path;
@@ -382,6 +384,18 @@ int monitor_process_init(TALLOC_CTX *mem_ctx,
if (ret != EOK)
return ret;
+ /* Avoid a startup race condition between InfoPipe
+ * and NSS. If the sysdb doesn't exist yet, both
+ * will try to create it at the same time. So
+ * we'll have the monitor create it before either of
+ * those processes start.
+ */
+ ret = sysdb_init(mem_ctx, ctx->ev, ctx->cdb,
+ NULL, &sysdb);
+ if (ret != EOK)
+ return ret;
+ talloc_free(sysdb);
+
/* Initialize D-BUS Server
* The monitor will act as a D-BUS server for all
* SSSD processes */