Hi gentoo devs,

This question is regarding interaction of fowners [1] and estrip functionality in portage.
fowners is used on various binaries and files to assign the ownership to specific users or group.

GNU objcopy and strip do not change the file ownership when run as root. However, llvm's versions do not preserve it and instead make root the owner of the modified file. 
e.g. 
sudo strip <file> keeps the original ownership .
sudo llvm-strip <file> will change ownership to root.

We were trying to have llvm objcopy with a patch [3] to have the same behavior as GNU but LLVM developers pointed out that GNU implementation is thought to have a security issue: https://sourceware.org/bugzilla/show_bug.cgi?id=26945 
We have modified the LLVM patch to avoid chown on the final file and rather doing it on the temporay file but I am not sure if that will be enough to placate the llvm devs.

What does everyone think of modifying usages of calls to strip and objcopy inside estrip so that file ownership is manually restored. e.g

owner=$(stat -U file)
group=$(stat -G file)
strip <file>
chown owner:group file

[1] https://devmanual.gentoo.org/function-reference/install-functions/
[2] https://gitweb.gentoo.org/proj/portage.git/tree/bin/estrip
[3] https://reviews.llvm.org/D93881

Thanks,
Manoj