summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2007-06-26 23:56:21 +0000
committerStef Walter <stef@memberwebs.com>2007-06-26 23:56:21 +0000
commit35b75975ece6f7e40447efdecbb6163d79e0323d (patch)
treebef8caf6f1d13740c796dc317b77d392abaeccf9
parent92829f531e52776eb91800597eda2907e8d66bf0 (diff)
Make restarting the jail from within actually work.
-rw-r--r--srcx/jkill.c18
-rw-r--r--srcx/util.c4
2 files changed, 14 insertions, 8 deletions
diff --git a/srcx/jkill.c b/srcx/jkill.c
index 8f08e2f..d828fe1 100644
--- a/srcx/jkill.c
+++ b/srcx/jkill.c
@@ -110,6 +110,11 @@ int main(int argc, char* argv[])
if(daemon(0, 1) == -1)
err(1, "couldn't disconnect from console");
+ /* Ignore these signals as all sorts of crazy stuff happens around our process */
+ signal(SIGHUP, SIG_IGN);
+ signal(SIGPIPE, SIG_IGN);
+ signal(SIGTERM, SIG_IGN);
+
r = kill_jail(argv[0]);
exit(r);
}
@@ -193,20 +198,21 @@ static void parse_jail_opts(int argc, char* argv[])
int ch;
int ishr = 0;
- t = strchr(argv[0], '/');
- t = t ? t + 1 : argv[0];
-
g_verbose = 1;
g_force = 1;
g_usescripts = 1;
+ t = strrchr(argv[0], '/');
+ t = t ? t + 1 : argv[0];
+
if(strcmp(t, "halt") == 0)
{
g_restart = 0;
ishr = 1;
}
- else if(strcmp(t, "reboot") == 0)
+ else if(strcmp(t, "reboot") == 0 ||
+ strcmp(t, "restart") == 0)
{
g_restart = 1;
ishr = 1;
@@ -334,10 +340,10 @@ static void parse_host_opts(int argc, char* argv[])
}
#define SHUTDOWN_SCRIPT "/etc/rc.shutdown"
-static char* SHUTDOWN_ARGS[] = { _PATH_BSHELL, SHUTDOWN_SCRIPT };
+static char* SHUTDOWN_ARGS[] = { _PATH_BSHELL, SHUTDOWN_SCRIPT, NULL };
#define START_SCRIPT "/etc/rc"
-static char* START_ARGS[] = { _PATH_BSHELL, START_SCRIPT };
+static char* START_ARGS[] = { _PATH_BSHELL, START_SCRIPT, NULL };
static int kill_jail(const char* jail)
{
diff --git a/srcx/util.c b/srcx/util.c
index 59226fd..214707e 100644
--- a/srcx/util.c
+++ b/srcx/util.c
@@ -403,9 +403,9 @@ int run_dup_command(const char* jail, const char* cmd, char* env[],
/* Okay, now run whatever command it was */
if(args)
- execve(cmd, args, env);
+ execve(cmd, args, env ? env : environ);
else
- execle(cmd, cmd, NULL, env);
+ execle(cmd, cmd, NULL, env ? env : environ);
/* In case it returns then have to do this to get
children to disconnect from stdout */