OpenVPN / openvpn3-linux

OpenVPN 3 Linux client
GNU Affero General Public License v3.0
563 stars 151 forks source link

Error: openvpn3-autoload: error: argument --key: No such file or directory (If the file name contains spaces) #31

Closed Jiw0cha closed 2 years ago

Jiw0cha commented 3 years ago

Hi. Step to reproduce: add to file name space: 'ovpn config.key' Edit the config file: key '/etc/openvpn/client/ovpn config.key' or key "/etc/openvpn/client/ovpn config.key"

Run: openvpn3-autoload --directory ... And get error: Error: openvpn3-autoload: error: argument --key: No such file or directory ' "/etc/openvpn/client/ovpn config.key" '

And it's enough to get an error to specify in the file path (" ") or (' ')

dsommers commented 3 years ago

Can you please set ("export") this env. variable OPENVPN3_DEBUG=1 and rerun openvpn3-autoload. This should give a better backtrace of the error.

Jiw0cha commented 3 years ago

Can you please set ("export") this env. variable OPENVPN3_DEBUG=1 and rerun openvpn3-autoload. This should give a better backtrace of the error.

It won't work. https://github.com/OpenVPN/openvpn3-linux/blob/master/src/python/openvpn3-autoload#L101 tracebak not use ....

But if you want it that way, everything seems to be obvious, i add line print(traceback.format_exc())

openvpn3-autoload: error: argument --key: No such file or directory ''subdir/NY openvpn_udp-client.key''
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/openvpn3/ConfigParser.py", line 982, in __call__
    fp = open(values[0], 'r')
FileNotFoundError: [Errno 2] No such file or directory: "'subdir/NY openvpn_udp-client.key'"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/python3.7/argparse.py", line 1787, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/usr/lib64/python3.7/argparse.py", line 1993, in _parse_known_args
    start_index = consume_optional(start_index)
  File "/usr/lib64/python3.7/argparse.py", line 1933, in consume_optional
    take_action(action, args, option_string)
  File "/usr/lib64/python3.7/argparse.py", line 1861, in take_action
    action(self, namespace, argument_values, option_string)
  File "/usr/lib/python3.7/site-packages/openvpn3/ConfigParser.py", line 990, in __call__
    raise argparse.ArgumentError(self, err)
argparse.ArgumentError: argument --key: No such file or directory ''subdir/NY openvpn_udp-client.key''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/sbin/openvpn3-autoload", line 90, in find_autoload_configs
    'OpenVPN 3 autoloader')
  File "/usr/lib/python3.7/site-packages/openvpn3/ConfigParser.py", line 89, in __init__
    self.__opts = vars(self.__parser.parse_args(self.__args))
  File "/usr/lib64/python3.7/argparse.py", line 1755, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "/usr/lib64/python3.7/argparse.py", line 1787, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/usr/lib64/python3.7/argparse.py", line 1993, in _parse_known_args
    start_index = consume_optional(start_index)
  File "/usr/lib64/python3.7/argparse.py", line 1933, in consume_optional
    take_action(action, args, option_string)
  File "/usr/lib64/python3.7/argparse.py", line 1861, in take_action
    action(self, namespace, argument_values, option_string)
  File "/usr/lib/python3.7/site-packages/openvpn3/ConfigParser.py", line 840, in __call__
    posix=False)))
  File "/usr/lib64/python3.7/argparse.py", line 1755, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "/usr/lib64/python3.7/argparse.py", line 1794, in parse_known_args
    self.error(str(err))
  File "/usr/lib/python3.7/site-packages/openvpn3/ConfigParser.py", line 64, in error
    raise Exception("%s: error: %s"  % (self.prog, message))
Exception: openvpn3-autoload: error: argument --key: No such file or directory ''subdir/NY openvpn_udp-client.key''
dsommers commented 3 years ago

This should be fixed with commit 2211292cb75f9f124b41afb8545ee6d3caf9ae1e, which will be part of the next release.

dsommers commented 2 years ago

v17_beta has been released now.