diff options
author | jamie <jamie@FreeBSD.org> | 2009-05-27 14:30:26 +0000 |
---|---|---|
committer | jamie <jamie@FreeBSD.org> | 2009-05-27 14:30:26 +0000 |
commit | 8dbff96dac0a8009a4169eedbbe59be58a480889 (patch) | |
tree | 4a406964696e0ebb946248969d86b305f81eab7b /usr.bin/killall | |
parent | a013e0afcbb44052a86a7977277d669d8883b7e7 (diff) | |
download | FreeBSD-src-8dbff96dac0a8009a4169eedbbe59be58a480889.zip FreeBSD-src-8dbff96dac0a8009a4169eedbbe59be58a480889.tar.gz |
Add support for the arbitrary named jail parameters used by jail_set(2)
and jail_get(2). Jail(8) can now create jails using a "name=value"
format instead of just specifying a limited set of fixed parameters; it
can also modify parameters of existing jails. Jls(8) can display all
parameters of jails, or a specified set of parameters. The available
parameters are gathered from the kernel, and not hard-coded into these
programs.
Small patches on killall(1) and jexec(8) to support jail names with
jail_get(2).
Approved by: bz (mentor)
Diffstat (limited to 'usr.bin/killall')
-rw-r--r-- | usr.bin/killall/killall.1 | 10 | ||||
-rw-r--r-- | usr.bin/killall/killall.c | 23 |
2 files changed, 22 insertions, 11 deletions
diff --git a/usr.bin/killall/killall.1 b/usr.bin/killall/killall.1 index 816ea81..632c066 100644 --- a/usr.bin/killall/killall.1 +++ b/usr.bin/killall/killall.1 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 9, 2007 +.Dd May 27, 2009 .Os .Dt KILLALL 1 .Sh NAME @@ -34,7 +34,7 @@ .Nm .Op Fl delmsvz .Op Fl help -.Op Fl j Ar jid +.Op Fl j Ar jail .Op Fl u Ar user .Op Fl t Ar tty .Op Fl c Ar procname @@ -91,9 +91,9 @@ The signal may be specified either as a name (with or without a leading .Dq Li SIG ) , or numerically. -.It Fl j Ar jid -Kill processes in the jail specified by -.Ar jid . +.It Fl j Ar jail +Kill processes in the specified +.Ar jail . .It Fl u Ar user Limit potentially matching processes to those belonging to the specified diff --git a/usr.bin/killall/killall.c b/usr.bin/killall/killall.c index 8e84572..ffb6ee4 100644 --- a/usr.bin/killall/killall.c +++ b/usr.bin/killall/killall.c @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/jail.h> #include <sys/stat.h> +#include <sys/uio.h> #include <sys/user.h> #include <sys/sysctl.h> #include <fcntl.h> @@ -51,7 +52,7 @@ static void __dead2 usage(void) { - fprintf(stderr, "usage: killall [-delmsvz] [-help] [-j jid]\n"); + fprintf(stderr, "usage: killall [-delmsvz] [-help] [-j jail]\n"); fprintf(stderr, " [-u user] [-t tty] [-c cmd] [-SIGNAL] [cmd]...\n"); fprintf(stderr, "At least one option or argument to specify processes must be given.\n"); @@ -100,6 +101,7 @@ nosig(char *name) int main(int ac, char **av) { + struct iovec jparams[2]; struct kinfo_proc *procs = NULL, *newprocs; struct stat sb; struct passwd *pw; @@ -159,12 +161,21 @@ main(int ac, char **av) } jflag++; if (*av == NULL) - errx(1, "must specify jid"); - jid = strtol(*av, &ep, 10); - if (!*av || *ep) - errx(1, "illegal jid: %s", *av); + errx(1, "must specify jail"); + jid = strtoul(*av, &ep, 10); + if (!**av || *ep) { + *(const void **)&jparams[0].iov_base = + "name"; + jparams[0].iov_len = sizeof("name"); + jparams[1].iov_base = *av; + jparams[1].iov_len = strlen(*av) + 1; + jid = jail_get(jparams, 2, 0); + if (jid < 0) + errx(1, "unknown jail: %s", + *av); + } if (jail_attach(jid) == -1) - err(1, "jail_attach(): %d", jid); + err(1, "jail_attach(%d)", jid); break; case 'u': ++*av; |