summaryrefslogtreecommitdiff
path: root/src/starter/starter.c
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@debian.org>2013-08-25 15:37:26 +0200
committerYves-Alexis Perez <corsac@debian.org>2013-08-25 15:37:26 +0200
commit6b99c8d9cff7b3e8ae8f3204b99e7ea40f791349 (patch)
tree009fc492961e13860d2a4bc2de8caf2bbe2975e7 /src/starter/starter.c
parentc83921a2b566aa9d55d8ccc7258f04fca6292ee6 (diff)
downloadvyos-strongswan-6b99c8d9cff7b3e8ae8f3204b99e7ea40f791349.tar.gz
vyos-strongswan-6b99c8d9cff7b3e8ae8f3204b99e7ea40f791349.zip
Imported Upstream version 5.1.0
Diffstat (limited to 'src/starter/starter.c')
-rw-r--r--src/starter/starter.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/starter/starter.c b/src/starter/starter.c
index 917e52d68..06eb142bd 100644
--- a/src/starter/starter.c
+++ b/src/starter/starter.c
@@ -61,6 +61,8 @@ char *cmd = NULL;
char *pid_file = NULL;
char *starter_pid_file = NULL;
+static char *config_file = NULL;
+
/* logging */
static bool log_to_stderr = TRUE;
static bool log_to_syslog = TRUE;
@@ -291,11 +293,11 @@ static void generate_selfcert()
}
}
#endif
- setegid(gid);
- seteuid(uid);
- ignore_result(system("ipsec scepclient --out pkcs1 --out cert-self --quiet"));
- seteuid(0);
- setegid(0);
+ ignore_result(setegid(gid));
+ ignore_result(seteuid(uid));
+ ignore_result(system(IPSEC_SCRIPT " scepclient --out pkcs1 --out cert-self --quiet"));
+ ignore_result(seteuid(0));
+ ignore_result(setegid(0));
/* ipsec.secrets is root readable only */
oldmask = umask(0066);
@@ -393,7 +395,8 @@ static void usage(char *name)
{
fprintf(stderr, "Usage: starter [--nofork] [--auto-update <sec>]\n"
" [--debug|--debug-more|--debug-all|--nolog]\n"
- " [--attach-gdb] [--daemon <name>]\n");
+ " [--attach-gdb] [--daemon <name>]\n"
+ " [--conf <path to ipsec.conf>]\n");
exit(LSB_RC_INVALID_ARGUMENT);
}
@@ -460,6 +463,10 @@ int main (int argc, char **argv)
{
daemon_name = argv[++i];
}
+ else if (streq(argv[i], "--conf") && i+1 < argc)
+ {
+ config_file = argv[++i];
+ }
else
{
usage(argv[0]);
@@ -471,6 +478,10 @@ int main (int argc, char **argv)
DBG1(DBG_APP, "unable to set daemon name");
exit(LSB_RC_FAILURE);
}
+ if (!config_file)
+ {
+ config_file = CONFIG_FILE;
+ }
init_log("ipsec_starter");
@@ -524,7 +535,7 @@ int main (int argc, char **argv)
exit(LSB_RC_FAILURE);
}
- cfg = confread_load(CONFIG_FILE);
+ cfg = confread_load(config_file);
if (cfg == NULL || cfg->err > 0)
{
DBG1(DBG_APP, "unable to start strongSwan -- fatal errors in config");
@@ -706,7 +717,7 @@ int main (int argc, char **argv)
if (_action_ & FLAG_ACTION_UPDATE)
{
DBG2(DBG_APP, "Reloading config...");
- new_cfg = confread_load(CONFIG_FILE);
+ new_cfg = confread_load(config_file);
if (new_cfg && (new_cfg->err == 0))
{
@@ -898,4 +909,3 @@ int main (int argc, char **argv)
}
exit(LSB_RC_SUCCESS);
}
-