On Wednesday 18 May 2005 09:40, Simon Perreault wrote: > 1) reopen stdin, stdout and stderr to /dev/null when --daemon option is > specified (need a way to access options structure in the plugin)
Here's a patch using the first solution. Please consider applying.
Index: options.c =================================================================== RCS file: /cvsroot/openvpn/openvpn/options.c,v retrieving revision 1.62 diff -u -p -r1.62 options.c --- options.c 18 May 2005 08:21:54 -0000 1.62 +++ options.c 18 May 2005 14:55:28 -0000 @@ -622,6 +622,7 @@ setenv_settings (struct env_set *es, con setenv_str (es, "local", o->local); setenv_int (es, "local_port", o->local_port); setenv_int (es, "verb", o->verbosity); + setenv_int (es, "daemon", o->daemon); if (o->remote_list) { Index: plugin/auth-pam/auth-pam.c =================================================================== RCS file: /cvsroot/openvpn/openvpn/plugin/auth-pam/auth-pam.c,v retrieving revision 1.5 diff -u -p -r1.5 auth-pam.c --- plugin/auth-pam/auth-pam.c 30 Apr 2005 22:21:16 -0000 1.5 +++ plugin/auth-pam/auth-pam.c 18 May 2005 14:55:28 -0000 @@ -373,6 +373,16 @@ openvpn_plugin_open_v1 (unsigned int *ty /* Ignore most signals (the parent will receive them) */ set_signals (); + /* + * Daemonize if --daemon option is set. + */ + { + const char *daemon_string = get_env ("daemon", envp); + if (daemon_string && daemon_string[0] == '1') + if (daemon (0, 0) < 0) + perror ("AUTH-PAM: daemonization failed"); + } + /* execute the event loop */ pam_server (fd[1], argv[1], context->verb, &name_value_list);