aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Lapshin <a.v.lapshin@mail.ru>2021-04-12 14:27:14 +0300
committerMichał Górny <mgorny@moritz.systems>2021-07-21 12:52:50 +0200
commite2054f8b7c5e4a44f75024d3e217c24ca4117e82 (patch)
tree53b7ed609793027c33372e24c3ade8cb90899207
parent[llvm-objcopy][NFC] Move ownership keeping code into restoreStatOnFile(). (diff)
downloadllvm-project-gentoo-12.0.1-r1.tar.gz
llvm-project-gentoo-12.0.1-r1.tar.bz2
llvm-project-gentoo-12.0.1-r1.zip
Fix chrome os failure after 021de7cf80268091cf13485a538b611b37d0b33e.gentoo-12.0.1-r1
chrome os build failed after D98511: https://bugs.chromium.org/p/chromium/issues/detail?id=1197970 This patch fixes permission issue appeared after D98511. Gentoo-Component: llvm
-rw-r--r--llvm/tools/llvm-objcopy/llvm-objcopy.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
index 68b5e97d09ed..d9365d8b0cb7 100644
--- a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
+++ b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -287,6 +287,12 @@ static Error restoreStatOnFile(StringRef Filename,
if (std::error_code EC = sys::fs::status(FD, OStat))
return createFileError(Filename, EC);
if (OStat.type() == sys::fs::file_type::regular_file) {
+#ifndef _WIN32
+ // Keep ownership if llvm-objcopy is called under root.
+ if (Config.InputFilename == Config.OutputFilename && OStat.getUser() == 0)
+ sys::fs::changeFileOwnership(FD, Stat.getUser(), Stat.getGroup());
+#endif
+
sys::fs::perms Perm = Stat.permissions();
if (Config.InputFilename != Config.OutputFilename)
Perm = static_cast<sys::fs::perms>(Perm & ~sys::fs::getUmask() & ~06000);
@@ -296,12 +302,6 @@ static Error restoreStatOnFile(StringRef Filename,
if (auto EC = sys::fs::setPermissions(FD, Perm))
#endif
return createFileError(Filename, EC);
-
-#ifndef _WIN32
- // Keep ownership if llvm-objcopy is called under root.
- if (Config.InputFilename == Config.OutputFilename && OStat.getUser() == 0)
- sys::fs::changeFileOwnership(FD, Stat.getUser(), Stat.getGroup());
-#endif
}
if (auto EC = sys::Process::SafelyCloseFileDescriptor(FD))