Re: [Openvpn-devel] [PATCH 11/12] openvpnmsica: Merge FindTUNTAPAdapters into FindSystemInfo

2020-03-31 Thread Lev Stipakov
Hi,

> To summarize: the return value of find_adapters() call is ignored on purpose.

Shouldn't return type be void if return value is not used?

I'll ack it to not to further delay 2.5 release, but it would be good
to get a follow-up
patch with either void or return value being not ignored.

Acked-by: Lev Stipakov 


___
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel


Re: [Openvpn-devel] [PATCH 11/12] openvpnmsica: Merge FindTUNTAPAdapters into FindSystemInfo

2020-03-30 Thread Simon Rozman
Hi Lev,

I'm struggling with family duties now that schools are closed. This makes it 
hard to find any time for computers.

Nevertheless, should find_adapters() fail for some reason, it is not critical 
to bail out of FindSystemInfo() custom action.

The find_adapters() itself already displays a resumable error message (MSI also 
writes it to the log) on all of the error return paths:
- tap_list_adapters() calls msg(M_NONFATAL...) on error returns
- other returns have msg(M_NONFATAL...)

Mind that msg() is using MSI error messaging 
[https://github.com/rozmansi/openvpn/blob/feature/msi/src/openvpnmsica/dllmain.c#L108].
 MsiProcessMessage(s->hInstall, INSTALLMESSAGE_ERROR, hRecordProg); will popup 
an error dialog in interactive MSI sessions, and write error message to the log 
in interactive and non-interactive sessions.

To summarize: the return value of find_adapters() call is ignored on purpose.

Regards,
Simon

-Original Message-
From: Lev Stipakov 
Date: Tuesday, 24 March 2020 at 13:07
To: Simon Rozman 
Cc: "openvpn-devel@lists.sourceforge.net" 
Subject: Re: [Openvpn-devel] [PATCH 11/12] openvpnmsica: Merge 
FindTUNTAPAdapters into FindSystemInfo

Hi,

Compiled with msvc, smoke-tested with rundll32.

One thing:

> +set_openvpnserv_state(hInstall);
> +find_adapters(
> +hInstall,
> +TEXT("root\\") TEXT(TAP_WIN_COMPONENT_ID),
> +TEXT("TAPWINDOWS6ADAPTERS"),
> +TEXT("ACTIVETAPWINDOWS6ADAPTERS"));

Both methods return error codes which we ignore.



smime.p7s
Description: S/MIME cryptographic signature
___
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel


Re: [Openvpn-devel] [PATCH 11/12] openvpnmsica: Merge FindTUNTAPAdapters into FindSystemInfo

2020-03-24 Thread Lev Stipakov
Hi,

Compiled with msvc, smoke-tested with rundll32.

One thing:

> +set_openvpnserv_state(hInstall);
> +find_adapters(
> +hInstall,
> +TEXT("root\\") TEXT(TAP_WIN_COMPONENT_ID),
> +TEXT("TAPWINDOWS6ADAPTERS"),
> +TEXT("ACTIVETAPWINDOWS6ADAPTERS"));

Both methods return error codes which we ignore.


___
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel


[Openvpn-devel] [PATCH 11/12] openvpnmsica: Merge FindTUNTAPAdapters into FindSystemInfo

2020-03-09 Thread Simon Rozman
1. We don't need two custom actions to evaluate the system state, do we?

2. FindTUNTAPAdapters was actually broken. It enumerated all existing
   network adapters, rather than just the ones we are interested in:
   TAP-Windows6 and Wintun.

3. TUNTAPADAPTER and ACTIVETUNTAPADAPTERS were split into
   TAPWINDOWS6ADAPTERS, ACTIVETAPWINDOWS6ADAPTERS, WINTUNADAPTERS and
   ACTIVEWINTUNADAPTERS to allow finer control.

Signed-off-by: Simon Rozman 
---
 src/openvpnmsica/openvpnmsica.c | 235 
 src/openvpnmsica/openvpnmsica.h |  26 ++--
 2 files changed, 125 insertions(+), 136 deletions(-)

diff --git a/src/openvpnmsica/openvpnmsica.c b/src/openvpnmsica/openvpnmsica.c
index ae9b007f..28cf16b5 100644
--- a/src/openvpnmsica/openvpnmsica.c
+++ b/src/openvpnmsica/openvpnmsica.c
@@ -248,49 +248,26 @@ cleanup_OpenSCManager:
 }
 
 
