[Midnightbsd-cvs] src [11189] sync with freebsd

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sat Jun 30 20:21:10 EDT 2018


Revision: 11189
          http://svnweb.midnightbsd.org/src/?rev=11189
Author:   laffer1
Date:     2018-06-30 20:21:10 -0400 (Sat, 30 Jun 2018)
Log Message:
-----------
sync with freebsd

Modified Paths:
--------------
    trunk/bin/pkill/pkill.1
    trunk/bin/pkill/pkill.c

Property Changed:
----------------
    trunk/bin/pkill/pkill.1

Modified: trunk/bin/pkill/pkill.1
===================================================================
--- trunk/bin/pkill/pkill.1	2018-06-30 23:45:13 UTC (rev 11188)
+++ trunk/bin/pkill/pkill.1	2018-07-01 00:21:10 UTC (rev 11189)
@@ -1,7 +1,7 @@
+.\" $MidnightBSD$
 .\"	$NetBSD: pkill.1,v 1.8 2003/02/14 15:59:18 grant Exp $
 .\"
-.\" $FreeBSD: src/usr.bin/pkill/pkill.1,v 1.22 2006/12/20 11:57:22 ru Exp $
-.\" $MidnightBSD: src/bin/pkill/pkill.1,v 1.1 2009/03/27 22:04:42 laffer1 Exp $
+.\" $FreeBSD: stable/10/bin/pkill/pkill.1 307403 2016-10-16 22:02:50Z sevan $
 .\"
 .\" Copyright (c) 2002 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -30,7 +30,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd February 11, 2010
+.Dd August 21, 2015
 .Dt PKILL 1
 .Os
 .Sh NAME
@@ -45,9 +45,10 @@
 .Op Fl N Ar system
 .Op Fl P Ar ppid
 .Op Fl U Ar uid
+.Op Fl c Ar class
 .Op Fl d Ar delim
 .Op Fl g Ar pgrp
-.Op Fl j Ar jid
+.Op Fl j Ar jail
 .Op Fl s Ar sid
 .Op Fl t Ar tty
 .Op Fl u Ar euid
@@ -61,8 +62,9 @@
 .Op Fl N Ar system
 .Op Fl P Ar ppid
 .Op Fl U Ar uid
+.Op Fl c Ar class
 .Op Fl g Ar pgrp
-.Op Fl j Ar jid
+.Op Fl j Ar jail
 .Op Fl s Ar sid
 .Op Fl t Ar tty
 .Op Fl u Ar euid
@@ -131,6 +133,9 @@
 process and all of its ancestors are excluded (unless
 .Fl v
 is used).
+.It Fl c Ar class
+Restrict matches to processes running with specified login class
+.Ar class .
 .It Fl f
 Match against full argument lists.
 The default is to match against process names.
@@ -145,16 +150,16 @@
 command.
 .It Fl i
 Ignore case distinctions in both the process table and the supplied pattern.
-.It Fl j Ar jid
-Restrict matches to processes inside jails with a jail ID in the comma-separated
-list
-.Ar jid .
-The value
+.It Fl j Ar jail
+Restrict matches to processes inside the specified jails.
+The argument
+.Ar jail
+may be
 .Dq Li any
-matches processes in any jail.
-The value
+to match processes in any jail,
 .Dq Li none
-matches processes not in jail.
+to match processes not in jail,
+or a comma-separated list of jail IDs or names.
 .It Fl l
 Long output.
 For
@@ -287,5 +292,4 @@
 They made their first appearance in
 .Fx 5.3 .
 .Sh AUTHORS
-.An Andrew Doran
-.Aq ad at NetBSD.org
+.An Andrew Doran Aq Mt ad at NetBSD.org


Property changes on: trunk/bin/pkill/pkill.1
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/bin/pkill/pkill.c
===================================================================
--- trunk/bin/pkill/pkill.c	2018-06-30 23:45:13 UTC (rev 11188)
+++ trunk/bin/pkill/pkill.c	2018-07-01 00:21:10 UTC (rev 11189)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
 /*	$NetBSD: pkill.c,v 1.16 2005/10/10 22:13:20 kleink Exp $	*/
-/* $MidnightBSD: src/bin/pkill/pkill.c,v 1.1 2009/03/27 22:04:42 laffer1 Exp $ */
+
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
  * Copyright (c) 2005 Pawel Jakub Dawidek <pjd at FreeBSD.org>
