mirror of https://github.com/OpenVPN/openvpn-gui
Add backslash to global paths read from HKLM
Signed-off-by: Selva Nair <selva.nair@gmail.com>pull/784/head
parent
08608b2213
commit
7a38f43b38
|
|
@ -72,6 +72,7 @@ target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||||
Cryptui.lib
|
Cryptui.lib
|
||||||
Wininet.lib
|
Wininet.lib
|
||||||
Iphlpapi.lib
|
Iphlpapi.lib
|
||||||
|
Pathcch.lib
|
||||||
Ntdll.lib)
|
Ntdll.lib)
|
||||||
|
|
||||||
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
|
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
@ -154,6 +155,7 @@ target_link_libraries(${PROJECT_NAME_PLAP} PRIVATE
|
||||||
Cryptui.lib
|
Cryptui.lib
|
||||||
Rpcrt4.lib
|
Rpcrt4.lib
|
||||||
Iphlpapi.lib
|
Iphlpapi.lib
|
||||||
|
Pathcch.lib
|
||||||
Ntdll.lib)
|
Ntdll.lib)
|
||||||
|
|
||||||
add_dependencies(${PROJECT_NAME_PLAP} msg_header_gen)
|
add_dependencies(${PROJECT_NAME_PLAP} msg_header_gen)
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,7 @@ openvpn_gui_LDADD = \
|
||||||
-lsecur32 \
|
-lsecur32 \
|
||||||
-lwininet \
|
-lwininet \
|
||||||
-liphlpapi \
|
-liphlpapi \
|
||||||
|
-lpathcch \
|
||||||
-lntdll \
|
-lntdll \
|
||||||
$(JSON_LIBS)
|
$(JSON_LIBS)
|
||||||
|
|
||||||
|
|
|
||||||
3
access.c
3
access.c
|
|
@ -28,7 +28,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <shellapi.h>
|
#include <shlwapi.h>
|
||||||
|
#include <pathcch.h>
|
||||||
#include <lm.h>
|
#include <lm.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <security.h>
|
#include <security.h>
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,7 @@ libopenvpn_plap_la_LIBADD = \
|
||||||
-lgdi32 \
|
-lgdi32 \
|
||||||
-lrpcrt4 \
|
-lrpcrt4 \
|
||||||
-liphlpapi \
|
-liphlpapi \
|
||||||
|
-lpathcch \
|
||||||
-lntdll
|
-lntdll
|
||||||
|
|
||||||
libopenvpn_plap_la_LDFLAGS = -no-undefined -avoid-version -static-libgcc
|
libopenvpn_plap_la_LDFLAGS = -no-undefined -avoid-version -static-libgcc
|
||||||
|
|
|
||||||
31
registry.c
31
registry.c
|
|
@ -28,6 +28,7 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
|
#include <pathcch.h>
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
|
@ -79,6 +80,14 @@ RegValueExists(HKEY regkey, const WCHAR *name)
|
||||||
return (RegQueryValueEx(regkey, name, NULL, NULL, NULL, NULL) == ERROR_SUCCESS);
|
return (RegQueryValueEx(regkey, name, NULL, NULL, NULL, NULL) == ERROR_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Add trailing slash to a path if not present */
|
||||||
|
static BOOL
|
||||||
|
AddTrailingBackslash(WCHAR *dir, size_t nchar)
|
||||||
|
{
|
||||||
|
HRESULT res = PathCchAddBackslash(dir, nchar);
|
||||||
|
return (res == S_OK || res == S_FALSE) ? TRUE : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
GetGlobalRegistryKeys()
|
GetGlobalRegistryKeys()
|
||||||
{
|
{
|
||||||
|
|
@ -106,7 +115,8 @@ GetGlobalRegistryKeys()
|
||||||
ShowLocalizedMsg(IDS_ERR_OPEN_REGISTRY);
|
ShowLocalizedMsg(IDS_ERR_OPEN_REGISTRY);
|
||||||
}
|
}
|
||||||
if (!regkey || !GetRegistryValue(regkey, _T(""), o.install_path, _countof(o.install_path))
|
if (!regkey || !GetRegistryValue(regkey, _T(""), o.install_path, _countof(o.install_path))
|
||||||
|| _tcslen(o.install_path) == 0)
|
|| _tcslen(o.install_path) == 0
|
||||||
|
|| !AddTrailingBackslash(o.install_path, _countof(o.install_path)))
|
||||||
{
|
{
|
||||||
/* error reading registry value */
|
/* error reading registry value */
|
||||||
if (regkey)
|
if (regkey)
|
||||||
|
|
@ -116,33 +126,32 @@ GetGlobalRegistryKeys()
|
||||||
/* Use a sane default value */
|
/* Use a sane default value */
|
||||||
_sntprintf_0(o.install_path, _T("%ls"), _T("C:\\Program Files\\OpenVPN\\"));
|
_sntprintf_0(o.install_path, _T("%ls"), _T("C:\\Program Files\\OpenVPN\\"));
|
||||||
}
|
}
|
||||||
if (o.install_path[_tcslen(o.install_path) - 1] != _T('\\'))
|
|
||||||
{
|
|
||||||
_tcscat(o.install_path, _T("\\"));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* an admin-defined global config dir defined in HKLM\OpenVPN\config_dir */
|
/* an admin-defined global config dir defined in HKLM\OpenVPN\config_dir */
|
||||||
if (!regkey
|
if (!regkey
|
||||||
|| !GetRegistryValue(
|
|| !GetRegistryValue(
|
||||||
regkey, _T("config_dir"), o.global_config_dir, _countof(o.global_config_dir)))
|
regkey, _T("config_dir"), o.global_config_dir, _countof(o.global_config_dir))
|
||||||
|
|| !AddTrailingBackslash(o.global_config_dir, _countof(o.global_config_dir)))
|
||||||
{
|
{
|
||||||
/* use default = openvpnpath\config */
|
/* use default = openvpnpath\config */
|
||||||
_sntprintf_0(o.global_config_dir, _T("%lsconfig"), o.install_path);
|
_sntprintf_0(o.global_config_dir, _T("%lsconfig\\"), o.install_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!regkey
|
if (!regkey
|
||||||
|| !GetRegistryValue(
|
|| !GetRegistryValue(
|
||||||
regkey, _T("autostart_config_dir"), o.config_auto_dir, _countof(o.config_auto_dir)))
|
regkey, _T("autostart_config_dir"), o.config_auto_dir, _countof(o.config_auto_dir))
|
||||||
|
|| !AddTrailingBackslash(o.config_auto_dir, _countof(o.config_auto_dir)))
|
||||||
{
|
{
|
||||||
/* use default = openvpnpath\config-auto */
|
/* use default = openvpnpath\config-auto */
|
||||||
_sntprintf_0(o.config_auto_dir, L"%lsconfig-auto", o.install_path);
|
_sntprintf_0(o.config_auto_dir, L"%lsconfig-auto\\", o.install_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!regkey
|
if (!regkey
|
||||||
|| !GetRegistryValue(regkey, _T("log_dir"), o.global_log_dir, _countof(o.global_log_dir)))
|
|| !GetRegistryValue(regkey, _T("log_dir"), o.global_log_dir, _countof(o.global_log_dir))
|
||||||
|
|| !AddTrailingBackslash(o.global_log_dir, _countof(o.global_log_dir)))
|
||||||
{
|
{
|
||||||
/* use default = openvpnpath\log */
|
/* use default = openvpnpath\log */
|
||||||
_sntprintf_0(o.global_log_dir, L"%lslog", o.install_path);
|
_sntprintf_0(o.global_log_dir, L"%lslog\\", o.install_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!regkey
|
if (!regkey
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue