diff options
| author | Reepca Russelstein <reepca@russelstein.xyz> | 2025-09-05 01:59:12 -0500 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2025-09-23 11:13:22 +0200 |
| commit | c87a9b855e12fafbafcd2af37fd53374cf965ce8 (patch) | |
| tree | c2f5677ef1f9307941447a96b99f6fdfd0a977a7 /nix/libstore | |
| parent | d042111c9e7a530f6627fff2beae334db6d91fca (diff) | |
daemon: Restore post-canonicalization permissions after moving.
At this point the value of 'st.st_mode' is from before canonicalization, so
restoring to that will undo the permissions aspect of the canonicalization for
a top-level directory store item.
Fixes #1104, introduced in
ae18b3d9e6 (https://codeberg.org/guix/guix/commit/ae18b3d9e6bd0c184505a094851448d08555e23e).
* nix/libstore/build.cc (DerivationGoal::registerOutputs): update 'st' with
post-canonicalization permissions before making actualPath
temporarily-writable.
* tests/store.scm ("build outputs aren't writable"): new test.
Change-Id: I5e5eaa79fa6b7f81e1d12fd285883c762a22ce5a
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'nix/libstore')
| -rw-r--r-- | nix/libstore/build.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc index 0a4de96d51d..a48214a9c0a 100644 --- a/nix/libstore/build.cc +++ b/nix/libstore/build.cc | |||
| @@ -3139,10 +3139,14 @@ void DerivationGoal::registerOutputs() | |||
| 3139 | replaceValidPath(path, actualPath); | 3139 | replaceValidPath(path, actualPath); |
| 3140 | else | 3140 | else |
| 3141 | if (buildMode != bmCheck) { | 3141 | if (buildMode != bmCheck) { |
| 3142 | if (S_ISDIR(st.st_mode)) | 3142 | if (S_ISDIR(st.st_mode)) { |
| 3143 | if (lstat(actualPath.c_str(), &st) == -1) | ||
| 3144 | throw SysError(format("getting canonicalized permissions of directory `%1%'") % actualPath); | ||
| 3143 | /* Change mode on the directory to allow for | 3145 | /* Change mode on the directory to allow for |
| 3144 | rename(2). */ | 3146 | rename(2). */ |
| 3145 | chmod(actualPath.c_str(), st.st_mode | 0700); | 3147 | if (chmod(actualPath.c_str(), st.st_mode | 0700) == -1) |
| 3148 | throw SysError(format("making `%1%' writable for move from chroot to store") % actualPath); | ||
| 3149 | } | ||
| 3146 | if (rename(actualPath.c_str(), path.c_str()) == -1) | 3150 | if (rename(actualPath.c_str(), path.c_str()) == -1) |
| 3147 | throw SysError(format("moving build output `%1%' from the chroot to the store") % path); | 3151 | throw SysError(format("moving build output `%1%' from the chroot to the store") % path); |
| 3148 | if (S_ISDIR(st.st_mode) && chmod(path.c_str(), st.st_mode) == -1) | 3152 | if (S_ISDIR(st.st_mode) && chmod(path.c_str(), st.st_mode) == -1) |
