summaryrefslogtreecommitdiff
path: root/src/starter/invokecharon.c
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@debian.org>2013-01-02 14:18:20 +0100
committerYves-Alexis Perez <corsac@debian.org>2013-01-02 14:18:20 +0100
commitc1343b3278cdf99533b7902744d15969f9d6fdc1 (patch)
treed5ed3dc5677a59260ec41cd39bb284d3e94c91b3 /src/starter/invokecharon.c
parentb34738ed08c2227300d554b139e2495ca5da97d6 (diff)
downloadvyos-strongswan-c1343b3278cdf99533b7902744d15969f9d6fdc1.tar.gz
vyos-strongswan-c1343b3278cdf99533b7902744d15969f9d6fdc1.zip
Imported Upstream version 5.0.1
Diffstat (limited to 'src/starter/invokecharon.c')
-rw-r--r--src/starter/invokecharon.c43
1 files changed, 21 insertions, 22 deletions
diff --git a/src/starter/invokecharon.c b/src/starter/invokecharon.c
index e88939415..102d1589e 100644
--- a/src/starter/invokecharon.c
+++ b/src/starter/invokecharon.c
@@ -23,11 +23,8 @@
#include <stdlib.h>
#include <errno.h>
-#include <freeswan.h>
-
-#include "../pluto/constants.h"
-#include "../pluto/defs.h"
-#include "../pluto/log.h"
+#include <library.h>
+#include <debug.h>
#include "confread.h"
#include "invokecharon.h"
@@ -49,19 +46,19 @@ void starter_charon_sigchild(pid_t pid, int status)
if (status == SS_RC_LIBSTRONGSWAN_INTEGRITY ||
status == SS_RC_DAEMON_INTEGRITY)
{
- plog("charon has quit: integrity test of %s failed",
- (status == 64) ? "libstrongswan" : "charon");
+ DBG1(DBG_APP, "charon has quit: integrity test of %s failed",
+ (status == 64) ? "libstrongswan" : "charon");
_stop_requested = 1;
}
else if (status == SS_RC_INITIALIZATION_FAILED)
{
- plog("charon has quit: initialization failed");
+ DBG1(DBG_APP, "charon has quit: initialization failed");
_stop_requested = 1;
}
if (!_stop_requested)
{
- plog("charon has died -- restart scheduled (%dsec)"
- , CHARON_RESTART_DELAY);
+ DBG1(DBG_APP, "charon has died -- restart scheduled (%dsec)",
+ CHARON_RESTART_DELAY);
alarm(CHARON_RESTART_DELAY); // restart in 5 sec
}
unlink(CHARON_PID_FILE);
@@ -91,7 +88,7 @@ int starter_stop_charon (void)
else if (i == 40)
{
kill(pid, SIGKILL);
- plog("starter_stop_charon(): charon does not respond, sending KILL");
+ DBG1(DBG_APP, "starter_stop_charon(): charon does not respond, sending KILL");
}
else
{
@@ -101,15 +98,15 @@ int starter_stop_charon (void)
}
if (_charon_pid == 0)
{
- plog("charon stopped after %d ms", 200*i);
+ DBG1(DBG_APP, "charon stopped after %d ms", 200*i);
return 0;
}
- plog("starter_stop_charon(): can't stop charon !!!");
+ DBG1(DBG_APP, "starter_stop_charon(): can't stop charon !!!");
return -1;
}
else
{
- plog("stater_stop_charon(): charon was not started...");
+ DBG1(DBG_APP, "stater_stop_charon(): charon was not started...");
}
return -1;
}
@@ -175,7 +172,7 @@ int starter_start_charon (starter_config_t *cfg, bool no_fork, bool attach_gdb)
if (_charon_pid)
{
- plog("starter_start_charon(): charon already started...");
+ DBG1(DBG_APP, "starter_start_charon(): charon already started...");
return -1;
}
else
@@ -187,34 +184,36 @@ int starter_start_charon (starter_config_t *cfg, bool no_fork, bool attach_gdb)
switch (pid)
{
case -1:
- plog("can't fork(): %s", strerror(errno));
+ DBG1(DBG_APP, "can't fork(): %s", strerror(errno));
return -1;
case 0:
/* child */
setsid();
+ closefrom(3);
sigprocmask(SIG_SETMASK, 0, NULL);
/* disable glibc's malloc checker, conflicts with leak detective */
setenv("MALLOC_CHECK_", "0", 1);
execv(arg[0], arg);
- plog("can't execv(%s,...): %s", arg[0], strerror(errno));
+ DBG1(DBG_APP, "can't execv(%s,...): %s", arg[0], strerror(errno));
exit(1);
default:
/* father */
- _charon_pid = pid;
- for (i = 0; i < 500 && _charon_pid; i++)
+ _charon_pid = pid;
+ for (i = 0; i < 500 && _charon_pid; i++)
{
/* wait for charon for a maximum of 500 x 20 ms = 10 s */
usleep(20000);
if (stat(CHARON_PID_FILE, &stb) == 0)
{
- plog("charon (%d) started after %d ms", _charon_pid, 20*(i+1));
+ DBG1(DBG_APP, "charon (%d) started after %d ms",
+ _charon_pid, 20*(i+1));
return 0;
}
}
if (_charon_pid)
{
/* If charon is started but with no ctl file, stop it */
- plog("charon too long to start... - kill kill");
+ DBG1(DBG_APP, "charon too long to start... - kill kill");
for (i = 0; i < 20 && (pid = _charon_pid) != 0; i++)
{
if (i == 0)
@@ -234,7 +233,7 @@ int starter_start_charon (starter_config_t *cfg, bool no_fork, bool attach_gdb)
}
else
{
- plog("charon refused to be started");
+ DBG1(DBG_APP, "charon refused to be started");
}
return -1;
}