From a0750b18588db1867364fb3ff64faca60bdcc0a4 Mon Sep 17 00:00:00 2001 From: Tollef Fog Heen Date: Wed, 21 Oct 2009 17:19:43 +0200 Subject: [PATCH] Move db connection later Do as little as possible while we are still running as root. This also makes ident connections work. --- src/main.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main.c b/src/main.c index d21c60f..43bd7c3 100644 --- a/src/main.c +++ b/src/main.c @@ -575,12 +575,6 @@ int main(int argc, char ** argv) /* XXX return value */ parse_config(config, &conf); - db_conn = PQconnectdb(conf.dbdef); - if (PQstatus(db_conn) != CONNECTION_OK) { - syslog(LOG_ERR, "connection to database failed: %s", - PQerrorMessage(db_conn)); - exit(1); - } d = MHD_start_daemon(MHD_USE_DEBUG, conf.port, NULL, /* Access policy handler */ @@ -604,6 +598,13 @@ int main(int argc, char ** argv) exit(1); } + db_conn = PQconnectdb(conf.dbdef); + if (PQstatus(db_conn) != CONNECTION_OK) { + syslog(LOG_ERR, "connection to database failed: %s", + PQerrorMessage(db_conn)); + exit(1); + } + if (!foreground) daemon(0, 0); -- 2.39.5