Compare commits

..

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
f466b48de0
!43 1216 - give credit to @hexaclock
From: @zhang-liang-pengkun 
Reviewed-by: @Charlie_li 
Signed-off-by: @Charlie_li
2024-01-15 11:11:00 +00:00
zhang-liang-pengkun
d531246e47 1216 - give credit to @hexaclock
Signed-off-by: zhang-liang-pengkun <zhangliangpengkun@xfusion.com>
2024-01-12 17:52:17 +08:00
openeuler-ci-bot
f3db2257bb
!40 fix compatibility with python 2.6.x (#1216)
From: @zhang-liang-pengkun 
Reviewed-by: @Charlie_li 
Signed-off-by: @Charlie_li
2023-12-28 09:43:49 +00:00
zhang-liang-pengkun
7c336a95b7 fix compatibility with python 2.6.x (#1216)
Signed-off-by: zhang-liang-pengkun <zhangliangpengkun@xfusion.com>
2023-12-27 17:39:50 +08:00
openeuler-ci-bot
15c86d559d
!36 Pass python_requires argument to setuptools
From: @zhang-liang-pengkun 
Reviewed-by: @Charlie_li 
Signed-off-by: @Charlie_li
2023-12-25 08:39:33 +00:00
zhang-liang-pengkun
2a07055558 Pass python_requires argument to setuptools
Signed-off-by: zhang-liang-pengkun <zhangliangpengkun@xfusion.com>
2023-12-21 18:06:35 +08:00
openeuler-ci-bot
93d96cb022
!28 Fix Linuxdisk io counters fails on Linux kernel
From: @zhang-liang-pengkun 
Reviewed-by: @Charlie_li 
Signed-off-by: @Charlie_li
2023-10-19 09:53:07 +00:00
zhang-liang-pengkun
be3abedfe0 Fix Linuxdisk io counters fails on Linux kernel
Signed-off-by: zhang-liang-pengkun <zhangliangpengkun@xfusion.com>
2023-10-18 17:50:19 +08:00
openeuler-ci-bot
722208a5a4 !14 fix CVE-2019-18874
From: @starlet-dx
Reviewed-by: @small_leek
Signed-off-by: @small_leek
2021-10-20 11:47:01 +00:00
starlet-dx
2f0531fa5c fix CVE-2019-18874 2021-10-20 19:26:44 +08:00
7 changed files with 259 additions and 1 deletions

View File

@ -0,0 +1,37 @@
From 8f99f3782663959062ee868bbfdbc336307a3a4d Mon Sep 17 00:00:00 2001
From: Koen Kooi <koen@dominion.thruhere.net>
Date: Mon, 5 Nov 2018 15:17:16 +0000
Subject: [PATCH] Fix #1354 [Linux] disk_io_counters() fails on Linux kernel
4.18+ (#1360)
Linux kernel 4.18+ added 4 fields, ingore them and parse the rest as
usual.
---
psutil/_pslinux.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py
index b57adb3..764c95f 100644
--- a/psutil/_pslinux.py
+++ b/psutil/_pslinux.py
@@ -1051,6 +1051,8 @@ def disk_io_counters():
# ...unless (Linux 2.6) the line refers to a partition instead
# of a disk, in which case the line has less fields (7):
# "3 1 hda1 8 8 8 8"
+ # 4.18+ has 4 fields added:
+ # "3 0 hda 8 8 8 8 8 8 8 8 8 8 8 0 0 0 0"
# See:
# https://www.kernel.org/doc/Documentation/iostats.txt
# https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats
@@ -1062,7 +1064,7 @@ def disk_io_counters():
reads = int(fields[2])
(reads_merged, rbytes, rtime, writes, writes_merged,
wbytes, wtime, _, busy_time, _) = map(int, fields[4:14])
- elif fields_len == 14:
+ elif flen == 14 or flen == 18:
# Linux 2.6+, line referring to a disk
name = fields[2]
(reads, reads_merged, rbytes, rtime, writes, writes_merged,
--
2.39.0.windows.2

View File

@ -0,0 +1,40 @@
From f7171c45d7cfc1ce68baa7cd0afdaa94e28305a5 Mon Sep 17 00:00:00 2001
From: Jon Dufresne <jon.dufresne@gmail.com>
Date: Thu, 11 Jan 2018 12:34:18 -0800
Subject: [PATCH] Pass python_requires argument to setuptools (#1208)
Helps pip decide what version of the library to install.
https://packaging.python.org/tutorials/distributing-packages/#python-requires
> If your project only runs on certain Python versions, setting the
> python_requires argument to the appropriate PEP 440 version specifier
> string will prevent pip from installing the project on other Python
> versions.
https://setuptools.readthedocs.io/en/latest/setuptools.html#new-and-changed-setup-keywords
> python_requires
>
> A string corresponding to a version specifier (as defined in PEP 440)
> for the Python version, used to specify the Requires-Python defined in
> PEP 345.
---
setup.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/setup.py b/setup.py
index 1625a3eb..d8db694e 100755
--- a/setup.py
+++ b/setup.py
@@ -338,6 +338,7 @@ def main():
)
if setuptools is not None:
kwargs.update(
+ python_requires=">=2.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
test_suite="psutil.tests.get_suite",
tests_require=tests_require,
extras_require=extras_require,
--
2.39.0.windows.2

View File

@ -0,0 +1,25 @@
From 7618de9683684811402f50b08ca3f3e979774e72 Mon Sep 17 00:00:00 2001
From: Dan Vinakovsky <dvinak@gmail.com>
Date: Mon, 12 Feb 2018 18:29:34 -0500
Subject: [PATCH] fix compatibility with python 2.6.x (#1216)
---
psutil/_pswindows.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/psutil/_pswindows.py b/psutil/_pswindows.py
index b6c58c93..0eb4b14f 100644
--- a/psutil/_pswindows.py
+++ b/psutil/_pswindows.py
@@ -200,7 +200,7 @@ def py2_strencode(s):
if isinstance(s, str):
return s
else:
- return s.encode(ENCODING, errors=ENCODING_ERRS)
+ return s.encode(ENCODING, ENCODING_ERRS)
# =====================================================================
--
2.39.0.windows.2

View File

@ -0,0 +1,44 @@
From 62e1783764420f36cd270135decb00b324add7fe Mon Sep 17 00:00:00 2001
From: Giampaolo Rodola <g.rodola@gmail.com>
Date: Tue, 13 Feb 2018 00:31:59 +0100
Subject: [PATCH] #1216 - give credit to @hexaclock
---
CREDITS | 4 ++++
HISTORY.rst | 9 +++++++++
2 files changed, 13 insertions(+)
diff --git a/CREDITS b/CREDITS
index cf9ce493..798b36e3 100644
--- a/CREDITS
+++ b/CREDITS
@@ -515,3 +515,7 @@ I: 1167
N: janderbrain
W: https://github.com/janderbrain
I: 1169
+
+N: Dan Vinakovsky
+W: https://github.com/hexaclock
+I: 1216
diff --git a/HISTORY.rst b/HISTORY.rst
index dd813c5b..463860c2 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -1,5 +1,14 @@
*Bug tracker at https://github.com/giampaolo/psutil/issues*
+5.4.4
+=====
+
+XXXX-XX-XX
+
+**Bug fixes**
+
+- 1216_: fix compatibility with python 2.6 on Windows (patch by Dan Vinakovsky)
+
5.4.3
=====
--
2.39.0.windows.2

59
CVE-2019-18874-1.patch Normal file
View File

@ -0,0 +1,59 @@
Backport of:
From 7d512c8e4442a896d56505be3e78f1156f443465 Mon Sep 17 00:00:00 2001
From: Riccardo Schirone <ret2libc@users.noreply.github.com>
Date: Wed, 13 Nov 2019 14:54:21 +0100
Subject: [PATCH] Use Py_CLEAR instead of Py_DECREF to also set the variable to
NULL (#1616)
These files contain loops that convert system data into python objects
and during the process they create objects and dereference their
refcounts after they have been added to the resulting list.
However, in case of errors during the creation of those python objects,
the refcount to previously allocated objects is dropped again with
Py_XDECREF, which should be a no-op in case the paramater is NULL. Even
so, in most of these loops the variables pointing to the objects are
never set to NULL, even after Py_DECREF is called at the end of the loop
iteration. This means, after the first iteration, if an error occurs
those python objects will get their refcount dropped two times,
resulting in a possible double-free.
---
psutil/_psutil_aix.c | 18 +++++++-------
psutil/_psutil_bsd.c | 30 +++++++++++-----------
psutil/_psutil_linux.c | 14 +++++------
psutil/_psutil_osx.c | 39 ++++++++++++++---------------
psutil/_psutil_sunos.c | 43 ++++++++++++++++----------------
psutil/_psutil_windows.c | 54 ++++++++++++++++++++--------------------
6 files changed, 97 insertions(+), 101 deletions(-)
--- a/psutil/_psutil_linux.c
+++ b/psutil/_psutil_linux.c
@@ -232,9 +232,9 @@ psutil_disk_partitions(PyObject *self, P
goto error;
if (PyList_Append(py_retlist, py_tuple))
goto error;
- Py_DECREF(py_dev);
- Py_DECREF(py_mountp);
- Py_DECREF(py_tuple);
+ Py_CLEAR(py_dev);
+ Py_CLEAR(py_mountp);
+ Py_CLEAR(py_tuple);
}
endmntent(file);
return py_retlist;
@@ -488,10 +488,10 @@ psutil_users(PyObject *self, PyObject *a
goto error;
if (PyList_Append(py_retlist, py_tuple))
goto error;
- Py_DECREF(py_username);
- Py_DECREF(py_tty);
- Py_DECREF(py_hostname);
- Py_DECREF(py_tuple);
+ Py_CLEAR(py_username);
+ Py_CLEAR(py_tty);
+ Py_CLEAR(py_hostname);
+ Py_CLEAR(py_tuple);
}
endutent();
return py_retlist;

31
CVE-2019-18874-2.patch Normal file
View File

@ -0,0 +1,31 @@
From 3a9bccfd2c6d2e6538298cd3892058b1204056e0 Mon Sep 17 00:00:00 2001
From: Riccardo Schirone <ret2libc@users.noreply.github.com>
Date: Mon, 18 Nov 2019 15:51:39 +0100
Subject: [PATCH] psutil/_psutil_posix.c: better clear variables to ensure they
are NULL (#1624)
---
psutil/_psutil_posix.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/psutil/_psutil_posix.c b/psutil/_psutil_posix.c
index 209e787d5..aa6008491 100644
--- a/psutil/_psutil_posix.c
+++ b/psutil/_psutil_posix.c
@@ -324,11 +324,11 @@ psutil_net_if_addrs(PyObject* self, PyObject* args) {
goto error;
if (PyList_Append(py_retlist, py_tuple))
goto error;
- Py_DECREF(py_tuple);
- Py_DECREF(py_address);
- Py_DECREF(py_netmask);
- Py_DECREF(py_broadcast);
- Py_DECREF(py_ptp);
+ Py_CLEAR(py_tuple);
+ Py_CLEAR(py_address);
+ Py_CLEAR(py_netmask);
+ Py_CLEAR(py_broadcast);
+ Py_CLEAR(py_ptp);
}
freeifaddrs(ifaddr);

View File

@ -1,11 +1,18 @@
Name: python-psutil
Version: 5.4.3
Release: 8
Release: 13
Summary: A library for retrieving information on running processes and system utilization in Python
License: BSD
URL: https://github.com/giampaolo/psutil
Source0: https://github.com/giampaolo/psutil/archive/release-%{version}.tar.gz#/psutil-%{version}.tar.gz
Patch0001: CVE-2019-18874-1.patch
Patch0002: CVE-2019-18874-2.patch
Patch0003: 0001-Fix-1354-Linux-disk_io_counters-fails-on-Linux-kerne.patch
Patch0004: 0002-Pass-python_requires-argument-to-setuptools-1208.patch
Patch0005: 0003-fix-compatibility-with-python-2.6.x-1216.patch
Patch0006: 0004-1216-give-credit-to-hexaclock.patch
BuildRequires: gcc python2-devel python3-devel procps-ng python2-mock python3-mock python2-ipaddress
%description
@ -68,6 +75,21 @@ done
%{python3_sitearch}/*.egg-info
%changelog
* Fri Jan 12 2024 zhangliangpengkun<zhangliangpengkun@xfusion.com> - 5.4.3-13
- #1216 - give credit to @hexaclock
* Wed Dec 27 2023 zhangliangpengkun<zhangliangpengkun@xfusion.com> - 5.4.3-12
- fix compatibility with python 2.6.x
* Thu Dec 21 2023 zhangliangpengkun<zhangliangpengkun@xfusion.com> - 5.4.3-11
- Pass python_requires argument to setuptools (#1208)
* Wed Oct 18 2023 zhangliangpengkun<zhangliangpengkun@xfusion.com> - 5.4.3-10
- Fix Linuxdisk io counters fails on Linux kernel
* Wed Oct 20 2021 yaoxin <yaoxin30@huawei.com> - 5.4.3-9
- Fix CVE-2019-18874
* Fri Aug 21 2020 shixuantong <shixuantong@huawei.com> - 5.4.3-8
- add release version for rebuild