Ticket #20: 0001-Fix-multiple-configured-scripts-conflicts-issue-vers.patch

File 0001-Fix-multiple-configured-scripts-conflicts-issue-vers.patch, 4.5 KB (added by David Sommerseth, 12 years ago)

[PATCH] Fix multiple configured scripts conflicts issue (version 2)

  • options.c

    From ce722dc52bc062eb6e07f09133760579fd52f8dd Mon Sep 17 00:00:00 2001
    From: David Sommerseth <dazo@users.sourceforge.net>
    Date: Thu, 5 Aug 2010 20:51:22 +0200
    Subject: [PATCH] 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>
    ---
     options.c |   18 ++++++++++++++++++
     1 files changed, 18 insertions(+), 0 deletions(-)
    
    diff --git a/options.c b/options.c
    index b78158e..e39a8ba 100644
    a b msglevel_forward_compatible (struct options *options, const int msglevel) 
    34783478}
    34793479
    34803480static void
     3481warn_multiple_script (const char *script, const char *type) {
     3482      if (script) {
     3483        msg (M_WARN, "Multiple --%s scripts defined.  "
     3484             "The previously configured script is overridden.", type);
     3485      }
     3486}
     3487
     3488
     3489static void
    34813490add_option (struct options *options,
    34823491            char *p[],
    34833492            const char *file,
    add_option (struct options *options, 
    38773886      VERIFY_PERMISSION (OPT_P_SCRIPT);
    38783887      if (!no_more_than_n_args (msglevel, p, 2, NM_QUOTE_HINT))
    38793888        goto err;
     3889      warn_multiple_script (options->ipchange, "ipchange");
    38803890      options->ipchange = string_substitute (p[1], ',', ' ', &options->gc);
    38813891    }
    38823892  else if (streq (p[0], "float"))
    add_option (struct options *options, 
    39233933      VERIFY_PERMISSION (OPT_P_SCRIPT);
    39243934      if (!no_more_than_n_args (msglevel, p, 2, NM_QUOTE_HINT))
    39253935        goto err;
     3936      warn_multiple_script (options->up_script, "up");
    39263937      options->up_script = p[1];
    39273938    }
    39283939  else if (streq (p[0], "down") && p[1])
    add_option (struct options *options, 
    39303941      VERIFY_PERMISSION (OPT_P_SCRIPT);
    39313942      if (!no_more_than_n_args (msglevel, p, 2, NM_QUOTE_HINT))
    39323943        goto err;
     3944      warn_multiple_script (options->down_script, "down");
    39333945      options->down_script = p[1];
    39343946    }
    39353947  else if (streq (p[0], "down-pre"))
    add_option (struct options *options, 
    45984610      VERIFY_PERMISSION (OPT_P_SCRIPT);
    45994611      if (!no_more_than_n_args (msglevel, p, 2, NM_QUOTE_HINT))
    46004612        goto err;
     4613      warn_multiple_script (options->route_script, "route-up");
    46014614      options->route_script = p[1];
    46024615    }
    46034616  else if (streq (p[0], "route-noexec"))
    add_option (struct options *options, 
    49274940          msg (msglevel, "--auth-user-pass-verify requires a second parameter ('via-env' or 'via-file')");
    49284941          goto err;
    49294942        }
     4943      warn_multiple_script (options->auth_user_pass_verify_script, "auth-user-pass-verify");
    49304944      options->auth_user_pass_verify_script = p[1];
    49314945    }
    49324946  else if (streq (p[0], "client-connect") && p[1])
    add_option (struct options *options, 
    49344948      VERIFY_PERMISSION (OPT_P_SCRIPT);
    49354949      if (!no_more_than_n_args (msglevel, p, 2, NM_QUOTE_HINT))
    49364950        goto err;
     4951      warn_multiple_script (options->client_connect_script, "client-connect");
    49374952      options->client_connect_script = p[1];
    49384953    }
    49394954  else if (streq (p[0], "client-disconnect") && p[1])
    add_option (struct options *options, 
    49414956      VERIFY_PERMISSION (OPT_P_SCRIPT);
    49424957      if (!no_more_than_n_args (msglevel, p, 2, NM_QUOTE_HINT))
    49434958        goto err;
     4959      warn_multiple_script (options->client_disconnect_script, "client-disconnect");
    49444960      options->client_disconnect_script = p[1];
    49454961    }
    49464962  else if (streq (p[0], "learn-address") && p[1])
    add_option (struct options *options, 
    49484964      VERIFY_PERMISSION (OPT_P_SCRIPT);
    49494965      if (!no_more_than_n_args (msglevel, p, 2, NM_QUOTE_HINT))
    49504966        goto err;
     4967      warn_multiple_script (options->learn_address_script, "learn-address");
    49514968      options->learn_address_script = p[1];
    49524969    }
    49534970  else if (streq (p[0], "tmp-dir") && p[1])
    add_option (struct options *options, 
    57085725      VERIFY_PERMISSION (OPT_P_SCRIPT);
    57095726      if (!no_more_than_n_args (msglevel, p, 2, NM_QUOTE_HINT))
    57105727        goto err;
     5728      warn_multiple_script (options->tls_verify, "tls-verify");
    57115729      options->tls_verify = string_substitute (p[1], ',', ' ', &options->gc);
    57125730    }
    57135731  else if (streq (p[0], "tls-remote") && p[1])