summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wendler <polynomial-c@gentoo.org>2019-03-14 15:14:59 +0100
committerLars Wendler <polynomial-c@gentoo.org>2019-03-14 15:16:10 +0100
commitb10dc8d58e5d94e5e2d5f001171667c6cf1fa039 (patch)
treeaca1e80c3d5c06daaa2e272c7a45520b63e78c31 /sys-process/psmisc
parentgames-puzzle/five-or-more: bump to 3.30.0 (diff)
downloadgentoo-b10dc8d58e5d94e5e2d5f001171667c6cf1fa039.tar.gz
gentoo-b10dc8d58e5d94e5e2d5f001171667c6cf1fa039.tar.bz2
gentoo-b10dc8d58e5d94e5e2d5f001171667c6cf1fa039.zip
sys-process/psmisc: Added fix for killall to work with old kernels
Package-Manager: Portage-2.3.62, Repoman-2.3.12 Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
Diffstat (limited to 'sys-process/psmisc')
-rw-r--r--sys-process/psmisc/files/psmisc-23.2-killall_check_truncated_16_char.patch122
-rw-r--r--sys-process/psmisc/files/psmisc-23.2-old_comm_len.patch28
-rw-r--r--sys-process/psmisc/psmisc-23.2-r2.ebuild56
3 files changed, 206 insertions, 0 deletions
diff --git a/sys-process/psmisc/files/psmisc-23.2-killall_check_truncated_16_char.patch b/sys-process/psmisc/files/psmisc-23.2-killall_check_truncated_16_char.patch
new file mode 100644
index 000000000000..bfc2a24d5de9
--- /dev/null
+++ b/sys-process/psmisc/files/psmisc-23.2-killall_check_truncated_16_char.patch
@@ -0,0 +1,122 @@
+From 1188315cd037d73bf946a0003b70c6423cc330d2 Mon Sep 17 00:00:00 2001
+From: Craig Small <csmall@enc.com.au>
+Date: Wed, 7 Nov 2018 20:13:09 +1100
+Subject: [PATCH] killall: match on 16 character commlen too
+
+The comm length increase meant killall could accomodate the
+larger comm name given out by newer kernels but it meant that
+if a user relied on the previous 16 character truncation then
+processes that used to match would fail.
+
+killall now checks to see if the the comm is the old COMM_LEN
+length and the given name is longer than old COMM_LEN and does
+a truncated match as well.
+
+References:
+ https://bugs.debian.org/912748
+---
+ ChangeLog | 3 +++
+ src/killall.c | 69 +++++++++++++++++++++++++++++++++++----------------
+ 2 files changed, 50 insertions(+), 22 deletions(-)
+
+diff --git a/ChangeLog b/ChangeLog
+index 7fd2abd..37962cb 100644
+--- a/ChangeLog
++++ b/ChangeLog
+@@ -1,3 +1,6 @@
++Changes in 23.4
++===============
++ * killall: check also truncated 16 char comm names Debian #912748
+ Changes in 23.2
+ ===============
+ * misc: Command names increased from 16 to 64 characters
+diff --git a/src/killall.c b/src/killall.c
+index 2715515..09212a4 100644
+--- a/src/killall.c
++++ b/src/killall.c
+@@ -492,6 +492,49 @@ create_pid_table(int *max_pids, int *pids)
+ return pid_table;
+ }
+
++#define strcmp2(A,B,I) (I? strcasecmp((A),(B)):strcmp((A),(B)))
++#define strncmp2(A,B,L,I) (I? strncasecmp((A),(B),(L)):strncmp((A),(B),(L)))
++static int match_process_name(
++ const char *proc_comm,
++ const int comm_len,
++ const char *proc_cmdline,
++ const char *match_name,
++ const int match_len,
++ const int got_long
++ )
++{
++ /* process is old length but matching longer */
++ if (comm_len == OLD_COMM_LEN - 1 && match_len >= OLD_COMM_LEN - 1)
++ {
++ if (got_long)
++ {
++ return (0 == strncmp2 (match_name, proc_cmdline, OLD_COMM_LEN - 1,
++ ignore_case));
++ } else {
++ return (0 == strncmp2 (match_name, proc_comm, OLD_COMM_LEN - 1,
++ ignore_case));
++ }
++ }
++
++ if (comm_len == COMM_LEN - 1 && match_len >= COMM_LEN - 1)
++ {
++ if (got_long)
++ {
++ return (0 == strncmp2 (match_name, proc_cmdline, COMM_LEN - 1,
++ ignore_case));
++ } else {
++ return (0 == strncmp2 (match_name, proc_comm, COMM_LEN - 1,
++ ignore_case));
++ }
++ }
++ /* Not old new COMM_LEN so we match all of it */
++ if (got_long)
++ {
++ return (0 == strcmp2 (match_name, proc_cmdline, ignore_case));
++ }
++ return (0 == strcmp2 (match_name, proc_comm, ignore_case));
++}
++
+ #ifdef WITH_SELINUX
+ static int
+ kill_all(int signal, int name_count, char **namelist, struct passwd *pwent,
+@@ -599,28 +642,10 @@ kill_all (int signal, int name_count, char **namelist, struct passwd *pwent)
+ {
+ if (!name_info[j].st.st_dev)
+ {
+- if (length != COMM_LEN - 1 || name_info[j].name_length < COMM_LEN - 1)
+- {
+- if (ignore_case == 1)
+- {
+- if (strcasecmp (namelist[j], comm))
+- continue;
+- } else {
+- if (strcmp(namelist[j], comm))
+- continue;
+- }
+- } else {
+- if (ignore_case == 1)
+- {
+- if (got_long ? strcasecmp (namelist[j], command) :
+- strncasecmp (namelist[j], comm, COMM_LEN - 1))
+- continue;
+- } else {
+- if (got_long ? strcmp (namelist[j], command) :
+- strncmp (namelist[j], comm, COMM_LEN - 1))
+- continue;
+- }
+- }
++ if (!match_process_name(comm, length, command, namelist[j],
++ name_info[j].name_length, got_long))
++ continue;
++
+ } else {
+ int ok = 1;
+ if (asprintf (&path, PROC_BASE "/%d/exe", pid_table[i]) < 0)
+--
+2.18.1
+
diff --git a/sys-process/psmisc/files/psmisc-23.2-old_comm_len.patch b/sys-process/psmisc/files/psmisc-23.2-old_comm_len.patch
new file mode 100644
index 000000000000..ae237e691099
--- /dev/null
+++ b/sys-process/psmisc/files/psmisc-23.2-old_comm_len.patch
@@ -0,0 +1,28 @@
+From e2cf9f3e83e0fc0278ff39a4dfc8e3f2730eebca Mon Sep 17 00:00:00 2001
+From: Craig Small <csmall@enc.com.au>
+Date: Wed, 7 Nov 2018 20:19:38 +1100
+Subject: [PATCH] misc: Remember to add comm.h too
+
+The previous commit should have included comm.h too
+---
+ src/comm.h | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/src/comm.h b/src/comm.h
+index b54b998..b10eb36 100644
+--- a/src/comm.h
++++ b/src/comm.h
+@@ -33,4 +33,10 @@
+ */
+ #define COMM_LEN 64
+
++/*
++ * Older kernels had only 16 characters, which means we may have to check this
++ * too
++ */
++#define OLD_COMM_LEN 16
++
+ #endif
+--
+2.18.1
+
diff --git a/sys-process/psmisc/psmisc-23.2-r2.ebuild b/sys-process/psmisc/psmisc-23.2-r2.ebuild
new file mode 100644
index 000000000000..f06137e3682d
--- /dev/null
+++ b/sys-process/psmisc/psmisc-23.2-r2.ebuild
@@ -0,0 +1,56 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+DESCRIPTION="A set of tools that use the proc filesystem"
+HOMEPAGE="http://psmisc.sourceforge.net/"
+SRC_URI="mirror://sourceforge/${PN}/${P}.tar.xz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-linux ~x86-linux"
+IUSE="ipv6 nls selinux X"
+
+RDEPEND=">=sys-libs/ncurses-5.7-r7:0=
+ nls? ( virtual/libintl )
+ selinux? ( sys-libs/libselinux )"
+DEPEND="${RDEPEND}
+ >=sys-devel/libtool-2.2.6b
+ nls? ( sys-devel/gettext )"
+
+DOCS=( AUTHORS ChangeLog NEWS README )
+
+PATCHES=(
+ "${FILESDIR}/${P}-old_comm_len.patch"
+ "${FILESDIR}/${P}-killall_check_truncated_16_char.patch"
+)
+
+src_configure() {
+ local myeconfargs=(
+ --disable-harden-flags
+ $(use_enable ipv6)
+ $(use_enable nls)
+ $(use_enable selinux)
+ )
+ econf "${myeconfargs[@]}"
+}
+
+src_compile() {
+ # peekfd is a fragile crap hack #330631
+ nonfatal emake -C src peekfd || touch src/peekfd{.o,}
+ emake
+}
+
+src_install() {
+ default
+
+ use X || rm -f "${ED%/}"/usr/bin/pstree.x11
+
+ [[ -s ${ED%/}/usr/bin/peekfd ]] || rm -f "${ED%/}"/usr/bin/peekfd
+ [[ -e ${ED%/}/usr/bin/peekfd ]] || rm -f "${ED%/}"/usr/share/man/man1/peekfd.1
+
+ # fuser is needed by init.d scripts; use * wildcard for #458250
+ dodir /bin
+ mv "${ED%/}"/usr/bin/*fuser "${ED%/}"/bin || die
+}