summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2012-01-09 01:44:32 +0100
committerDavid Sommerseth <dazo@users.sourceforge.net>2013-06-13 01:01:55 +0200
commita2b54da7ebec0883fcc812ae86033a6d5fa36c5d (patch)
tree61b03d39c2de60c967fc2d34a000b26a14a4c710
parent52497ab789ce706d6c726d347dfc8af7bedfee89 (diff)
downloadeurephia-a2b54da7ebec0883fcc812ae86033a6d5fa36c5d.tar.gz
eurephia-a2b54da7ebec0883fcc812ae86033a6d5fa36c5d.tar.xz
eurephia-a2b54da7ebec0883fcc812ae86033a6d5fa36c5d.zip
Add eDBdisconnect_firewall() database driver function
If this function is found declared in the database driver, it will be used instead of eDBdisconnect() when forking the firewall thread. This is to avoid disconnecting some databases in the wrong way. This new function is fully optional to implement if the database driver works fine with calling eDBdisconnect(). Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>
-rw-r--r--database/eurephiadb.c3
-rw-r--r--database/eurephiadb_driver.h10
-rw-r--r--plugin/firewall/eurephiafw.c6
3 files changed, 18 insertions, 1 deletions
diff --git a/database/eurephiadb.c b/database/eurephiadb.c
index 3b1c751..30e790e 100644
--- a/database/eurephiadb.c
+++ b/database/eurephiadb.c
@@ -148,6 +148,9 @@ int eDBlink_init(eurephiaCTX *ctx, const char *dbdriver, const int minver)
eDBconnect = eGetSym(ctx, ctx->eurephia_driver, "eDBconnect");
eDBdisconnect = eGetSym(ctx, ctx->eurephia_driver, "eDBdisconnect");
+ /* This is allowed not to be present in all drivers */
+ eDBdisconnect_firewall = dlsym(ctx->eurephia_driver, "eDBdisconnect_firewall");
+
eDBauth_TLS = eGetSym(ctx, ctx->eurephia_driver, "eDBauth_TLS");
eDBauth_user = eGetSym(ctx, ctx->eurephia_driver, "eDBauth_user");
diff --git a/database/eurephiadb_driver.h b/database/eurephiadb_driver.h
index b7154ea..7a99a78 100644
--- a/database/eurephiadb_driver.h
+++ b/database/eurephiadb_driver.h
@@ -116,6 +116,16 @@ int EUREPHIA_DRIVERAPI_FUNC(eDBconnect)(eurephiaCTX *ctx, const int argc, const
void EUREPHIA_DRIVERAPI_FUNC(eDBdisconnect) (eurephiaCTX *ctx);
/**
+ * Disconnects the eurephia firewall thread from the inherited database connection.
+ * If this function is found in the driver, it will be called instead of eDBdisconnect()
+ *
+ * @version API version level 1
+ * @param ctx eurephiaCTX - context with the database connection to disconnect from.
+ *
+ */
+void EUREPHIA_DRIVERAPI_FUNC(eDBdisconnect_firewall) (eurephiaCTX *ctx);
+
+/**
* Authenticates a certificate against the database.
*
* @version API version level 1
diff --git a/plugin/firewall/eurephiafw.c b/plugin/firewall/eurephiafw.c
index d74a383..51661d6 100644
--- a/plugin/firewall/eurephiafw.c
+++ b/plugin/firewall/eurephiafw.c
@@ -254,7 +254,11 @@ void eFW_StartFirewall(eurephiaCTX *ctx, const int daemon, const int logredir) {
if( daemon ) {
efw_daemonize(ctx, logredir);
}
- eDBdisconnect(ctx);
+ if( eDBdisconnect_firewall == NULL ) {
+ eDBdisconnect(ctx);
+ } else {
+ eDBdisconnect_firewall(ctx);
+ }
eFW_RunFirewall(&(*ctx->fwcfg).thrdata);
exit(-1); // If our child process exits abnormally.