summaryrefslogtreecommitdiffstats
path: root/bin/pkill/pkill.c
diff options
context:
space:
mode:
Diffstat (limited to 'bin/pkill/pkill.c')
-rw-r--r--bin/pkill/pkill.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/bin/pkill/pkill.c b/bin/pkill/pkill.c
index add989f..a15620a 100644
--- a/bin/pkill/pkill.c
+++ b/bin/pkill/pkill.c
@@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
#include <grp.h>
#include <errno.h>
#include <locale.h>
+#include <jail.h>
#define STATUS_MATCH 0
#define STATUS_NOMATCH 1
@@ -78,7 +79,7 @@ enum listtype {
LT_GROUP,
LT_TTY,
LT_PGRP,
- LT_JID,
+ LT_JAIL,
LT_SID,
LT_CLASS
};
@@ -245,7 +246,7 @@ main(int argc, char **argv)
cflags |= REG_ICASE;
break;
case 'j':
- makelist(&jidlist, LT_JID, optarg);
+ makelist(&jidlist, LT_JAIL, optarg);
criteria = 1;
break;
case 'l':
@@ -582,7 +583,7 @@ usage(void)
fprintf(stderr,
"usage: %s %s [-F pidfile] [-G gid] [-M core] [-N system]\n"
- " [-P ppid] [-U uid] [-c class] [-g pgrp] [-j jid]\n"
+ " [-P ppid] [-U uid] [-c class] [-g pgrp] [-j jail]\n"
" [-s sid] [-t tty] [-u euid] pattern ...\n",
getprogname(), ustr);
@@ -697,7 +698,7 @@ makelist(struct listhead *head, enum listtype type, char *src)
if (li->li_number == 0)
li->li_number = getsid(mypid);
break;
- case LT_JID:
+ case LT_JAIL:
if (li->li_number < 0)
errx(STATUS_BADUSAGE,
"Negative jail ID `%s'", sp);
@@ -763,15 +764,20 @@ foundtty: if ((st.st_mode & S_IFCHR) == 0)
li->li_number = st.st_rdev;
break;
- case LT_JID:
+ case LT_JAIL: {
+ int jid;
+
if (strcmp(sp, "none") == 0)
li->li_number = 0;
else if (strcmp(sp, "any") == 0)
li->li_number = -1;
+ else if ((jid = jail_getid(sp)) != -1)
+ li->li_number = jid;
else if (*ep != '\0')
errx(STATUS_BADUSAGE,
- "Invalid jail ID `%s'", sp);
+ "Invalid jail ID or name `%s'", sp);
break;
+ }
case LT_CLASS:
li->li_number = -1;
li->li_name = strdup(sp);
OpenPOWER on IntegriCloud