From ce722dc52bc062eb6e07f09133760579fd52f8dd Mon Sep 17 00:00:00 2001 From: David Sommerseth Date: Thu, 5 Aug 2010 20:51:22 +0200 Subject: Fix multiple configured scripts conflicts issue (version 2) This is a fix for trac ticket #20, which was started in the sf.net bug tracker: 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 Acked-by: James Yonan --- options.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'options.c') diff --git a/options.c b/options.c index b78158e..e39a8ba 100644 --- a/options.c +++ b/options.c @@ -3477,6 +3477,15 @@ msglevel_forward_compatible (struct options *options, const int msglevel) return options->forward_compatible ? M_WARN : 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[], @@ -3877,6 +3886,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")) @@ -3923,6 +3933,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]) @@ -3930,6 +3941,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")) @@ -4598,6 +4610,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")) @@ -4927,6 +4940,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]) @@ -4934,6 +4948,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]) @@ -4941,6 +4956,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]) @@ -4948,6 +4964,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]) @@ -5708,6 +5725,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]) -- cgit v1.2.3