diff options
| -rw-r--r-- | nix/libstore/build.cc | 8 | ||||
| -rw-r--r-- | tests/store.scm | 11 |
2 files changed, 17 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) |
diff --git a/tests/store.scm b/tests/store.scm index 112ea7e2fcb..16dcbf2396d 100644 --- a/tests/store.scm +++ b/tests/store.scm | |||
| @@ -417,6 +417,17 @@ | |||
| 417 | get-string-all) | 417 | get-string-all) |
| 418 | a)))) | 418 | a)))) |
| 419 | 419 | ||
| 420 | ;; https://codeberg.org/guix/guix/issues/1104 | ||
| 421 | (test-equal "build outputs aren't writable" | ||
| 422 | #o555 | ||
| 423 | (let ((drv (build-expression->derivation %store "writable-output" | ||
| 424 | `(begin | ||
| 425 | ,(random-text) | ||
| 426 | (mkdir %output) | ||
| 427 | (chmod %output #o755))))) | ||
| 428 | (build-derivations %store (list drv)) | ||
| 429 | (stat:perms (stat (derivation->output-path drv "out"))))) | ||
| 430 | |||
| 420 | (unless (unprivileged-user-namespace-supported?) | 431 | (unless (unprivileged-user-namespace-supported?) |
| 421 | (test-skip 1)) | 432 | (test-skip 1)) |
| 422 | (test-equal "isolated environment" | 433 | (test-equal "isolated environment" |
