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