Default route is not restored
The change 01d3b8c0, which was supposed to support "stacked VPNs", in fact broke restoration of the default route, at least on my system (Debian testing, OpenConnect version v8.10-2+b1), which was working fine for years without any changes until a recent upgrade of the openconnect and vpnc-scripts packages.
To debug what's going on, I've added the following lines to the top of the /usr/share/vpnc-scripts/vpnc-script file:
echo PPID = ${PPID}
pstree -Tp
So when starting OpenConnect in background, I see something like this (trimmed for clarity):
$ sudo openconnect -b ...
...
Continuing in background; pid 29997
...
PPID = 29999
systemd(1)─┬─cron(613)
...
├─openconnect(29997)───sh(29999)───vpnc-script(30000)───pstree(30001)
...
PPID = 30014
systemd(1)─┬─cron(613)
...
├─openconnect(29997)───sh(30014)───vpnc-script(30015)───pstree(30017)
...
As can be seen, vpnc-script is executed twice, and the second time it creates the /var/run/vpnc/defaultroute.30014 file, but the problem is that this PPID variable value, instead of the openconnect PID, is the PID of some intermediate sh, which changes on every execution of vpnc-script.
Then, when stopping OpenConnect in background, I see something like this:
$ sudo killall -SIGINT openconnect
Send BYE packet: Aborted by caller
PPID = 30617
systemd(1)─┬─cron(613)
...
├─openconnect(29997)───sh(30617)───vpnc-script(30619)───pstree(30620)
...
The script is executed once, and of course, the default route is not restored, neither the file defaultroute.30014 is deleted, because the new PPID value doesn't match the previous one.
Is this a Debian problem, or I'm doing something wrong? Or OpenConnect calls vpnc-script not how it's supposed to be done? (And why?)