summaryrefslogtreecommitdiffstats
path: root/options.c
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2010-08-05 20:51:22 +0200
committerDavid Sommerseth <dazo@users.sourceforge.net>2010-10-21 11:40:36 +0200
commit3a777430493de180d425cebbc9eecde68e7fb6a6 (patch)
treef606a8e1d80920e5b2dc9da9d1bf94c3312ef8ad /options.c
parent639216502cc474fcc2526598680b2bcdbb35c0a1 (diff)
downloadopenvpn-3a777430493de180d425cebbc9eecde68e7fb6a6.tar.gz
openvpn-3a777430493de180d425cebbc9eecde68e7fb6a6.tar.xz
openvpn-3a777430493de180d425cebbc9eecde68e7fb6a6.zip
Fix multiple configured scripts conflicts issue (version 2)
This is a fix for trac ticket #20, <https://community.openvpn.net/openvpn/ticket/20> which was started in the sf.net bug tracker: <http://sourceforge.net/tracker/?func=detail&aid=2078470&group_id=48978&atid=454719> The implemented solution is to give a warning for each of the different script hooks available. The last configured script will override any earlier configured scripts, to ensure that the command line can override the configuration file. Signed-off-by: David Sommerseth <dazo@users.sourceforge.net> Acked-by: James Yonan <james@openvpn.net>
Diffstat (limited to 'options.c')
-rw-r--r--options.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/options.c b/options.c
index 6d3ef8e..3c20f5b 100644
--- a/options.c
+++ b/options.c
@@ -3491,6 +3491,15 @@ msglevel_forward_compatible (struct options *options, const int msglevel)
}
static void
+warn_multiple_script (const char *script, const char *type) {
+ if (script) {
+ msg (M_WARN, "Multiple --%s scripts defined. "
+ "The previously configured script is overridden.", type);
+ }
+}
+
+
+static void
add_option (struct options *options,
char *p[],
const char *file,
@@ -3890,6 +3899,7 @@ add_option (struct options *options,
VERIFY_PERMISSION (OPT_P_SCRIPT);
if (!no_more_than_n_args (msglevel, p, 2, NM_QUOTE_HINT))
goto err;
+ warn_multiple_script (options->ipchange, "ipchange");
options->ipchange = string_substitute (p[1], ',', ' ', &options->gc);
}
else if (streq (p[0], "float"))
@@ -3936,6 +3946,7 @@ add_option (struct options *options,
VERIFY_PERMISSION (OPT_P_SCRIPT);
if (!no_more_than_n_args (msglevel, p, 2, NM_QUOTE_HINT))
goto err;
+ warn_multiple_script (options->up_script, "up");
options->up_script = p[1];
}
else if (streq (p[0], "down") && p[1])
@@ -3943,6 +3954,7 @@ add_option (struct options *options,
VERIFY_PERMISSION (OPT_P_SCRIPT);
if (!no_more_than_n_args (msglevel, p, 2, NM_QUOTE_HINT))
goto err;
+ warn_multiple_script (options->down_script, "down");
options->down_script = p[1];
}
else if (streq (p[0], "down-pre"))
@@ -4624,6 +4636,7 @@ add_option (struct options *options,
VERIFY_PERMISSION (OPT_P_SCRIPT);
if (!no_more_than_n_args (msglevel, p, 2, NM_QUOTE_HINT))
goto err;
+ warn_multiple_script (options->route_script, "route-up");
options->route_script = p[1];
}
else if (streq (p[0], "route-noexec"))
@@ -4953,6 +4966,7 @@ add_option (struct options *options,
msg (msglevel, "--auth-user-pass-verify requires a second parameter ('via-env' or 'via-file')");
goto err;
}
+ warn_multiple_script (options->auth_user_pass_verify_script, "auth-user-pass-verify");
options->auth_user_pass_verify_script = p[1];
}
else if (streq (p[0], "client-connect") && p[1])
@@ -4960,6 +4974,7 @@ add_option (struct options *options,
VERIFY_PERMISSION (OPT_P_SCRIPT);
if (!no_more_than_n_args (msglevel, p, 2, NM_QUOTE_HINT))
goto err;
+ warn_multiple_script (options->client_connect_script, "client-connect");
options->client_connect_script = p[1];
}
else if (streq (p[0], "client-disconnect") && p[1])
@@ -4967,6 +4982,7 @@ add_option (struct options *options,
VERIFY_PERMISSION (OPT_P_SCRIPT);
if (!no_more_than_n_args (msglevel, p, 2, NM_QUOTE_HINT))
goto err;
+ warn_multiple_script (options->client_disconnect_script, "client-disconnect");
options->client_disconnect_script = p[1];
}
else if (streq (p[0], "learn-address") && p[1])
@@ -4974,6 +4990,7 @@ add_option (struct options *options,
VERIFY_PERMISSION (OPT_P_SCRIPT);
if (!no_more_than_n_args (msglevel, p, 2, NM_QUOTE_HINT))
goto err;
+ warn_multiple_script (options->learn_address_script, "learn-address");
options->learn_address_script = p[1];
}
else if (streq (p[0], "tmp-dir") && p[1])
@@ -5753,6 +5770,7 @@ add_option (struct options *options,
VERIFY_PERMISSION (OPT_P_SCRIPT);
if (!no_more_than_n_args (msglevel, p, 2, NM_QUOTE_HINT))
goto err;
+ warn_multiple_script (options->tls_verify, "tls-verify");
options->tls_verify = string_substitute (p[1], ',', ' ', &options->gc);
}
else if (streq (p[0], "tls-remote") && p[1])