From eb47066238189b1fded887ffce25e6ff57c86a0d Mon Sep 17 00:00:00 2001
From: Gert Doering <gert@greenie.muc.de>
Date: Tue, 28 Apr 2015 13:01:41 +0200
Subject: [PATCH] Print helpful error message on --mktun/--rmtun if not
available.
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>
---
src/openvpn/init.c | 10 ++++++++--
src/openvpn/options.c | 2 --
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/openvpn/init.c b/src/openvpn/init.c
index b97d2da..42cb3e2 100644
a
|
b
|
do_genkey (const struct options * options) |
887 | 887 | bool |
888 | 888 | do_persist_tuntap (const struct options *options) |
889 | 889 | { |
890 | | #ifdef ENABLE_FEATURE_TUN_PERSIST |
891 | 890 | if (options->persist_config) |
892 | 891 | { |
893 | 892 | /* sanity check on options for --mktun or --rmtun */ |
… |
… |
do_persist_tuntap (const struct options *options) |
901 | 900 | ) |
902 | 901 | msg (M_FATAL|M_OPTERR, |
903 | 902 | "options --mktun or --rmtun should only be used together with --dev"); |
| 903 | #ifdef ENABLE_FEATURE_TUN_PERSIST |
904 | 904 | tuncfg (options->dev, options->dev_type, options->dev_node, |
905 | 905 | options->persist_mode, |
906 | 906 | options->username, options->groupname, &options->tuntap_options); |
907 | 907 | if (options->persist_mode && options->lladdr) |
908 | 908 | set_lladdr(options->dev, options->lladdr, NULL); |
909 | 909 | return true; |
910 | | } |
| 910 | #else |
| 911 | msg( M_FATAL|M_OPTERR, |
| 912 | "options --mktun and --rmtun are not available on your operating " |
| 913 | "system. Please check 'man tun' (or 'tap'), whether your system " |
| 914 | "supports using 'ifconfig %s create' / 'destroy' to create/remove " |
| 915 | "persistant tunnel interfaces.", options->dev ); |
911 | 916 | #endif |
| 917 | } |
912 | 918 | return false; |
913 | 919 | } |
914 | 920 | |
diff --git a/src/openvpn/options.c b/src/openvpn/options.c
index e8cf06a..4f27336 100644
a
|
b
|
add_option (struct options *options, |
7023 | 7023 | options->pkcs11_id_management = true; |
7024 | 7024 | } |
7025 | 7025 | #endif |
7026 | | #ifdef ENABLE_FEATURE_TUN_PERSIST |
7027 | 7026 | else if (streq (p[0], "rmtun")) |
7028 | 7027 | { |
7029 | 7028 | VERIFY_PERMISSION (OPT_P_GENERAL); |
… |
… |
add_option (struct options *options, |
7036 | 7035 | options->persist_config = true; |
7037 | 7036 | options->persist_mode = 1; |
7038 | 7037 | } |
7039 | | #endif |
7040 | 7038 | else if (streq (p[0], "peer-id")) |
7041 | 7039 | { |
7042 | 7040 | VERIFY_PERMISSION (OPT_P_PEER_ID); |