keylime/0012-keylime-policy-avoid-opening-dev-stdout.patch
Anderson Toshiyuki Sasaki 6f0ec89584 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 <ansasaki@redhat.com>
2025-08-28 17:48:05 +02:00

38 lines
1.4 KiB
Diff

From e9a6615ea3ab60b9248377071ea2f5cc7b45dfda Mon Sep 17 00:00:00 2001
From: Sergio Correia <scorreia@redhat.com>
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 <scorreia@redhat.com>
---
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