[PATCH] D98511: [llvm-objcopy][NFC] Move ownership keeping code into the restoreStatOnFile().

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 16 12:05:39 PDT 2021


MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

The fchown behavior requires root (CAP_CHOWN) so it is not tested. I have tried several commands and the behavior is kept.

  'cp' -f aa.o a.o; chmod 3777 a.o; ls -l a.o; sudo /tmp/RelA/bin/llvm-strip -p a.o; ls -l a.o
  'cp' -f aa.o a.o; chmod 3707 a.o; ls -l a.o; sudo /tmp/RelA/bin/llvm-objcopy -p a.o b.o; ls -l b.o
  umask 0
  'cp' -f aa.o a.o; chmod 3707 a.o; ls -l a.o; sudo /tmp/RelA/bin/llvm-objcopy -p a.o b.o; ls -l b.o

Treating .dwo similar to .o is good.



================
Comment at: llvm/tools/llvm-objcopy/llvm-objcopy.cpp:301
+#ifndef _WIN32
+    // Keep ownership if llvm-objcopy is called under /root.
+    if (Config.InputFilename == Config.OutputFilename)
----------------
`/root` => root.


================
Comment at: llvm/tools/llvm-objcopy/llvm-objcopy.cpp:302
+    // Keep ownership if llvm-objcopy is called under /root.
+    if (Config.InputFilename == Config.OutputFilename)
+      if (OStat.getUser() == 0)
----------------
The two conditions can be folded.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98511/new/

https://reviews.llvm.org/D98511



More information about the llvm-commits mailing list