]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Detect missing TAP driver and bail out gracefully
authorSimon Rozman <simon@rozman.si>
Wed, 19 Dec 2018 20:26:11 +0000 (21:26 +0100)
committerGert Doering <gert@greenie.muc.de>
Tue, 22 Jan 2019 18:48:03 +0000 (19:48 +0100)
When no TUN/TAP driver is installed a interface cannot be created. This
patch detects this condition and bails out with an error message.

This also fixes a typo in one of the error messages.
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20181219202611.2144-4-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg18038.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/tapctl/tap.c

index 790a495640ecc8ad1c70fd78a3df10cb5ecfdedc..ed3c6e0bc997b21602540bc24c3cedb8f92ad25b 100644 (file)
@@ -460,7 +460,7 @@ tap_create_interface(
             &devinfo_data))
     {
         dwResult = GetLastError();
-        msg(M_NONFATAL, "%s: SetupDiClassNameFromGuid failed", __FUNCTION__);
+        msg(M_NONFATAL, "%s: SetupDiCreateDeviceInfo failed", __FUNCTION__);
         goto cleanup_hDevInfoList;
     }
 
@@ -596,6 +596,13 @@ tap_create_interface(
         free(drvinfo_detail_data);
     }
 
+    if (dwlDriverVersion == 0)
+    {
+        dwResult = ERROR_NOT_FOUND;
+        msg(M_NONFATAL, "%s: No driver for device \"%" PRIsLPTSTR "\" installed.", __FUNCTION__, szzHardwareIDs);
+        goto cleanup_DriverInfoList;
+    }
+
     /* Call appropriate class installer. */
     if (!SetupDiCallClassInstaller(
             DIF_REGISTERDEVICE,