summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-09-27 00:10:04 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-09-28 23:49:01 +0200
commit954d3a51afc0ee23e84b1aa9c4a9073901cfb766 (patch)
tree636fcddff874f2d1070611cf6e447693cc386cd0
parentfc6cec86136976488e64b8faec2bad6810acfb68 (diff)
coredumpctl: fix handling of files written to fd
Added in 9fe13294a9 (by me :[```), and later obfuscated in d0c8806d4ab, if an uncompressed external file or an internally stored coredump was supposed to be written to a file descriptor, nothing would be written.
-rw-r--r--src/coredump/coredumpctl.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/coredump/coredumpctl.c b/src/coredump/coredumpctl.c
index 67bf502e73..05a097076b 100644
--- a/src/coredump/coredumpctl.c
+++ b/src/coredump/coredumpctl.c
@@ -593,16 +593,16 @@ static int save_core(sd_journal *j, int fd, char **path, bool *unlink_temp) {
else if (r == 0)
retrieve(data, len, "COREDUMP_FILENAME", &filename);
- if (filename && access(filename, R_OK) < 0)
- return log_error_errno(errno, "File \"%s\" is not readable: %m", filename);
+ if (filename) {
+ if (access(filename, R_OK) < 0)
+ return log_error_errno(errno, "File \"%s\" is not readable: %m", filename);
- if (filename && !endswith(filename, ".xz") && !endswith(filename, ".lz4")) {
- if (path) {
+ if (path && !endswith(filename, ".xz") && !endswith(filename, ".lz4")) {
*path = filename;
filename = NULL;
- }
- return 0;
+ return 0;
+ }
}
if (fd < 0) {
@@ -659,13 +659,13 @@ static int save_core(sd_journal *j, int fd, char **path, bool *unlink_temp) {
data += 9;
len -= 9;
- sz = write(fdt, data, len);
+ sz = write(fd, data, len);
if (sz < 0) {
- r = log_error_errno(errno, "Failed to write temporary file: %m");
+ r = log_error_errno(errno, "Failed to write output: %m");
goto error;
}
if (sz != (ssize_t) len) {
- log_error("Short write to temporary file.");
+ log_error("Short write to output.");
r = -EIO;
goto error;
}