Gentoo Archives: gentoo-commits

From: Lars Wendler <polynomial-c@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-process/psmisc/files/, sys-process/psmisc/
Date: Thu, 14 Mar 2019 14:16:20
Message-Id: 1552572970.b10dc8d58e5d94e5e2d5f001171667c6cf1fa039.polynomial-c@gentoo
1 commit: b10dc8d58e5d94e5e2d5f001171667c6cf1fa039
2 Author: Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
3 AuthorDate: Thu Mar 14 14:14:59 2019 +0000
4 Commit: Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
5 CommitDate: Thu Mar 14 14:16:10 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b10dc8d5
7
8 sys-process/psmisc: Added fix for killall to work with old kernels
9
10 Package-Manager: Portage-2.3.62, Repoman-2.3.12
11 Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>
12
13 ...misc-23.2-killall_check_truncated_16_char.patch | 122 +++++++++++++++++++++
14 .../psmisc/files/psmisc-23.2-old_comm_len.patch | 28 +++++
15 sys-process/psmisc/psmisc-23.2-r2.ebuild | 56 ++++++++++
16 3 files changed, 206 insertions(+)
17
18 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
19 new file mode 100644
20 index 00000000000..bfc2a24d5de
21 --- /dev/null
22 +++ b/sys-process/psmisc/files/psmisc-23.2-killall_check_truncated_16_char.patch
23 @@ -0,0 +1,122 @@
24 +From 1188315cd037d73bf946a0003b70c6423cc330d2 Mon Sep 17 00:00:00 2001
25 +From: Craig Small <csmall@×××××××.au>
26 +Date: Wed, 7 Nov 2018 20:13:09 +1100
27 +Subject: [PATCH] killall: match on 16 character commlen too
28 +
29 +The comm length increase meant killall could accomodate the
30 +larger comm name given out by newer kernels but it meant that
31 +if a user relied on the previous 16 character truncation then
32 +processes that used to match would fail.
33 +
34 +killall now checks to see if the the comm is the old COMM_LEN
35 +length and the given name is longer than old COMM_LEN and does
36 +a truncated match as well.
37 +
38 +References:
39 + https://bugs.debian.org/912748
40 +---
41 + ChangeLog | 3 +++
42 + src/killall.c | 69 +++++++++++++++++++++++++++++++++++----------------
43 + 2 files changed, 50 insertions(+), 22 deletions(-)
44 +
45 +diff --git a/ChangeLog b/ChangeLog
46 +index 7fd2abd..37962cb 100644
47 +--- a/ChangeLog
48 ++++ b/ChangeLog
49 +@@ -1,3 +1,6 @@
50 ++Changes in 23.4
51 ++===============
52 ++ * killall: check also truncated 16 char comm names Debian #912748
53 + Changes in 23.2
54 + ===============
55 + * misc: Command names increased from 16 to 64 characters
56 +diff --git a/src/killall.c b/src/killall.c
57 +index 2715515..09212a4 100644
58 +--- a/src/killall.c
59 ++++ b/src/killall.c
60 +@@ -492,6 +492,49 @@ create_pid_table(int *max_pids, int *pids)
61 + return pid_table;
62 + }
63 +
64 ++#define strcmp2(A,B,I) (I? strcasecmp((A),(B)):strcmp((A),(B)))
65 ++#define strncmp2(A,B,L,I) (I? strncasecmp((A),(B),(L)):strncmp((A),(B),(L)))
66 ++static int match_process_name(
67 ++ const char *proc_comm,
68 ++ const int comm_len,
69 ++ const char *proc_cmdline,
70 ++ const char *match_name,
71 ++ const int match_len,
72 ++ const int got_long
73 ++ )
74 ++{
75 ++ /* process is old length but matching longer */
76 ++ if (comm_len == OLD_COMM_LEN - 1 && match_len >= OLD_COMM_LEN - 1)
77 ++ {
78 ++ if (got_long)
79 ++ {
80 ++ return (0 == strncmp2 (match_name, proc_cmdline, OLD_COMM_LEN - 1,
81 ++ ignore_case));
82 ++ } else {
83 ++ return (0 == strncmp2 (match_name, proc_comm, OLD_COMM_LEN - 1,
84 ++ ignore_case));
85 ++ }
86 ++ }
87 ++
88 ++ if (comm_len == COMM_LEN - 1 && match_len >= COMM_LEN - 1)
89 ++ {
90 ++ if (got_long)
91 ++ {
92 ++ return (0 == strncmp2 (match_name, proc_cmdline, COMM_LEN - 1,
93 ++ ignore_case));
94 ++ } else {
95 ++ return (0 == strncmp2 (match_name, proc_comm, COMM_LEN - 1,
96 ++ ignore_case));
97 ++ }
98 ++ }
99 ++ /* Not old new COMM_LEN so we match all of it */
100 ++ if (got_long)
101 ++ {
102 ++ return (0 == strcmp2 (match_name, proc_cmdline, ignore_case));
103 ++ }
104 ++ return (0 == strcmp2 (match_name, proc_comm, ignore_case));
105 ++}
106 ++
107 + #ifdef WITH_SELINUX
108 + static int
109 + kill_all(int signal, int name_count, char **namelist, struct passwd *pwent,
110 +@@ -599,28 +642,10 @@ kill_all (int signal, int name_count, char **namelist, struct passwd *pwent)
111 + {
112 + if (!name_info[j].st.st_dev)
113 + {
114 +- if (length != COMM_LEN - 1 || name_info[j].name_length < COMM_LEN - 1)
115 +- {
116 +- if (ignore_case == 1)
117 +- {
118 +- if (strcasecmp (namelist[j], comm))
119 +- continue;
120 +- } else {
121 +- if (strcmp(namelist[j], comm))
122 +- continue;
123 +- }
124 +- } else {
125 +- if (ignore_case == 1)
126 +- {
127 +- if (got_long ? strcasecmp (namelist[j], command) :
128 +- strncasecmp (namelist[j], comm, COMM_LEN - 1))
129 +- continue;
130 +- } else {
131 +- if (got_long ? strcmp (namelist[j], command) :
132 +- strncmp (namelist[j], comm, COMM_LEN - 1))
133 +- continue;
134 +- }
135 +- }
136 ++ if (!match_process_name(comm, length, command, namelist[j],
137 ++ name_info[j].name_length, got_long))
138 ++ continue;
139 ++
140 + } else {
141 + int ok = 1;
142 + if (asprintf (&path, PROC_BASE "/%d/exe", pid_table[i]) < 0)
143 +--
144 +2.18.1
145 +
146
147 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
148 new file mode 100644
149 index 00000000000..ae237e69109
150 --- /dev/null
151 +++ b/sys-process/psmisc/files/psmisc-23.2-old_comm_len.patch
152 @@ -0,0 +1,28 @@
153 +From e2cf9f3e83e0fc0278ff39a4dfc8e3f2730eebca Mon Sep 17 00:00:00 2001
154 +From: Craig Small <csmall@×××××××.au>
155 +Date: Wed, 7 Nov 2018 20:19:38 +1100
156 +Subject: [PATCH] misc: Remember to add comm.h too
157 +
158 +The previous commit should have included comm.h too
159 +---
160 + src/comm.h | 6 ++++++
161 + 1 file changed, 6 insertions(+)
162 +
163 +diff --git a/src/comm.h b/src/comm.h
164 +index b54b998..b10eb36 100644
165 +--- a/src/comm.h
166 ++++ b/src/comm.h
167 +@@ -33,4 +33,10 @@
168 + */
169 + #define COMM_LEN 64
170 +
171 ++/*
172 ++ * Older kernels had only 16 characters, which means we may have to check this
173 ++ * too
174 ++ */
175 ++#define OLD_COMM_LEN 16
176 ++
177 + #endif
178 +--
179 +2.18.1
180 +
181
182 diff --git a/sys-process/psmisc/psmisc-23.2-r2.ebuild b/sys-process/psmisc/psmisc-23.2-r2.ebuild
183 new file mode 100644
184 index 00000000000..f06137e3682
185 --- /dev/null
186 +++ b/sys-process/psmisc/psmisc-23.2-r2.ebuild
187 @@ -0,0 +1,56 @@
188 +# Copyright 1999-2019 Gentoo Authors
189 +# Distributed under the terms of the GNU General Public License v2
190 +
191 +EAPI=6
192 +
193 +DESCRIPTION="A set of tools that use the proc filesystem"
194 +HOMEPAGE="http://psmisc.sourceforge.net/"
195 +SRC_URI="mirror://sourceforge/${PN}/${P}.tar.xz"
196 +
197 +LICENSE="GPL-2"
198 +SLOT="0"
199 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-linux ~x86-linux"
200 +IUSE="ipv6 nls selinux X"
201 +
202 +RDEPEND=">=sys-libs/ncurses-5.7-r7:0=
203 + nls? ( virtual/libintl )
204 + selinux? ( sys-libs/libselinux )"
205 +DEPEND="${RDEPEND}
206 + >=sys-devel/libtool-2.2.6b
207 + nls? ( sys-devel/gettext )"
208 +
209 +DOCS=( AUTHORS ChangeLog NEWS README )
210 +
211 +PATCHES=(
212 + "${FILESDIR}/${P}-old_comm_len.patch"
213 + "${FILESDIR}/${P}-killall_check_truncated_16_char.patch"
214 +)
215 +
216 +src_configure() {
217 + local myeconfargs=(
218 + --disable-harden-flags
219 + $(use_enable ipv6)
220 + $(use_enable nls)
221 + $(use_enable selinux)
222 + )
223 + econf "${myeconfargs[@]}"
224 +}
225 +
226 +src_compile() {
227 + # peekfd is a fragile crap hack #330631
228 + nonfatal emake -C src peekfd || touch src/peekfd{.o,}
229 + emake
230 +}
231 +
232 +src_install() {
233 + default
234 +
235 + use X || rm -f "${ED%/}"/usr/bin/pstree.x11
236 +
237 + [[ -s ${ED%/}/usr/bin/peekfd ]] || rm -f "${ED%/}"/usr/bin/peekfd
238 + [[ -e ${ED%/}/usr/bin/peekfd ]] || rm -f "${ED%/}"/usr/share/man/man1/peekfd.1
239 +
240 + # fuser is needed by init.d scripts; use * wildcard for #458250
241 + dodir /bin
242 + mv "${ED%/}"/usr/bin/*fuser "${ED%/}"/bin || die
243 +}