|
|
ad54c5 |
From a84df47afae75a0b4068c78d8201a515a841f353 Mon Sep 17 00:00:00 2001
|
|
|
ad54c5 |
From: David Tardon <dtardon@redhat.com>
|
|
|
ad54c5 |
Date: Tue, 16 Aug 2022 13:30:16 +0200
|
|
|
ad54c5 |
Subject: [PATCH] fix(skipcpio): ignore broken pipe
|
|
|
f226d6 |
|
|
|
ad54c5 |
If lsinitrd is called from a context in which SIGPIPE is ignored (e.g.,
|
|
|
ad54c5 |
from a systemd unit with default setting of IgnoreSIGPIPE=), the
|
|
|
ad54c5 |
following line will result in an error being issued:
|
|
|
ad54c5 |
|
|
|
ad54c5 |
bin="$($SKIP "$image" | { read -r -N 6 bin && echo "$bin"; })"
|
|
|
ad54c5 |
|
|
|
ad54c5 |
An example error from `kdumpctl start` (which internally just calls
|
|
|
ad54c5 |
`systemctl start kdump.service`):
|
|
|
ad54c5 |
|
|
|
ad54c5 |
kdumpctl[1287]: ERROR: src/skipcpio/skipcpio.c:191:main(): fwrite
|
|
|
ad54c5 |
|
|
|
ad54c5 |
A minimal reproducer:
|
|
|
ad54c5 |
|
|
|
ad54c5 |
systemd-run -t sh -c '/path/to/skipcpio /path/to/any/file | false'
|
|
|
ad54c5 |
|
|
|
ad54c5 |
(cherry-picked from e9a4d73b73b716a9d2d5f01ceb7b427ef544ed9b)
|
|
|
ad54c5 |
|
|
|
ad54c5 |
Resolves: #2109803
|
|
|
f226d6 |
---
|
|
|
ad54c5 |
src/skipcpio/skipcpio.c | 5 ++++-
|
|
|
ad54c5 |
1 file changed, 4 insertions(+), 1 deletion(-)
|
|
|
f226d6 |
|
|
|
ad54c5 |
diff --git a/src/skipcpio/skipcpio.c b/src/skipcpio/skipcpio.c
|
|
|
ad54c5 |
index 13bfaf53..f66c1869 100644
|
|
|
ad54c5 |
--- a/src/skipcpio/skipcpio.c
|
|
|
ad54c5 |
+++ b/src/skipcpio/skipcpio.c
|
|
|
ad54c5 |
@@ -23,6 +23,7 @@
|
|
|
ad54c5 |
#define _GNU_SOURCE
|
|
|
ad54c5 |
#endif
|
|
|
f226d6 |
|
|
|
ad54c5 |
+#include <errno.h>
|
|
|
ad54c5 |
#include <stdio.h>
|
|
|
ad54c5 |
#include <stdlib.h>
|
|
|
ad54c5 |
#include <string.h>
|
|
|
ad54c5 |
@@ -187,8 +188,10 @@ cat_rest:
|
|
|
ad54c5 |
goto end;
|
|
|
ad54c5 |
}
|
|
|
f226d6 |
|
|
|
ad54c5 |
+ errno = 0;
|
|
|
ad54c5 |
if (fwrite(buf.copy_buffer, 1, s, stdout) != s) {
|
|
|
ad54c5 |
- pr_err("fwrite\n");
|
|
|
ad54c5 |
+ if (errno != EPIPE)
|
|
|
ad54c5 |
+ pr_err("fwrite\n");
|
|
|
ad54c5 |
goto end;
|
|
|
ad54c5 |
}
|
|
|
ad54c5 |
}
|