Skip to content

Commit ee8a5e4

Browse files
committed
Fix chrome os failure after 021de7c.
chrome os build failed after D98511: https://bugs.chromium.org/p/chromium/issues/detail?id=1197970 This patch fixes permission issue appeared after D98511.
1 parent 6cc91ad commit ee8a5e4

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

llvm/tools/llvm-objcopy/llvm-objcopy.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,12 @@ static Error restoreStatOnFile(StringRef Filename,
259259
if (std::error_code EC = sys::fs::status(FD, OStat))
260260
return createFileError(Filename, EC);
261261
if (OStat.type() == sys::fs::file_type::regular_file) {
262+
#ifndef _WIN32
263+
// Keep ownership if llvm-objcopy is called under root.
264+
if (Config.InputFilename == Config.OutputFilename && OStat.getUser() == 0)
265+
sys::fs::changeFileOwnership(FD, Stat.getUser(), Stat.getGroup());
266+
#endif
267+
262268
sys::fs::perms Perm = Stat.permissions();
263269
if (Config.InputFilename != Config.OutputFilename)
264270
Perm = static_cast<sys::fs::perms>(Perm & ~sys::fs::getUmask() & ~06000);
@@ -268,12 +274,6 @@ static Error restoreStatOnFile(StringRef Filename,
268274
if (auto EC = sys::fs::setPermissions(FD, Perm))
269275
#endif
270276
return createFileError(Filename, EC);
271-
272-
#ifndef _WIN32
273-
// Keep ownership if llvm-objcopy is called under root.
274-
if (Config.InputFilename == Config.OutputFilename && OStat.getUser() == 0)
275-
sys::fs::changeFileOwnership(FD, Stat.getUser(), Stat.getGroup());
276-
#endif
277277
}
278278

279279
if (auto EC = sys::Process::SafelyCloseFileDescriptor(FD))

0 commit comments

Comments
 (0)