-UINT __stdcall
-FindSystemInfo(_In_ MSIHANDLE hInstall)
-{
-#ifdef _MSC_VER
-#pragma comment(linker, DLLEXP_EXPORT)
-#endif
-
-debug_popup(TEXT(__FUNCTION__));
-
-BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL));
-
-OPENVPNMSICA_SAVE_MSI_SESSION(hInstall);
-
-set_openvpnserv_state(hInstall);
-
-if (bIsCoInitialized)
-{
-CoUninitialize();
-}
-return ERROR_SUCCESS;
-}
-
-
-UINT __stdcall
-FindTUNTAPAdapters(_In_ MSIHANDLE hInstall)
+static UINT
+find_adapters(
+_In_ MSIHANDLE hInstall,
+_In_z_ LPCTSTR szHardwareId,
+_In_z_ LPCTSTR szAdaptersPropertyName,
+_In_z_ LPCTSTR szActiveAdaptersPropertyName)
 {
-#ifdef _MSC_VER
-#pragma comment(linker, DLLEXP_EXPORT)
-#endif
-
-debug_popup(TEXT(__FUNCTION__));
-
 UINT uiResult;
-BOOL bIsCoInitialized = SUCCEEDED(CoInitialize(NULL));
-
-OPENVPNMSICA_SAVE_MSI_SESSION(hInstall);
 
-/* Get existing network adapters. */
+/* Get network adapters with given hardware ID. */
 struct tap_adapter_node *pAdapterList = NULL;
-uiResult = tap_list_adapters(NULL, NULL, );
+uiResult = tap_list_adapters(NULL, szHardwareId, );
 if (uiResult != ERROR_SUCCESS)
 {
-goto cleanup_CoInitialize;
+return uiResult;
+}
+else if (pAdapterList == NULL)
+{
+/* No adapters - no fun. */
+return ERROR_SUCCESS;
 }
 
 /* Get IPv4/v6 info for all network adapters. Actually, we're interested 
in link status only: up/down? */
@@ -302,7 +279,7 @@ FindTUNTAPAdapters(_In_ MSIHANDLE hInstall)
 if (pAdapterAdresses == NULL)
 {
 msg(M_NONFATAL, "%s: malloc(%u) failed", __FUNCTION__, 
ulAdapterAdressesSize);
-uiResult = ERROR_OUTOFMEMORY; goto cleanup_tap_list_adapters;
+uiResult = ERROR_OUTOFMEMORY; goto cleanup_pAdapterList;
 }
 
 ULONG ulResult = GetAdaptersAddresses(
@@ -322,117 +299,135 @@ FindTUNTAPAdapters(_In_ MSIHANDLE hInstall)
 {
 SetLastError(ulResult); /* MSDN does not mention 
GetAdaptersAddresses() to set GetLastError(). But we do have an error code. Set 
last error manually. */
 msg(M_NONFATAL | M_ERRNO, "%s: GetAdaptersAddresses() failed", 
__FUNCTION__);
-uiResult = ulResult; goto cleanup_tap_list_adapters;
+uiResult = ulResult; goto cleanup_pAdapterList;
 }
 }
 
-if (pAdapterList != NULL)
+/* Count adapters. */
+size_t adapter_count = 0;
+for (struct tap_adapter_node *pAdapter = pAdapterList; pAdapter; pAdapter 
= pAdapter->pNext)
 {
-/* Count adapters. */
-size_t adapter_count = 0;
-for (struct tap_adapter_node *pAdapter = pAdapterList; pAdapter; 
pAdapter = pAdapter->pNext)
-{
-adapter_count++;
-}
+adapter_count++;
+}
 
-/* Prepare semicolon delimited list of TAP adapter ID(s) and active 
TAP adapter ID(s). */
-LPTSTR
-szAdapters = (LPTSTR)malloc(adapter_count * (38 /*GUID*/ + 1 
/*separator/terminator*/) * sizeof(TCHAR)),
-szAdaptersTail = szAdapters;
-if (szAdapters == NULL)
-{
-msg(M_FATAL, "%s: malloc(%u) failed", __FUNCTION__, adapter_count 
* (38 /*GUID*/ + 1 /*separator/terminator*/) * sizeof(TCHAR));
-uiResult = ERROR_OUTOFMEMORY; goto cleanup_pAdapterAdresses;
-}
+/* Prepare semicolon delimited list of TAP adapter ID(s) and active TAP 
adapter ID(s). */
+LPTSTR
+szAdapters = (LPTSTR)malloc(adapter_count * (38 /*GUID*/ + 1 
/*separator/terminator*/) * sizeof(TCHAR)),
+szAdaptersTail = szAdapters;
+if (szAdapters == NULL)
+{
+msg(M_FATAL, "%s: malloc(%u) failed", __FUNCTION__, adapter_count * 
(38 /*GUID*/ + 1 /*separator/terminator*/) * sizeof(TCHAR));
+uiResult = ERROR_OUTOFMEMORY; goto cleanup_pAdapterAdresses;
+}
+
+LPTSTR
+szAdaptersActive = (LPTSTR)malloc(adapter_count * (38 /*GUID*/ + 1 
/*separator/terminator*/) * sizeof(TCHAR)),
+szAdaptersActiveTail = szAdaptersActive;
+if