From 6f0ec895848634607673ed74402e1fad0b34876d Mon Sep 17 00:00:00 2001 From: Anderson Toshiyuki Sasaki Date: Thu, 28 Aug 2025 17:48:05 +0200 Subject: [PATCH] Avoid opening /dev/stdout when printing This fixes a test failure during build in ppc64le arch Related: RHEL-111239 Signed-off-by: Anderson Toshiyuki Sasaki --- ...lime-policy-avoid-opening-dev-stdout.patch | 37 +++++++++++++++++++ keylime.spec | 2 + 2 files changed, 39 insertions(+) create mode 100644 0012-keylime-policy-avoid-opening-dev-stdout.patch diff --git a/0012-keylime-policy-avoid-opening-dev-stdout.patch b/0012-keylime-policy-avoid-opening-dev-stdout.patch new file mode 100644 index 0000000..eea629d --- /dev/null +++ b/0012-keylime-policy-avoid-opening-dev-stdout.patch @@ -0,0 +1,37 @@ +From e9a6615ea3ab60b9248377071ea2f5cc7b45dfda Mon Sep 17 00:00:00 2001 +From: Sergio Correia +Date: Thu, 28 Aug 2025 14:33:59 +0100 +Subject: [PATCH] policy/sign: use print() when writing to /dev/stdout + +Signed-off-by: Sergio Correia +--- + keylime/policy/sign_runtime_policy.py | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/keylime/policy/sign_runtime_policy.py b/keylime/policy/sign_runtime_policy.py +index 87529065d..316ee15aa 100644 +--- a/keylime/policy/sign_runtime_policy.py ++++ b/keylime/policy/sign_runtime_policy.py +@@ -2,6 +2,7 @@ + + import argparse + import json ++import sys + from json.decoder import JSONDecodeError + from typing import TYPE_CHECKING, Any, Optional + +@@ -191,8 +192,12 @@ def sign_runtime_policy(args: argparse.Namespace) -> Optional[str]: + return None + + try: +- with open(args.output_file, "wb") as f: +- f.write(signed_policy.encode("UTF-8")) ++ if args.output_file == "/dev/stdout": ++ # Let's simply print to stdout the regular way. ++ print(signed_policy, file=sys.stdout) ++ else: ++ with open(args.output_file, "wb") as f: ++ f.write(signed_policy.encode("UTF-8")) + except Exception as exc: + logger.error("Unable to write signed policy to destination file '%s': %s", args.output_file, exc) + return None diff --git a/keylime.spec b/keylime.spec index a19a712..63efe1d 100644 --- a/keylime.spec +++ b/keylime.spec @@ -45,6 +45,8 @@ Patch: 0010-mba-normalize-vendor_db-in-EV_EFI_VARIABLE_AUTHORITY.patch # Backported from https://github.com/keylime/keylime/pull/1794 Patch: 0011-fix-malformed-certs-workaround.patch +# Backported from https://github.com/keylime/keylime/pull/1795 +Patch: 0012-keylime-policy-avoid-opening-dev-stdout.patch # Main program: Apache-2.0 # Icons: MIT