backport patches from upstream

(cherry picked from commit 2c5bf4aced7188410413106c35204d32f1f5f991)
This commit is contained in:
zgzxx 2023-09-11 17:18:11 +08:00 committed by openeuler-sync-bot
parent a7a0b922e0
commit d36bdc4cc4
3 changed files with 72 additions and 1 deletions

View File

@ -0,0 +1,35 @@
From f6dc6acfa00707ce25c6357169111937f12512dd Mon Sep 17 00:00:00 2001
From: James Carter <jwcart2@gmail.com>
Date: Thu, 3 Aug 2023 09:40:24 -0400
Subject: [PATCH] python: Use isinstance() instead of type()
CI testing fails while running flake8 on python scripts with the
message "./python/semanage/seobject.py:250:16: E721 do not compare
types, for exact checks use `is` / `is not`, for instance checks use
`isinstance()`"
Use "isinstance(args, str)" instead of "type(args) == str"
Signed-off-by: James Carter <jwcart2@gmail.com>
Reference:https://github.com/SELinuxProject/selinux/commit/f6dc6acfa00707ce25c6357169111937f12512dd
Conflict:NA
---
python/semanage/seobject.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/python/semanage/seobject.py b/python/semanage/seobject.py
index 361205d1..cc944ae2 100644
--- a/python/semanage/seobject.py
+++ b/python/semanage/seobject.py
@@ -247,7 +247,7 @@ class semanageRecords:
global handle
if args:
# legacy code - args was store originally
- if type(args) == str:
+ if isinstance(args, str):
self.store = args
else:
self.args = args
--
2.23.0

View File

@ -0,0 +1,31 @@
From 8730e0762e36ae214932e2a2a84aedd573462357 Mon Sep 17 00:00:00 2001
From: Huaxin Lu <luhuaxin1@huawei.com>
Date: Tue, 11 Jul 2023 06:49:33 +0800
Subject: [PATCH] restorecond: add check for strdup in strings_list_add
Check the return value of strdup() to avoid null pointer reference.
Signed-off-by: Huaxin Lu <luhuaxin1@huawei.com>
Acked-by: James Carter <jwcart2@gmail.com>
Reference:https://github.com/SELinuxProject/selinux/commit/8730e0762e36ae214932e2a2a84aedd573462357
Conflict:NA
---
restorecond/stringslist.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/restorecond/stringslist.c b/restorecond/stringslist.c
index f9404b1e..a76542a7 100644
--- a/restorecond/stringslist.c
+++ b/restorecond/stringslist.c
@@ -48,6 +48,8 @@ void strings_list_add(struct stringsList **list, const char *string)
if (!newptr)
exitApp("Out of Memory");
newptr->string = strdup(string);
+ if (!newptr->string)
+ exitApp("Out of Memory");
newptr->next = ptr;
if (prev)
prev->next = newptr;
--
2.23.0

View File

@ -3,7 +3,7 @@
Name: policycoreutils
Version: 3.3
Release: 6
Release: 7
Summary: Policy core utilities of selinux
License: GPLv2
URL: https://github.com/SELinuxProject
@ -29,6 +29,8 @@ Patch6008: backport-sepolicy-Call-os.makedirs-with-exist_ok-True.patch
Patch6009: backport-policycoreutils-fix-potential-NULL-reference-in-load_checks.patch
Patch6010: backport-python-sepolicy-add-missing-booleans-to-man-pages.patch
Patch6011: backport-python-sepolicy-Cache-conditional-rule-queries.patch
Patch6012: backport-restorecond-add-check-for-strdup-in-strings_list_add.patch
Patch6013: backport-python-Use-isinstance-instead-of-type.patch
BuildRequires: gcc
BuildRequires: pam-devel libsepol-static >= 3.3 libsemanage-static >= 3.3 libselinux-devel >= 3.3 libcap-devel audit-libs-devel gettext
@ -269,6 +271,9 @@ find %{buildroot}%{python3_sitelib} %{buildroot}%{python3_sitearch} \
%{_mandir}/*
%changelog
* Mon Sep 11 2023 zhangguangzhi <zhangguangzhi3@huawei.com> -3.3-7
- backport patches from upstream
* Wed Mar 22 2023 zhangguangzhi <zhangguangzhi3@huawei.com> -3.3-6
- backport patches from upstream