summaryrefslogtreecommitdiff
path: root/src/openvpn/pf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvpn/pf.c')
-rw-r--r--src/openvpn/pf.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/src/openvpn/pf.c b/src/openvpn/pf.c
index 7277ae6..3645631 100644
--- a/src/openvpn/pf.c
+++ b/src/openvpn/pf.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2018 OpenVPN Inc <sales@openvpn.net>
+ * Copyright (C) 2002-2021 OpenVPN Inc <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -35,9 +35,9 @@
#include "init.h"
#include "memdbg.h"
+#include "pf.h"
#include "ssl_verify.h"
-#include "pf-inline.h"
static void
pf_destroy(struct pf_set *pfs)
@@ -547,9 +547,7 @@ pf_check_reload(struct context *c)
const int wakeup_transition = 60;
bool reloaded = false;
- if (c->c2.pf.enabled
- && c->c2.pf.filename
- && event_timeout_trigger(&c->c2.pf.reload, &c->c2.timeval, ETT_DEFAULT))
+ if (c->c2.pf.filename)
{
platform_stat_t s;
if (!platform_stat(c->c2.pf.filename, &s))
@@ -618,19 +616,18 @@ pf_load_from_buffer_list(struct context *c, const struct buffer_list *config)
void
pf_init_context(struct context *c)
{
- struct gc_arena gc = gc_new();
#ifdef PLUGIN_PF
if (plugin_defined(c->plugins, OPENVPN_PLUGIN_ENABLE_PF))
{
- const char *pf_file = create_temp_file(c->options.tmp_dir, "pf", &gc);
- if (pf_file)
+ c->c2.pf.filename = platform_create_temp_file(c->options.tmp_dir, "pf",
+ &c->c2.gc);
+ if (c->c2.pf.filename)
{
- setenv_str(c->c2.es, "pf_file", pf_file);
+ setenv_str(c->c2.es, "pf_file", c->c2.pf.filename);
if (plugin_call(c->plugins, OPENVPN_PLUGIN_ENABLE_PF, NULL, NULL, c->c2.es) == OPENVPN_PLUGIN_FUNC_SUCCESS)
{
event_timeout_init(&c->c2.pf.reload, 1, now);
- c->c2.pf.filename = string_alloc(pf_file, &c->c2.gc);
c->c2.pf.enabled = true;
#ifdef ENABLE_DEBUG
if (check_debug_level(D_PF_DEBUG))
@@ -639,10 +636,21 @@ pf_init_context(struct context *c)
}
#endif
}
- else
- {
- msg(M_WARN, "WARNING: OPENVPN_PLUGIN_ENABLE_PF disabled");
- }
+ }
+ if (!c->c2.pf.enabled)
+ {
+ /* At some point in openvpn history, this code just printed a
+ * warning and signalled itself (SIGUSR1, "plugin-pf-init-failed")
+ * to terminate the client instance. This got broken at one of
+ * the client auth state refactorings (leading to SIGSEGV crashes)
+ * and due to "pf will be removed anyway" reasons the easiest way
+ * to prevent crashes is to REQUIRE that plugins succeed - so if
+ * the plugin fails, we cleanly abort OpenVPN
+ *
+ * see also: https://community.openvpn.net/openvpn/ticket/1377
+ */
+ msg(M_FATAL, "FATAL: failed to init PF plugin, must succeed.");
+ return;
}
}
#endif /* ifdef PLUGIN_PF */
@@ -658,7 +666,6 @@ pf_init_context(struct context *c)
#endif
}
#endif
- gc_free(&gc);
}
void