From 76f137e2666633c41ffd76dee618c2984896d9db Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Jan 27 2021 16:09:16 +0000 Subject: import policycoreutils-2.9-10.el8 --- diff --git a/SOURCES/0033-python-semanage-empty-stdout-before-exiting-on-Broke.patch b/SOURCES/0033-python-semanage-empty-stdout-before-exiting-on-Broke.patch new file mode 100644 index 0000000..56a271b --- /dev/null +++ b/SOURCES/0033-python-semanage-empty-stdout-before-exiting-on-Broke.patch @@ -0,0 +1,55 @@ +From 0bed778c53a4f93b1b092b3db33e8c36aabfa39d Mon Sep 17 00:00:00 2001 +From: Vit Mojzis +Date: Tue, 5 Jan 2021 17:00:21 +0100 +Subject: [PATCH] python/semanage: empty stdout before exiting on + BrokenPipeError + +Empty stdout buffer before exiting when BrokenPipeError is +encountered. Otherwise python will flush the bufer during exit, which +may trigger the exception again. +https://docs.python.org/3/library/signal.html#note-on-sigpipe + +Fixes: + #semanage fcontext -l | egrep -q -e '^/home' + BrokenPipeError: [Errno 32] Broken pipe + Exception ignored in: <_io.TextIOWrapper name='' mode='w' encoding='UTF-8'> + BrokenPipeError: [Errno 32] Broken pipe + +Note that the error above only appears occasionally (usually only the +first line is printed). + +Signed-off-by: Vit Mojzis +Acked-by: Nicolas Iooss +--- + python/semanage/semanage | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/python/semanage/semanage b/python/semanage/semanage +index b2bd9df9..1abe3536 100644 +--- a/python/semanage/semanage ++++ b/python/semanage/semanage +@@ -26,6 +26,7 @@ + import traceback + import argparse + import sys ++import os + PROGNAME = "selinux-python" + try: + import gettext +@@ -953,6 +954,13 @@ def do_parser(): + args = commandParser.parse_args(make_args(sys.argv)) + args.func(args) + sys.exit(0) ++ except BrokenPipeError as e: ++ sys.stderr.write("%s: %s\n" % (e.__class__.__name__, str(e))) ++ # Python flushes standard streams on exit; redirect remaining output ++ # to devnull to avoid another BrokenPipeError at shutdown ++ devnull = os.open(os.devnull, os.O_WRONLY) ++ os.dup2(devnull, sys.stdout.fileno()) ++ sys.exit(1) + except IOError as e: + sys.stderr.write("%s: %s\n" % (e.__class__.__name__, str(e))) + sys.exit(1) +-- +2.29.2 + diff --git a/SOURCES/0034-python-semanage-Sort-imports-in-alphabetical-order.patch b/SOURCES/0034-python-semanage-Sort-imports-in-alphabetical-order.patch new file mode 100644 index 0000000..8c1bab7 --- /dev/null +++ b/SOURCES/0034-python-semanage-Sort-imports-in-alphabetical-order.patch @@ -0,0 +1,41 @@ +From 4b0e627d42f9a8e09dcd064a6ae897f4c2e9cf6c Mon Sep 17 00:00:00 2001 +From: Vit Mojzis +Date: Wed, 6 Jan 2021 10:00:07 +0100 +Subject: [PATCH] python/semanage: Sort imports in alphabetical order + +Signed-off-by: Vit Mojzis +--- + python/semanage/semanage | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/python/semanage/semanage b/python/semanage/semanage +index 1abe3536..781e8645 100644 +--- a/python/semanage/semanage ++++ b/python/semanage/semanage +@@ -23,10 +23,12 @@ + # + # + +-import traceback + import argparse +-import sys + import os ++import re ++import sys ++import traceback ++ + PROGNAME = "selinux-python" + try: + import gettext +@@ -786,8 +788,6 @@ def setupExportParser(subparsers): + exportParser.add_argument('-f', '--output_file', dest='output_file', action=SetExportFile, help=_('Output file')) + exportParser.set_defaults(func=handleExport) + +-import re +- + + def mkargv(line): + dquote = "\"" +-- +2.29.2 + diff --git a/SPECS/policycoreutils.spec b/SPECS/policycoreutils.spec index 24ffe1c..e9c4cff 100644 --- a/SPECS/policycoreutils.spec +++ b/SPECS/policycoreutils.spec @@ -12,7 +12,7 @@ Summary: SELinux policy core utilities Name: policycoreutils Version: 2.9 -Release: 9%{?dist} +Release: 10%{?dist} License: GPLv2 # https://github.com/SELinuxProject/selinux/wiki/Releases Source0: https://github.com/SELinuxProject/selinux/releases/download/20190315/policycoreutils-2.9.tar.gz @@ -70,6 +70,8 @@ Patch0029: 0029-python-semanage-fix-moduleRecords.customized.patch Patch0030: 0030-python-semanage-Add-support-for-DCCP-and-SCTP-protoc.patch Patch0031: 0031-dbus-Fix-FileNotFoundError-in-org.selinux.relabel_on.patch Patch0032: 0032-restorecond-Fix-redundant-console-log-output-error.patch +Patch0033: 0033-python-semanage-empty-stdout-before-exiting-on-Broke.patch +Patch0034: 0034-python-semanage-Sort-imports-in-alphabetical-order.patch Obsoletes: policycoreutils < 2.0.61-2 Conflicts: filesystem < 3, selinux-policy-base < 3.13.1-138 @@ -507,6 +509,10 @@ The policycoreutils-restorecond package contains the restorecond service. %systemd_postun_with_restart restorecond.service %changelog +* Sat Jan 16 2021 Vit Mojzis - 2.9-10 +- python/semanage: Sort imports in alphabetical order +- python/semanage: empty stdout before exiting on BrokenPipeError (#1822100) + * Fri Jan 17 2020 Vit Mojzis - 2.9-9 - Update translations (#1754978)