Gentoo Archives: gentoo-commits

From: Patrice Clement <monsieurp@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-process/iotop/files/, sys-process/iotop/
Date: Thu, 28 Feb 2019 22:49:50
Message-Id: 1551394173.03b1702e2d96eb257c30e2b59addf644e55469f8.monsieurp@gentoo
1 commit: 03b1702e2d96eb257c30e2b59addf644e55469f8
2 Author: Emil Lundmark <lndmrk <AT> chromium <DOT> org>
3 AuthorDate: Thu Dec 20 16:59:05 2018 +0000
4 Commit: Patrice Clement <monsieurp <AT> gentoo <DOT> org>
5 CommitDate: Thu Feb 28 22:49:33 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=03b1702e
7
8 sys-process/iotop: fix parse_proc_pid_status().
9
10 iotop does not work on kernels that populate /proc/*/status either with
11 empty lines or lines containing spaces after the : character. These
12 patches from the upstream iotop project fixes the parsing of status.
13
14 Signed-off-by: Emil Lundmark <lndmrk <AT> chromium.org>
15 Closes: https://github.com/gentoo/gentoo/pull/11157
16 Signed-off-by: Patrice Clement <monsieurp <AT> gentoo.org>
17
18 ...ctually-skip-invalid-lines-in-proc-status.patch | 26 +++++++++
19 ...Ignore-invalid-lines-in-proc-status-files.patch | 64 ++++++++++++++++++++++
20 ...-split-proc-status-lines-on-the-character.patch | 31 +++++++++++
21 sys-process/iotop/iotop-0.6.ebuild | 7 ++-
22 4 files changed, 127 insertions(+), 1 deletion(-)
23
24 diff --git a/sys-process/iotop/files/iotop-0.6-Actually-skip-invalid-lines-in-proc-status.patch b/sys-process/iotop/files/iotop-0.6-Actually-skip-invalid-lines-in-proc-status.patch
25 new file mode 100644
26 index 00000000000..9dc89bfb6f3
27 --- /dev/null
28 +++ b/sys-process/iotop/files/iotop-0.6-Actually-skip-invalid-lines-in-proc-status.patch
29 @@ -0,0 +1,26 @@
30 +From 7c51ce0e29bd135c216f18e18f0c4ab769af0d6f Mon Sep 17 00:00:00 2001
31 +From: Paul Wise <pabs3@×××××××××.net>
32 +Date: Fri, 25 May 2018 15:20:44 +0800
33 +Subject: [PATCH 2/2] Actually skip invalid lines in /proc/*/status
34 +
35 +Fixes: commit 0392b205b5c3973a326721c2e9f97f0fa2eefa82
36 +---
37 + iotop/data.py | 2 +-
38 + 1 file changed, 1 insertion(+), 1 deletion(-)
39 +
40 +diff --git a/iotop/data.py b/iotop/data.py
41 +index e0387f0..3874974 100644
42 +--- a/iotop/data.py
43 ++++ b/iotop/data.py
44 +@@ -214,7 +214,7 @@ def parse_proc_pid_status(pid):
45 + # Ignore lines that are not formatted correctly as
46 + # some downstream kernels may have weird lines and
47 + # the needed fields are probably formatted correctly.
48 +- pass
49 ++ continue
50 + result_dict[key] = value.strip()
51 + except IOError:
52 + pass # No such process
53 +--
54 +2.20.1.97.g81188d93c3-goog
55 +
56
57 diff --git a/sys-process/iotop/files/iotop-0.6-Ignore-invalid-lines-in-proc-status-files.patch b/sys-process/iotop/files/iotop-0.6-Ignore-invalid-lines-in-proc-status-files.patch
58 new file mode 100644
59 index 00000000000..df46caf4ce1
60 --- /dev/null
61 +++ b/sys-process/iotop/files/iotop-0.6-Ignore-invalid-lines-in-proc-status-files.patch
62 @@ -0,0 +1,64 @@
63 +From 0392b205b5c3973a326721c2e9f97f0fa2eefa82 Mon Sep 17 00:00:00 2001
64 +From: Paul Wise <pabs3@×××××××××.net>
65 +Date: Fri, 25 May 2018 15:13:26 +0800
66 +Subject: [PATCH 1/2] Ignore invalid lines in /proc/*/status files
67 +
68 +One Ubuntu Linux kernel security fix introduced a blank line.
69 +Some other Linux kernels may have invalid lines in the future.
70 +
71 +See-also: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1772671
72 +Fixes: https://bugs.launchpad.net/ubuntu/+source/iotop/+bug/1772856
73 +Reported-by: Paul Jaros <jaros.paul@×××××.com>
74 +Reported-in: <CAEh_nc0_DXTmfu16PxmVyrCi6QQeSrpnGGhtfNu60wJYfa_6Zw@××××××××××.com>
75 +Traceback (most recent call last):
76 + File "/usr/sbin/iotop", line 17, in <module>
77 + main()
78 + File "/usr/lib/python2.7/dist-packages/iotop/ui.py", line 620, in main
79 + main_loop()
80 + File "/usr/lib/python2.7/dist-packages/iotop/ui.py", line 610, in <lambda>
81 + main_loop = lambda: run_iotop(options)
82 + File "/usr/lib/python2.7/dist-packages/iotop/ui.py", line 508, in run_iotop
83 + return curses.wrapper(run_iotop_window, options)
84 + File "/usr/lib/python2.7/curses/wrapper.py", line 43, in wrapper
85 + return func(stdscr, *args, **kwds)
86 + File "/usr/lib/python2.7/dist-packages/iotop/ui.py", line 501, in run_iotop_window
87 + ui.run()
88 + File "/usr/lib/python2.7/dist-packages/iotop/ui.py", line 155, in run
89 + self.process_list.duration)
90 + File "/usr/lib/python2.7/dist-packages/iotop/ui.py", line 434, in refresh_display
91 + lines = self.get_data()
92 + File "/usr/lib/python2.7/dist-packages/iotop/ui.py", line 415, in get_data
93 + return list(map(format, processes))
94 + File "/usr/lib/python2.7/dist-packages/iotop/ui.py", line 388, in format
95 + cmdline = p.get_cmdline()
96 + File "/usr/lib/python2.7/dist-packages/iotop/data.py", line 292, in get_cmdline
97 + proc_status = parse_proc_pid_status(self.pid)
98 + File "/usr/lib/python2.7/dist-packages/iotop/data.py", line 196, in parse_proc_pid_status
99 + key, value = line.split(':\t', 1)
100 +ValueError: need more than 1 value to unpack
101 +---
102 + iotop/data.py | 8 +++++++-
103 + 1 file changed, 7 insertions(+), 1 deletion(-)
104 +
105 +diff --git a/iotop/data.py b/iotop/data.py
106 +index 115bb8f..e0387f0 100644
107 +--- a/iotop/data.py
108 ++++ b/iotop/data.py
109 +@@ -208,7 +208,13 @@ def parse_proc_pid_status(pid):
110 + result_dict = {}
111 + try:
112 + for line in open('/proc/%d/status' % pid):
113 +- key, value = line.split(':', 1)
114 ++ try:
115 ++ key, value = line.split(':', 1)
116 ++ except ValueError:
117 ++ # Ignore lines that are not formatted correctly as
118 ++ # some downstream kernels may have weird lines and
119 ++ # the needed fields are probably formatted correctly.
120 ++ pass
121 + result_dict[key] = value.strip()
122 + except IOError:
123 + pass # No such process
124 +--
125 +2.20.1.97.g81188d93c3-goog
126 +
127
128 diff --git a/sys-process/iotop/files/iotop-0.6-Only-split-proc-status-lines-on-the-character.patch b/sys-process/iotop/files/iotop-0.6-Only-split-proc-status-lines-on-the-character.patch
129 new file mode 100644
130 index 00000000000..ae8540f9da9
131 --- /dev/null
132 +++ b/sys-process/iotop/files/iotop-0.6-Only-split-proc-status-lines-on-the-character.patch
133 @@ -0,0 +1,31 @@
134 +From 7814f30a5ed65acd07f284bba991ca557788ee80 Mon Sep 17 00:00:00 2001
135 +From: Paul Wise <pabs3@×××××××××.net>
136 +Date: Thu, 28 Jul 2016 13:25:54 +0800
137 +Subject: [PATCH] Only split /proc/*/status lines on the : character.
138 +
139 +Apparently vserver kernels have some lines that don't
140 +appear to have the tab character so iotop crashes.
141 +
142 +The tab character will be stripped by the next code line.
143 +
144 +Closes: https://bugs.gentoo.org/show_bug.cgi?id=458556
145 +---
146 + iotop/data.py | 2 +-
147 + 1 file changed, 1 insertion(+), 1 deletion(-)
148 +
149 +diff --git a/iotop/data.py b/iotop/data.py
150 +index c4e961e..d18ca9d 100644
151 +--- a/iotop/data.py
152 ++++ b/iotop/data.py
153 +@@ -197,7 +197,7 @@ def parse_proc_pid_status(pid):
154 + result_dict = {}
155 + try:
156 + for line in open('/proc/%d/status' % pid):
157 +- key, value = line.split(':\t', 1)
158 ++ key, value = line.split(':', 1)
159 + result_dict[key] = value.strip()
160 + except IOError:
161 + pass # No such process
162 +--
163 +2.20.1.97.g81188d93c3-goog
164 +
165
166 diff --git a/sys-process/iotop/iotop-0.6.ebuild b/sys-process/iotop/iotop-0.6.ebuild
167 index 3faec2aa451..01dc5a097ef 100644
168 --- a/sys-process/iotop/iotop-0.6.ebuild
169 +++ b/sys-process/iotop/iotop-0.6.ebuild
170 @@ -21,7 +21,12 @@ CONFIG_CHECK="~TASK_IO_ACCOUNTING ~TASK_DELAY_ACCT ~TASKSTATS ~VM_EVENT_COUNTERS
171
172 DOCS=( NEWS README THANKS ChangeLog )
173
174 -PATCHES=( "${FILESDIR}"/${P}-setup.py3.patch )
175 +PATCHES=(
176 + "${FILESDIR}"/${P}-setup.py3.patch
177 + "${FILESDIR}"/${P}-Only-split-proc-status-lines-on-the-character.patch
178 + "${FILESDIR}"/${P}-Ignore-invalid-lines-in-proc-status-files.patch
179 + "${FILESDIR}"/${P}-Actually-skip-invalid-lines-in-proc-status.patch
180 +)
181
182 pkg_setup() {
183 linux-info_pkg_setup