Opened 3 years ago

Closed 3 years ago

#1376 closed Bug / Defect (fixed)

Error - "There already exist a config file ... " OpenVPN GUI when upgrading to 2.5 on Win10 x64

Reported by: Namsnob Owned by: Selva Nair
Priority: major Milestone: release 2.5.2
Component: Windows GUI Version: OpenVPN 2.5.0 (Community Ed)
Severity: Not set (select this one, unless your'e a OpenVPN developer) Keywords:
Cc: Selva Nair

Description

Hello together,

after updating servers and clients from OVPN 2.4.x to 2.5 via Windows MSI Installer, the GUI on startup always showed the Message Box Error - "There already exists a config file named xxxx.ovpn. You cannot have multiple config files with the...... " (resp. the German equivalent).

This is a bit annoying as this prevents OpenVPN startup without user intervention (and promptly, this had cut off our OVPN server access after an unattended windows update due to OpenVPN GUI "hang" after the reboot).

After some research, I found the following elder ticket which seem to have put me on the right track

https://community.openvpn.net/openvpn/ticket/1175

After comparing the Open VPN GUI setting in the preferences and the corresponding registry "HKLM\Software\OpenVPN\config_dir" entry, I found that there is indeed a slight difference, as the GUI preference has trailing "\", while the registry has not, i.e. Gui setting "C:\Program Files\OpenVPN\config\ <-!!" and the registry "C:\Program Files\OpenVPN\config" (although I have not changed one.

The OpenVPN GUI seems to consider that (obviously errorneously) as different paths and so the duplicate warning for one and the same ovpn file.

Of course, I could workaround that by adding the trailing "\" in the GUI preference setting.

But this seems to be an easy resolvable bug.

Hope that helps,

Best regards,
Joachim

Change History (6)

comment:1 Changed 3 years ago by Gert Döring

Cc: Selva Nair added
Milestone: release 2.5

I wonder how these paths came into existance in the first place...

But anyway. @selva: is there something like a "realpath(3)" for windows, which would take a path name and canonicalize it - de-duplicate double backslashes, canonicalize "path/../" elements, chop off trailing "/", so comparison is more likely to recognize duplicates?

(Note: path examples written with "/" as trac hates backslashes)

Last edited 3 years ago by Gert Döring (previous) (diff)

comment:2 Changed 3 years ago by Selva Nair

See #1359

After comparing the Open VPN GUI setting in the preferences and the corresponding registry "HKLM\Software\OpenVPN\config_dir" entry, I found that there is indeed a slight difference, as the GUI preference has trailing "\", while the registry has not, i.e. Gui setting "C:\Program Files\OpenVPN\config\ <-!!" and the registry "C:\Program Files\OpenVPN\config" (although I have not changed one.

The default value of local config directory in the GUI preferences is something like C:\Users\username\OpenVPN\config, not meant to be the same as the global location. The user must have changed it to C:\Program Files\OpenVPN\config\ which is the same as the global config directory.

We do a very basic check to skip the latter if "identical" to the former, but using the same value for these two locations serves no purpose. The GUI scans both the global location defined in the HKLM\...\config_dir and the user's private location defined in GUI preferences. Just leave the preferences at the default even if the user has no private configs. See also https://community.openvpn.net/openvpn/ticket/1359#comment:4.

@gert: We could use PathCanonicalize() which handles .\, ..\ etc. but may not help with detecting cases like \\?\C:\ and \\.\C:\ are the same as C:\ or drive described by volume GUID should match one with corresponding drive letter etc.

Anyway, I'll replace the strcmp() by something smarter to cover common cases.

comment:3 Changed 3 years ago by Gert Döring

This has been merged into the GUI via the github PR

https://github.com/OpenVPN/openvpn-gui/pull/405

and is part of the OpenVPN 2.5.1 release. Thanks, Selva.

So, I think this trac ticket can now be closed (as well as #1359)

comment:4 Changed 3 years ago by digdug3

Bug is still there. It's because of a left-over of an old OpenVPN-GUI registry entry.
This causes OpenVPN to look twice in the same folder. Removing the HKEY_CURRENT_USER registry entry fixes this.

HKEY_CURRENT_USER\SOFTWARE\OpenVPN-GUI
HKEY_LOCAL_MACHINE\SOFTWARE\OpenVPN-GUI

comment:5 in reply to:  4 Changed 3 years ago by Selva Nair

Replying to digdug3:

Bug is still there. It's because of a left-over of an old OpenVPN-GUI registry entry.
This causes OpenVPN to look twice in the same folder. Removing the HKEY_CURRENT_USER registry entry fixes this.

HKEY_CURRENT_USER\SOFTWARE\OpenVPN-GUI
HKEY_LOCAL_MACHINE\SOFTWARE\OpenVPN-GUI

Sorry, I fail to follow. The GUI needs the HKCU entry for its operation and it doesn't read that HKLM key that you mention. The only required HKLM key is HKLM\SOFTWARE\OpenVPN. If you delete GUI's HKCU key, it will get recreated when the GUI is restarted.

On deleting the HKCU key all that happens is user-specific settings get reverted to defaults. By default the GUI reads configs from %USERPROFILE%\OpenPVN\config and the location specified in HKLM\Software\OPENVPN\config_dir.

If those two entries do not exactly match but somehow effectively point to same location, pre 2.5.1 will show duplicate warning. 2.5.1+ tries to avoid this by a more thorough check of whether the two locations point to the same directory in the file system.

comment:6 Changed 3 years ago by Gert Döring

Milestone: release 2.5.2
Resolution: fixed
Status: newclosed

I consider this fixed, with the improved "directory duplication check"

Note: See TracTickets for help on using tickets.