From: Tobias Brunner Date: Thu, 11 Aug 2011 11:38:05 +0000 (+0200) Subject: Verify that executables are available and set (pluto|charon)start accordingly. X-Git-Tag: 4.6.0~572 X-Git-Url: https://git.strongswan.org/?p=strongswan.git;a=commitdiff_plain;h=45048eae238abc35186a6c15833af229cb5fefea;ds=sidebyside Verify that executables are available and set (pluto|charon)start accordingly. Some distributions enable both daemons but then distribute the executables in two separate packages. If only one package is installed but both daemons are enabled in ipsec.conf, starter will try to start the non existing daemon over and over again, and will each time readd the configs to the other daemon. --- diff --git a/src/starter/confread.c b/src/starter/confread.c index 5c94787..a470542 100644 --- a/src/starter/confread.c +++ b/src/starter/confread.c @@ -12,6 +12,9 @@ * for more details. */ +#include +#include +#include #include #include #include @@ -29,6 +32,7 @@ #include "parser.h" #include "confread.h" #include "args.h" +#include "files.h" #include "interfaces.h" /* strings containing a colon are interpreted as an IPv6 address */ @@ -39,6 +43,17 @@ static const char esp_defaults[] = "aes128-sha1,3des-sha1"; static const char firewall_defaults[] = "ipsec _updown iptables"; +static bool daemon_exists(char *daemon, char *path) +{ + struct stat st; + if (stat(path, &st) != 0) + { + plog("Disabling %sstart option, '%s' not found", daemon, path); + return FALSE; + } + return TRUE; +} + static void default_values(starter_config_t *cfg) { if (cfg == NULL) @@ -137,6 +152,21 @@ static void load_setup(starter_config_t *cfg, config_parsed_t *cfgp) continue; } } + + /* verify the executables are actually available (some distros split + * packages but enabled both) */ +#ifdef START_CHARON + cfg->setup.charonstart = cfg->setup.charonstart && + daemon_exists("charon", CHARON_CMD); +#else + cfg->setup.charonstart = FALSE; +#endif +#ifdef START_PLUTO + cfg->setup.plutostart = cfg->setup.plutostart && + daemon_exists("pluto", PLUTO_CMD); +#else + cfg->setup.plutostart = FALSE; +#endif } static void kw_end(starter_conn_t *conn, starter_end_t *end, kw_token_t token,