Small hack for OpenVPN-2.0beta11: tun + tcp + inetd + nowait
Hello,
here is a small patch, that allows a tun/tcp/inetd/nowait-configuration style. Some inconveniances are still to be addressed:
o ifconfig and route cannot be returned by the client-connect-script but have to be set right there
o the visible name of the interface cannot be changed in accordance with the connecting client (i.e. 'vpn-cust0' instead of 'tun123')
o ifconfig-pools and concurrent connections of the same clients cannot be handeled from openvpn by itself
On the other hand it gives me different processes and different interfaces for every conneced client so they can be managed (i.e. killed :-)) separately.
This patch is just a first approach and not fully tested (as most software ;-)).
Excerpt from the config-file:
dev tun
inetd nowait
proto tcp-server
mode server
Regards,
Christian Lademann
PS.: All submissions and contributions to open-source-projects are released
under the same license as the respective project.
mtcp.c +14 -0
@@ -501,9 +501,23 @@*/ if (touched &&IS_SIG (&touched->context)) { +int exit_after_close =0 ; + +if (touched->context.c2.link_socket->inetd ==INETD_NOWAIT ) + { + exit_after_close =1 ; + } +if (mi == touched) mi =NULL ;multi_close_instance (m, touched, false); + +/* +* If this socket results from an inetd-nowait - connection +* it has to be the only one and we have to exit. +*/ +if (exit_after_close) + m->top.sig->signal_received =SIGTERM ; } }
options.c +4 -0
@@ -1017,15 +1017,19 @@ )msg (M_USAGE ,"Options error: --inetd nowait can only be used in TLS mode" ); +/* if (options->inetd == INETD_NOWAIT && dev != DEV_TYPE_TAP) msg (M_USAGE, "Options error: --inetd nowait only makes sense in --dev tap mode"); +*/ /* * In forking TCP server mode, you don't need to ifconfig * the tap device (the assumption is that it will be bridged). */ +/* if (options->inetd == INETD_NOWAIT) options->ifconfig_noexec = true; +*/ /* * Sanity check on TCP mode options
socket.c +2 -0
@@ -844,7 +844,9 @@ {ASSERT (accept_from);ASSERT (sock->info.proto == PROTO_TCPv4_SERVER); +/* ASSERT (!sock->inetd); +*/ sock->sd = accept_from->sd; }