summaryrefslogtreecommitdiffstats
path: root/plugin/eurephia-auth.c
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2010-11-26 22:05:28 +0100
committerDavid Sommerseth <dazo@users.sourceforge.net>2010-11-26 22:05:28 +0100
commit525d75316848f79208101e48a54e21396464c98b (patch)
tree9475b2a3821d317a55ad118903839fed163e10d7 /plugin/eurephia-auth.c
parent5581ba10af35b94e750596312a9782255084aaeb (diff)
downloadeurephia-525d75316848f79208101e48a54e21396464c98b.tar.gz
eurephia-525d75316848f79208101e48a54e21396464c98b.tar.xz
eurephia-525d75316848f79208101e48a54e21396464c98b.zip
Move daemonize() code to be called in the firewall child thread only
The eurephia plug-in would daemonize the OpenVPN process by calling daemonize() too early. This patch renames daemoinze() to efw_daemonize() and calls it only in the firewall child process. Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>
Diffstat (limited to 'plugin/eurephia-auth.c')
-rw-r--r--plugin/eurephia-auth.c31
1 files changed, 1 insertions, 30 deletions
diff --git a/plugin/eurephia-auth.c b/plugin/eurephia-auth.c
index 3e9ff6d..03bf674 100644
--- a/plugin/eurephia-auth.c
+++ b/plugin/eurephia-auth.c
@@ -102,33 +102,6 @@ static void dump_env(FILE *f, const char *prefix, const char *envp[]) {
#endif // ENABLE_DEBUG
-/**
- * daemonize if "daemon" environment variable is set.
- * preserves stderr access after being daemonized, but
- * only if "daemon_log_direct" environment variable is set.
- *
- * @param envp openvpn environmental table
- */
-static void daemonize(const char *envp[])
-{
- char *daemon_string = GETENV_DAEMON(envp);
- if( daemon_string && daemon_string[0] == '1' ) {
- char *log_redirect = GETENV_DAEMONLOGREDIR(envp);
- int fd = -1;
- if( log_redirect && log_redirect[0] == '1' ) {
- fd = dup (2);
- }
- if( daemon(0, 0) < 0 ) {
- fprintf(stderr, "eurephia-auth: daemonization failed\n");
- } else if( fd >= 3 ) {
- dup2(fd, 2);
- close(fd);
- }
- free_nullsafe(NULL, log_redirect);
- }
- free_nullsafe(NULL, daemon_string);
-}
-
/**
* Prepares a eurephiaCTX (context) for the openvpn process and tells openvpn which hooks eurephia
@@ -158,9 +131,7 @@ OPENVPN_EXPORT openvpn_plugin_handle_t openvpn_plugin_open_v1(unsigned int *type
| OPENVPN_PLUGIN_MASK(OPENVPN_PLUGIN_LEARN_ADDRESS);
// Setup a eurephia context
- context = eurephiaInit(argv);
- // Daemonize if requested
- daemonize(envp);
+ context = eurephiaInit(argv, envp);
return (openvpn_plugin_handle_t) context;
}