Opened 6 years ago

Last modified 5 years ago

#405 new Bug / Defect

Use --cd in config causes instance to terminate on SIGHUP

Reported by: debbie10t Owned by:
Priority: minor Milestone:
Component: Generic / unclassified Version: OpenVPN 2.3.4 (Community Ed)
Severity: Not set (select this one, unless your'e a OpenVPN developer) Keywords:
Cc:

Description

Use of --cd to change the directory in a config file causes the OpenVPN process to terminate as the process can no longer find the config file when SIGHUP is issued.

Even if all files referenced in the config file are absolute paths the process expect to find the current running config in the current directory, which it is not due to the use of --cd

Proposed behaviour to solve this issue:
Have the code for --cd store the current directory at loading the config file and restore this directory on SIGHUP, in a similar manner as PUSHD / POPD.

Change History (4)

comment:1 Changed 6 years ago by Samuli Seppänen

I was able to reproduce this bug, but only if "cd" is added to the config file instead of to the command-line (--cd).

So this approach _does_ work (tested on Ubuntu 14.04 and Windows 7):

$ cd ~
$ openvpn --cd /etc/openvpn --config test.conf
$ kill -s 1 <openvpn-pid>

However, if I have this in my config a SIGHUP will break the connection:

cd /etc/openvpn/405
ca test-ca.crt

In this case test-ca.crt is located in /etc/openvpn/405/test-ca.crt.

comment:2 Changed 5 years ago by David Sommerseth

Does your configuration/init script make use of --daemon? If so, then the behaviour is kind of expected. During the forking and daemonizing, openvpn will do a 'cd /'. Another trap can be if --chroot is used as well.

comment:3 Changed 5 years ago by Samuli Seppänen

Is this something we can/should fix in the code, or just document on the man-page?

comment:4 Changed 5 years ago by debbie10t

I do use --daemon in my setup as it is defined in the archlinux unit files.

Is it possible to have the --cd respected by --daemon perhaps by order of execution ?

(I understand --chroot is more complex so I do not include it in this ticket)

Note: See TracTickets for help on using tickets.