diff options
Diffstat (limited to 'src/openvpn/openvpn.c')
-rw-r--r-- | src/openvpn/openvpn.c | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/src/openvpn/openvpn.c b/src/openvpn/openvpn.c index 3d244fc..857c5fa 100644 --- a/src/openvpn/openvpn.c +++ b/src/openvpn/openvpn.c @@ -37,8 +37,6 @@ #include "memdbg.h" -#include "forward-inline.h" - #define P2P_CHECK_SIG() EVENT_LOOP_CHECK_SIGNAL(c, process_signal_p2p, c); static bool @@ -48,28 +46,6 @@ process_signal_p2p(struct context *c) return process_signal(c); } -/* Write our PID to a file */ -static void -write_pid(const char *filename) -{ - if (filename) - { - unsigned int pid = 0; - FILE *fp = platform_fopen(filename, "w"); - if (!fp) - { - msg(M_ERR, "Open error on pid file %s", filename); - } - - pid = platform_getpid(); - fprintf(fp, "%u\n", pid); - if (fclose(fp)) - { - msg(M_ERR, "Close error on pid file %s", filename); - } - } -} - /**************************************************************************/ /** @@ -217,6 +193,8 @@ openvpn_main(int argc, char *argv[]) open_plugins(&c, true, OPENVPN_PLUGIN_INIT_PRE_CONFIG_PARSE); #endif + net_ctx_init(&c, &c.net_ctx); + /* init verbosity and mute levels */ init_verb_mute(&c, IVM_LEVEL_1); @@ -236,7 +214,7 @@ openvpn_main(int argc, char *argv[]) } /* tun/tap persist command? */ - if (do_persist_tuntap(&c.options)) + if (do_persist_tuntap(&c.options, &c.net_ctx)) { break; } @@ -274,7 +252,7 @@ openvpn_main(int argc, char *argv[]) if (c.first_time) { c.did_we_daemonize = possibly_become_daemon(&c.options); - write_pid(c.options.writepid); + write_pid_file(c.options.writepid, c.options.chroot_dir); } #ifdef ENABLE_MANAGEMENT @@ -305,12 +283,10 @@ openvpn_main(int argc, char *argv[]) tunnel_point_to_point(&c); break; -#if P2MP_SERVER case MODE_SERVER: tunnel_server(&c); break; -#endif default: ASSERT(0); } @@ -332,6 +308,7 @@ openvpn_main(int argc, char *argv[]) env_set_destroy(c.es); uninit_options(&c.options); gc_reset(&c.gc); + net_ctx_free(&c.net_ctx); } while (c.sig->signal_received == SIGHUP); } |