Merge "crash_dump: make output fd O_APPEND."
am: a70f11331f
Change-Id: I8e4acd2b0d0b8e9920b8cc425633e822098a20c1
diff --git a/debuggerd/crash_dump.cpp b/debuggerd/crash_dump.cpp
index d4be25b..d7bef03 100644
--- a/debuggerd/crash_dump.cpp
+++ b/debuggerd/crash_dump.cpp
@@ -155,6 +155,14 @@
return false;
}
+ // Make the fd O_APPEND so that our output is guaranteed to be at the end of a file.
+ // (This also makes selinux rules consistent, because selinux distinguishes between writing to
+ // a regular fd, and writing to an fd with O_APPEND).
+ int flags = fcntl(tmp_output_fd.get(), F_GETFL);
+ if (fcntl(tmp_output_fd.get(), F_SETFL, flags | O_APPEND) != 0) {
+ PLOG(WARNING) << "failed to set output fd flags";
+ }
+
*tombstoned_socket = std::move(sockfd);
*output_fd = std::move(tmp_output_fd);
return true;