summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-01-25 19:34:52 +0100
committerLennart Poettering <lennart@poettering.net>2016-01-25 19:34:52 +0100
commit164228707d7785a27316e2f28be7068044127016 (patch)
tree8d509d5a7f25a4b4970317b8ae2c82a8d127d870 /src/journal
parent7b213864afe455c39fa3f4365dd7149077fc3695 (diff)
parent5f3e0a74689f2acf05c37f5203acec0b8d067458 (diff)
Merge pull request #2240 from hgwalles/coredump-delete-bug
coredump: fix bug that loses core dump files when core dumps are compressed and disk space is low.
Diffstat (limited to 'src/journal')
-rw-r--r--src/journal/coredump.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/journal/coredump.c b/src/journal/coredump.c
index 869c8fea03..7df59fe29b 100644
--- a/src/journal/coredump.c
+++ b/src/journal/coredump.c
@@ -297,7 +297,8 @@ static int save_external_coredump(
const char *info[_INFO_LEN],
uid_t uid,
char **ret_filename,
- int *ret_fd,
+ int *ret_node_fd,
+ int *ret_data_fd,
uint64_t *ret_size) {
_cleanup_free_ char *fn = NULL, *tmp = NULL;
@@ -307,7 +308,8 @@ static int save_external_coredump(
assert(info);
assert(ret_filename);
- assert(ret_fd);
+ assert(ret_node_fd);
+ assert(ret_data_fd);
assert(ret_size);
r = make_filename(info, &fn);
@@ -386,11 +388,12 @@ static int save_external_coredump(
unlink_noerrno(tmp);
*ret_filename = fn_compressed; /* compressed */
- *ret_fd = fd; /* uncompressed */
+ *ret_node_fd = fd_compressed; /* compressed */
+ *ret_data_fd = fd; /* uncompressed */
*ret_size = (uint64_t) st.st_size; /* uncompressed */
fn_compressed = NULL;
- fd = -1;
+ fd = fd_compressed = -1;
return 0;
@@ -400,12 +403,14 @@ static int save_external_coredump(
uncompressed:
#endif
+
r = fix_permissions(fd, tmp, fn, info, uid);
if (r < 0)
goto fail;
*ret_filename = fn;
- *ret_fd = fd;
+ *ret_data_fd = fd;
+ *ret_node_fd = -1;
*ret_size = (uint64_t) st.st_size;
fn = NULL;
@@ -554,7 +559,7 @@ int main(int argc, char* argv[]) {
_cleanup_free_ char *exe = NULL, *comm = NULL, *filename = NULL;
const char *info[_INFO_LEN];
- _cleanup_close_ int coredump_fd = -1;
+ _cleanup_close_ int coredump_fd = -1, coredump_node_fd = -1;
struct iovec iovec[26];
uint64_t coredump_size;
@@ -633,7 +638,7 @@ int main(int argc, char* argv[]) {
if (arg_storage != COREDUMP_STORAGE_NONE)
arg_storage = COREDUMP_STORAGE_EXTERNAL;
- r = save_external_coredump(info, uid, &filename, &coredump_fd, &coredump_size);
+ r = save_external_coredump(info, uid, &filename, &coredump_node_fd, &coredump_fd, &coredump_size);
if (r < 0)
goto finish;
@@ -795,7 +800,7 @@ int main(int argc, char* argv[]) {
coredump_vacuum(-1, arg_keep_free, arg_max_use);
/* Always stream the coredump to disk, if that's possible */
- r = save_external_coredump(info, uid, &filename, &coredump_fd, &coredump_size);
+ r = save_external_coredump(info, uid, &filename, &coredump_node_fd, &coredump_fd, &coredump_size);
if (r < 0)
/* skip whole core dumping part */
goto log;
@@ -815,7 +820,7 @@ int main(int argc, char* argv[]) {
}
/* Vacuum again, but exclude the coredump we just created */
- coredump_vacuum(coredump_fd, arg_keep_free, arg_max_use);
+ coredump_vacuum(coredump_node_fd >= 0 ? coredump_node_fd : coredump_fd, arg_keep_free, arg_max_use);
/* Now, let's drop privileges to become the user who owns the
* segfaulted process and allocate the coredump memory under