This will enable a vpnc-script to more easily identify which VPN connection
is calling it, in the case of multiple concurrent or "stacked" VPN
connections.
Because OpenConnect (and vpnc) invoke the vpnc-script via an intermediate
shell process, the vpnc-script would otherwise need to determine its
GRANDparent PID, which is an error-prone, and not easily portable, process.
See https://gitlab.com/openconnect/vpnc-scripts/-/issues/28 and
https://gitlab.com/openconnect/vpnc-scripts/-/merge_requests/36 for issues
with the current approaches.
Signed-off-by: Daniel Lenski <dlenski@gmail.com>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
-#ifndef _WIN32
+#ifdef _WIN32
+#include <process.h>
+#define getpid _getpid
+#else
#include <sys/wait.h>
#endif
script_setenv(vpninfo, "CISCO_SPLIT_EXC", NULL, 0, 0);
script_setenv_int(vpninfo, "INTERNAL_IP4_MTU", vpninfo->ip_info.mtu);
+ script_setenv_int(vpninfo, "VPNPID", (int)getpid());
if (vpninfo->idle_timeout)
script_setenv_int(vpninfo, "IDLE_TIMEOUT", vpninfo->idle_timeout);