aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMike Barcroft <mike@FreeBSD.org>2003-04-09 03:04:12 +0000
committerMike Barcroft <mike@FreeBSD.org>2003-04-09 03:04:12 +0000
commitebf5d9bc2cad900f20b385a671e82ecaad28b3c7 (patch)
tree058bbdc564bcc891a28e1adb5f67a45e806274e2 /usr.bin
parent94d079eb1f423d46f2c44b51874b415ebff15fc8 (diff)
downloadsrc-ebf5d9bc2cad900f20b385a671e82ecaad28b3c7.tar.gz
src-ebf5d9bc2cad900f20b385a671e82ecaad28b3c7.zip
o Add jls(8) for listing active jails.
o Add jexec(8) to execute a command in an existing jail. o Add -j option for killall(1) to kill all processes in a specified jail. o Add -i option to jail(8) to output jail ID of newly created jail.
Notes
Notes: svn path=/head/; revision=113277
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/killall/killall.19
-rw-r--r--usr.bin/killall/killall.c23
2 files changed, 28 insertions, 4 deletions
diff --git a/usr.bin/killall/killall.1 b/usr.bin/killall/killall.1
index 9c81346d12e7..3614e3fd5a45 100644
--- a/usr.bin/killall/killall.1
+++ b/usr.bin/killall/killall.1
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd June 25, 1995
+.Dd April 8, 2003
.Os
.Dt KILLALL 1
.Sh NAME
@@ -39,6 +39,7 @@
.Op Fl m
.Op Fl s
.Op Fl z
+.Op Fl j Ar jid
.Op Fl u Ar user
.Op Fl t Ar tty
.Op Fl c Ar procname
@@ -89,6 +90,9 @@ The signal may be specified either as a name
(with or without a leading
.Dv SIG ) ,
or numerically.
+.It Fl j Ar jid
+Kill processes in the jail specified by
+.Ar jid .
.It Fl u Ar user
Limit potentially matching processes to those belonging to
the specified
@@ -133,7 +137,8 @@ Diagnostic messages will only be printed if requested by
options.
.Sh SEE ALSO
.Xr kill 1 ,
-.Xr sysctl 3
+.Xr sysctl 3 ,
+.Xr jail 8
.Sh HISTORY
The
.Nm
diff --git a/usr.bin/killall/killall.c b/usr.bin/killall/killall.c
index b1fcc25cf068..4c2b06ad307f 100644
--- a/usr.bin/killall/killall.c
+++ b/usr.bin/killall/killall.c
@@ -29,6 +29,7 @@
__FBSDID("$FreeBSD$");
#include <sys/param.h>
+#include <sys/jail.h>
#include <sys/stat.h>
#include <sys/user.h>
#include <sys/sysctl.h>
@@ -49,7 +50,9 @@ static void __dead2
usage(void)
{
- fprintf(stderr, "usage: killall [-l] [-v] [-m] [-sig] [-u user] [-t tty] [-c cmd] [cmd]...\n");
+ fprintf(stderr, "usage: killall [-l] [-v] [-m] [-sig] [-j jid]\n");
+ fprintf(stderr,
+ " [-u user] [-t tty] [-c cmd] [cmd]...\n");
fprintf(stderr, "At least one option or argument to specify processes must be given.\n");
exit(1);
}
@@ -110,6 +113,7 @@ main(int ac, char **av)
int vflag = 0;
int sflag = 0;
int dflag = 0;
+ int jflag = 0;
int mflag = 0;
int zflag = 0;
uid_t uid = 0;
@@ -122,6 +126,7 @@ main(int ac, char **av)
const char *const *p;
char *ep;
int errors = 0;
+ int jid;
int mib[4];
size_t miblen;
int st, nprocs;
@@ -142,6 +147,18 @@ main(int ac, char **av)
if (**av == '-') {
++*av;
switch (**av) {
+ case 'j':
+ ++*av;
+ if (**av == '\0')
+ ++av;
+ --ac;
+ jflag++;
+ jid = strtol(*av, &ep, 10);
+ if (!*av || *ep)
+ errx(1, "illegal jid: %s", *av);
+ if (jail_attach(jid) == -1)
+ err(1, "jail_attach(): %d", jid);
+ break;
case 'u':
++*av;
if (**av == '\0')
@@ -206,7 +223,7 @@ main(int ac, char **av)
}
}
- if (user == NULL && tty == NULL && cmd == NULL && ac == 0)
+ if (user == NULL && tty == NULL && cmd == NULL && !jflag && ac == 0)
usage();
if (tty) {
@@ -324,6 +341,8 @@ main(int ac, char **av)
matched = 0;
}
}
+ if (jflag && thispid == getpid())
+ matched = 0;
if (matched == 0)
continue;
if (ac > 0)