Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
From faa6cadd30cbd459cf8c51bfe197af78f6bf9f95 Mon Sep 17 00:00:00 2001
From: Arne Schwabe <arne@openvpn.net>
Date: Wed, 6 Feb 2019 15:22:34 +0100
Subject: [PATCH] Fix management tunnel argument
When the conversion to the new getaddrinfo happened I forgot to add the
port to the getaddrinfo call here. Remember that port to fix binding to
a random port.
---
src/openvpn/manage.c | 13 ++++++++++---
src/openvpn/manage.h | 1 +
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c
index 62d4bc7b..97984213 100644
--- a/src/openvpn/manage.c
+++ b/src/openvpn/manage.c
@@ -2428,6 +2428,7 @@ man_settings_init(struct man_settings *ms,
if (streq(addr, "tunnel") && !(flags & MF_CONNECT_AS_CLIENT))
{
ms->management_over_tunnel = true;
+ ms->management_over_tunnel_port = port;
}
else
{
@@ -2962,9 +2963,15 @@ management_post_tunnel_open(struct management *man, const in_addr_t tun_local_ip
int ret;
ia.s_addr = htonl(tun_local_ip);
- ret = openvpn_getaddrinfo(GETADDR_PASSIVE, inet_ntoa(ia), NULL, 0, NULL,
- AF_INET, &man->settings.local);
- ASSERT(ret==0);
+ ret = openvpn_getaddrinfo(GETADDR_PASSIVE, inet_ntoa(ia),
+ man->settings.management_over_tunnel_port, 0,
+ NULL, AF_INET, &man->settings.local);
+
+ if (ret != 0)
+ {
+ msg(M_FATAL, "Cannot resolve %s:%s for binding management interface",
+ inet_ntoa(ia), np(man->settings.management_over_tunnel_port));
+ }
man_connection_init(man);
}
diff --git a/src/openvpn/manage.h b/src/openvpn/manage.h
index 4bfcfdbe..a93ccd2b 100644
--- a/src/openvpn/manage.h
+++ b/src/openvpn/manage.h
@@ -229,6 +229,7 @@ struct man_settings {
struct sockaddr_un local_unix;
#endif
bool management_over_tunnel;
+ const char* management_over_tunnel_port;
struct user_pass up;
int log_history_cache;
int echo_buffer_size;
--
2.20.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.