From 27ec82e3bc00e06800249deca61c7b2df620596c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Billeter?= Date: Mon, 25 Nov 2019 18:05:17 +0100 Subject: utils.py: safe_link(): Copy if hardlink creation is not permitted By default, Linux doesn't allow creating hardlinks to read-only files of other users since Linux 3.6 (see /proc/sys/fs/protected_hardlinks). This fixes staging when buildbox-casd is running as a separate user and the traditional bubblewrap sandboxing backend is used. This combination is not recommended, however, it's triggered in CI by docker images that run buildbox-casd as a separate user and a few test cases that override BST_FORCE_SANDBOX. --- src/buildstream/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/buildstream/utils.py b/src/buildstream/utils.py index 5009be338..b6716a29d 100644 --- a/src/buildstream/utils.py +++ b/src/buildstream/utils.py @@ -326,7 +326,7 @@ def safe_link(src: str, dest: str, *, result: Optional[FileListResult] = None, _ if e.errno == errno.EEXIST and not _unlink: # Target exists already, unlink and try again safe_link(src, dest, result=result, _unlink=True) - elif e.errno == errno.EXDEV: + elif e.errno == errno.EXDEV or e.errno == errno.EPERM: safe_copy(src, dest) else: raise UtilError("Failed to link '{} -> {}': {}".format(src, dest, e)) from e -- cgit v1.2.1