From 08ba1ad9b1a6406a67feddeff211387225ccd603 Mon Sep 17 00:00:00 2001 From: Bill Peckham Date: Thu, 28 Mar 2019 18:42:13 -0700 Subject: Use flags = 0 to avoid fd closing for child updater process If we use the default parameter we'll get O_CLOEXEC, which will close the fd that we pass to the child process, which will cause it to fail. Passing zero avoids the problem. Bug: 122813742 Test: Verify that non-A/B OTA update is successful. Change-Id: Ia61bc7260f17d9209715583e6ded69e1196ed3f6 --- install.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/install.cpp b/install.cpp index b7fb78878..ffa39e46b 100644 --- a/install.cpp +++ b/install.cpp @@ -342,7 +342,9 @@ static int try_update_binary(const std::string& package, ZipArchiveHandle zip, b // The updater in child process writes to the pipe to communicate with recovery. android::base::unique_fd pipe_read, pipe_write; - if (!android::base::Pipe(&pipe_read, &pipe_write)) { + // Explicitly disable O_CLOEXEC using 0 as the flags (last) parameter to Pipe + // so that the child updater process will recieve a non-closed fd. + if (!android::base::Pipe(&pipe_read, &pipe_write, 0)) { PLOG(ERROR) << "Failed to create pipe for updater-recovery communication"; return INSTALL_CORRUPT; } -- cgit v1.2.3