@@ -31,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/pkill/pkill.c,v 1.31 2006/11/23 11:55:17 yar Exp $");
+__FBSDID("$FreeBSD: stable/10/bin/pkill/pkill.c 287269 2015-08-29 02:41:59Z jamie $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -59,6 +60,7 @@
 #include <grp.h>
 #include <errno.h>
 #include <locale.h>
+#include <jail.h>
 
 #define	STATUS_MATCH	0
 #define	STATUS_NOMATCH	1
@@ -78,13 +80,15 @@
 	LT_GROUP,
 	LT_TTY,
 	LT_PGRP,
-	LT_JID,
-	LT_SID
+	LT_JAIL,
+	LT_SID,
+	LT_CLASS
 };
 
 struct list {
 	SLIST_ENTRY(list) li_chain;
 	long	li_number;
+	char	*li_name;
 };
 
 SLIST_HEAD(listhead, list);
@@ -116,6 +120,7 @@
 static struct listhead tdevlist = SLIST_HEAD_INITIALIZER(tdevlist);
 static struct listhead sidlist = SLIST_HEAD_INITIALIZER(sidlist);
 static struct listhead jidlist = SLIST_HEAD_INITIALIZER(jidlist);
+static struct listhead classlist = SLIST_HEAD_INITIALIZER(classlist);
 
 static void	usage(void) __attribute__((__noreturn__));
 static int	killact(const struct kinfo_proc *);
@@ -179,7 +184,7 @@
 	execf = NULL;
 	coref = _PATH_DEVNULL;
 
-	while ((ch = getopt(argc, argv, "DF:G:ILM:N:P:SU:ad:fg:ij:lnoqs:t:u:vx")) != -1)
+	while ((ch = getopt(argc, argv, "DF:G:ILM:N:P:SU:ac:d:fg:ij:lnoqs:t:u:vx")) != -1)
 		switch (ch) {
 		case 'D':
 			debug_opt++;
@@ -222,6 +227,10 @@
 		case 'a':
 			ancestors++;
 			break;
+		case 'c':
+			makelist(&classlist, LT_CLASS, optarg);
+			criteria = 1;
+			break;
 		case 'd':
 			if (!pgrep)
 				usage();
@@ -238,7 +247,7 @@
 			cflags |= REG_ICASE;
 			break;
 		case 'j':
-			makelist(&jidlist, LT_JID, optarg);
+			makelist(&jidlist, LT_JAIL, optarg);
 			criteria = 1;
 			break;
 		case 'l':
@@ -469,6 +478,19 @@
 			continue;
 		}
 
+		SLIST_FOREACH(li, &classlist, li_chain) {
+			/*
+			 * We skip P_SYSTEM processes to match ps(1) output.
+			 */
+			if ((kp->ki_flag & P_SYSTEM) == 0 &&
+			    strcmp(kp->ki_loginclass, li->li_name) == 0)
+				break;
+		}
+		if (SLIST_FIRST(&classlist) != NULL && li == NULL) {
+			selected[i] = 0;
+			continue;
+		}
+
 		if (argc == 0)
 			selected[i] = 1;
 	}
@@ -562,9 +584,9 @@
 
 	fprintf(stderr,
 		"usage: %s %s [-F pidfile] [-G gid] [-M core] [-N system]\n"
-		"             [-P ppid] [-U uid] [-g pgrp] [-j jid] [-s sid]\n"
-		"             [-t tty] [-u euid] pattern ...\n", getprogname(),
-		ustr);
+		"             [-P ppid] [-U uid] [-c class] [-g pgrp] [-j jail]\n"
+		"             [-s sid] [-t tty] [-u euid] pattern ...\n",
+		getprogname(), ustr);
 
 	exit(STATUS_BADUSAGE);
 }
@@ -664,8 +686,10 @@
 		SLIST_INSERT_HEAD(head, li, li_chain);
 		empty = 0;
 
-		li->li_number = (uid_t)strtol(sp, &ep, 0);
-		if (*ep == '\0') {
+		if (type != LT_CLASS)
+			li->li_number = (uid_t)strtol(sp, &ep, 0);
+
+		if (type != LT_CLASS && *ep == '\0') {
 			switch (type) {
 			case LT_PGRP:
 				if (li->li_number == 0)
@@ -675,7 +699,7 @@
 				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);
@@ -741,15 +765,26 @@
 
 			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);
+			if (li->li_name == NULL)
+				err(STATUS_ERROR, "Cannot allocate memory");
+			break;
 		default:
 			usage();
 		}



More information about the Midnightbsd-cvs mailing list