Hardlinks fuse mount breaks when script links files
Summary
The way hardlinks copies linked files does not work when the file is not readable.
This was tested with 1.6.
The use case covers unpacking cpio files and install rpm files, when there are linked files. Linked files in packages are quite common, specially in toolchain packages.
Steps to reproduce
Consider the following:
kind: script
build-depends:
- freedesktop-sdk.bst:bootstrap-import.bst
config:
commands:
- touch /a
- chmod 0000 /a
- ln /a /b
- chmod 0755 /a
This fails with:
chmod 0755 /a
chmod: changing permissions of '/a': Permission denied
The reason is that the fuse fs wants to copy /a
. But it is not readable.
At no point did hardlinks have any reason to copy /a
, because the file is safe as it does not link to the read only file.
Possible fixes
Before copying a file with multiple links, we should make sure whether this file is safe. If it is, there is no reason to copy it. One way to know if a file is safe could be to add a special extended attribute to it.
Other relevant information
- BuildStream version affected: /milestone %BuildStream_v1.6
Edited by Valentin David