]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Print helpful error message on --mktun/--rmtun if not available.
authorGert Doering <gert@greenie.muc.de>
Tue, 28 Apr 2015 11:04:23 +0000 (13:04 +0200)
committerGert Doering <gert@greenie.muc.de>
Tue, 28 Apr 2015 15:13:44 +0000 (17:13 +0200)
OpenVPN only supports --mktun/--rmtun to create/destroy persistant
tunnels on Linux.  On BSD OSes, "ifconfig tun0 create" can do the
same job, so we do not actually need to support it - but the previous
error message ("unknown option") wasn't helpful.  So always accept
the option now, and on non-supported systems, direct user to manpage.

Trac #85

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: David Sommerseth <dazo@users.sourceforge.net>
Message-Id: <1430219063-12291-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9617
(cherry picked from commit 4ad2b65d9deb3197d847d7dcc36715aa5394836f)

src/openvpn/init.c
src/openvpn/options.c

index 3a67a50c17163b96cbd52ef89e1dfcd12ebb2a55..2c3285d8f9405c42742f20aef0b092e80cbddd42 100644 (file)
@@ -910,7 +910,6 @@ do_genkey (const struct options * options)
 bool
 do_persist_tuntap (const struct options *options)
 {
-#ifdef ENABLE_FEATURE_TUN_PERSIST
   if (options->persist_config)
     {
       /* sanity check on options for --mktun or --rmtun */
@@ -926,14 +925,21 @@ do_persist_tuntap (const struct options *options)
        )
        msg (M_FATAL|M_OPTERR,
             "options --mktun or --rmtun should only be used together with --dev");
+#ifdef ENABLE_FEATURE_TUN_PERSIST
       tuncfg (options->dev, options->dev_type, options->dev_node,
              options->persist_mode,
              options->username, options->groupname, &options->tuntap_options);
       if (options->persist_mode && options->lladdr)
         set_lladdr(options->dev, options->lladdr, NULL);
       return true;
-    }
+#else
+      msg( M_FATAL|M_OPTERR,
+       "options --mktun and --rmtun are not available on your operating "
+       "system.  Please check 'man tun' (or 'tap'), whether your system "
+        "supports using 'ifconfig %s create' / 'destroy' to create/remove "
+        "persistant tunnel interfaces.", options->dev );
 #endif
+    }
   return false;
 }
 
index dd3f1e4e875878b570d351dfce9f4fd70c54f6de..496eb5d2fdceb38c973687ad301867eca76f1483 100644 (file)
@@ -7038,7 +7038,6 @@ add_option (struct options *options,
       options->pkcs11_id_management = true;
     }
 #endif
-#ifdef ENABLE_FEATURE_TUN_PERSIST
   else if (streq (p[0], "rmtun"))
     {
       VERIFY_PERMISSION (OPT_P_GENERAL);
@@ -7051,7 +7050,6 @@ add_option (struct options *options,
       options->persist_config = true;
       options->persist_mode = 1;
     }
-#endif
   else if (streq (p[0], "peer-id"))
     {
       VERIFY_PERMISSION (OPT_P_PEER_ID);