Commit Graph

17424 Commits

Author SHA1 Message Date
Eelco Dolstra
c3e907af7d Warn if the download buffer is full
(cherry picked from commit f6a9a71b38)
2024-07-29 13:02:58 +00:00
Eelco Dolstra
78046450ab Add 'download-buffer-size' setting
We are piping curl downloads into `unpackTarfileToSink()`, but the
latter is typically slower than the former if you're on a fast
connection. So the download could appear unnecessarily slow. (There is
even a risk that if the Git import is *really* slow for whatever
reason, the TCP connection could time out.)

So let's make the download buffer bigger by default - 64 MiB is big
enough for the Nixpkgs tarball. Perhaps in the future, we could have
an unlimited buffer that spills data to disk beyond a certain
threshold, but that's probably overkill.

(cherry picked from commit 8ffea0a018)
2024-07-29 13:02:57 +00:00
Eelco Dolstra
7698e53b0b Log download durations
(cherry picked from commit caf4e98f0c)
2024-07-29 13:02:57 +00:00
Eelco Dolstra
051f3773db
Merge pull request #11194 from NixOS/backport-11086-to-2.23-maintenance
[Backport 2.23-maintenance] Eval cache: fix cache regressions
2024-07-26 18:26:25 +02:00
Lexi Mattick
77e4802ce2 Clean up cache for all commands
(cherry picked from commit 6c4470ec2a)
2024-07-26 15:59:36 +00:00
Lexi Mattick
6925a772d0 Eval cache: fix cache regressions
- Fix eval cache not being persisted in `nix develop` (since #10570)
- Don't attempt to commit cache transaction if there is no active transaction, which will spew errors in edge cases
- Drive-by: trivial typo fix

(cherry picked from commit e764ed31f6)
2024-07-26 15:59:36 +00:00
Eelco Dolstra
707a6c550f
Merge pull request #11128 from NixOS/backport-10852-to-2.23-maintenance
[Backport 2.23-maintenance] add call to `checkInterrupt` in a bunch of places
2024-07-17 18:28:29 +02:00
siddhantCodes
af8a1715e1 add call to checkInterrupt in a bunch of places
This brings back the old behaviour. We check for interrupts in places
that may iterate over wide directories.

(cherry picked from commit 8f1a26667e)
2024-07-17 16:02:07 +00:00
Eelco Dolstra
180dfa44b2 Bump version 2024-07-08 12:36:05 +02:00
Robert Hensing
f1deb42176
Merge pull request #11052 from NixOS/backport-11051-to-2.23-maintenance
[Backport 2.23-maintenance] src/nix/prefetch: fix prefetch containing current directory instead o…
2024-07-05 23:00:08 +02:00
Jörg Thalheim
d58592469d Update src/nix/prefetch.cc
Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
(cherry picked from commit 05381c0b30)
2024-07-05 18:33:21 +00:00
Jörg Thalheim
73f3179954 src/nix/prefetch: fix prefetch containing current directory instead of tarball
When --unpack was used the nix would add the current directory to the
nix store instead of the content of unpacked.
The reason for this is that std::distance already consumes the iterator.
To fix this we re-instantiate the directory iterator in case the
directory only contains a single entry.

(cherry picked from commit 8cea1fbd97)
2024-07-05 18:33:21 +00:00
Eelco Dolstra
df877f4522 Bump version 2024-07-05 19:40:34 +02:00
Eelco Dolstra
39735546f1
Merge pull request #11045 from NixOS/backport-11031-to-2.23-maintenance
[Backport 2.23-maintenance] libstore: fix sandboxed builds on macOS
2024-07-05 17:43:30 +02:00
Emily
b74f140866 libstore: fix sandboxed builds on macOS
The recent fix for CVE-2024-38531 broke the sandbox on macOS
completely. As it’s not practical to use `chroot(2)` on
macOS, the build takes place in the main filesystem tree, and the
world‐unreadable wrapper directory prevents the build from accessing
its `$TMPDIR` at all.

The macOS sandbox probably shouldn’t be treated as any kind of a
security boundary in its current state, but this specific vulnerability
wasn’t possible to exploit on macOS anyway, as creating `set{u,g}id`
binaries is blocked by sandbox policy.

Locking down the build sandbox further may be a good idea in future,
but it already has significant compatibility issues. For now, restore
the previous status quo on macOS.

Thanks to @alois31 for helping me come to a better understanding of
the vulnerability.

Fixes: 1d3696f0fb
Closes: #11002
(cherry picked from commit af2e1142b1)
2024-07-05 15:09:04 +00:00
Emily
639c2ffc9d libstore: clean up the build directory properly
After the fix for CVE-2024-38531, this was only removing the nested
build directory, rather than the top‐level temporary directory.

Fixes: 1d3696f0fb
(cherry picked from commit 76e4adfaac)
2024-07-05 15:09:04 +00:00
Eelco Dolstra
a5c2e1ef44
Merge pull request #11042 from NixOS/backport-11020-to-2.23-maintenance
[Backport 2.23-maintenance] Tarball fetcher: Fix fetchToStore() and eval caching
2024-07-05 16:55:08 +02:00
Eelco Dolstra
b91c7cf077 Tarball fetcher: Include revCount/lastModified in the fingerprint
This can influence the evaluation result so they should be included in
the fingerprint.

(cherry picked from commit 5b4102c3b2)
2024-07-05 14:30:29 +00:00
Eelco Dolstra
e38f45b19f nix flake metadata: Show flake fingerprint
This is useful for testing/debugging and maybe for sharing eval caches
(since it tells you what file in ~/.cache/nix/eval-cache-v5 to copy).

(cherry picked from commit 1ff186fc6e)
2024-07-05 14:30:29 +00:00
Eelco Dolstra
241c539f6f Tarball fetcher: Fix fetchToStore() and eval caching
(cherry picked from commit 9d95c228ee)
2024-07-05 14:30:29 +00:00
Robert Hensing
50a71b69b0
Merge pull request #11032 from NixOS/backport-11009-to-2.23-maintenance
[Backport 2.23-maintenance] Installer tests
2024-07-03 20:55:28 +02:00
Robert Hensing
49ae3b4166 installerScriptForGHA: aarch64-darwin
GitHub Actions seems to have magically switched architectures
without changing their identifiers.
See 2813ee66cb/README.md (available-images)
Maybe they have more complete documentation elsewhere, but it
seems to be incapable of selecting a runner based on architecture.

(cherry picked from commit df3e92ff96)
2024-07-03 18:22:47 +00:00
Robert Hensing
6d6ddbf36c
Merge pull request #11029 from NixOS/backport-11022-to-2.23-maintenance
[Backport 2.23-maintenance] Use proper struct sockpeercred for SO_PEERCRED for OpenBSD
2024-07-03 19:59:33 +02:00
kn
4e781b4eaa Use proper struct sockpeercred for SO_PEERCRED for OpenBSD
getsockopt(2) documents this;  ucred is wrong ("cr_" member prefix, no pid).

(cherry picked from commit 10ccdb7a41)
2024-07-03 15:57:17 +00:00
John Ericson
5d32212b27 Ident some CPP in nix daemon
Makes it easier for me to read.

(cherry picked from commit a09360400b)
2024-07-03 15:57:17 +00:00
Eelco Dolstra
f80e0832bc
Merge pull request #11000 from hercules-ci/backport-10992-to-2.23-maintenance
[Backport 2.23-maintenance] Fix #10947; don't cache disallowed IFD
2024-07-01 14:14:04 +02:00
Robert Hensing
11491a2f1f Fix rl-next/harden-user-sandboxing.md syntax 2024-07-01 12:57:28 +02:00
Robert Hensing
3f4e344572 Format 2024-07-01 11:38:14 +02:00
Robert Hensing
6432c21b01 Fix #10947; don't cache disallowed IFD
(cherry picked from commit fd94b74ee5)
2024-07-01 11:25:08 +02:00
Eelco Dolstra
53a5266220 Bump version 2024-06-27 13:14:43 +02:00
tomberek
20ac781190
Merge pull request from GHSA-q82p-44mg-mgh5
Fix sandbox escape 2.23
2024-06-26 18:49:22 -04:00
Eelco Dolstra
d7f018041e
Merge pull request #10950 from NixOS/backport-10943-to-2.23-maintenance
[Backport 2.23-maintenance] Accept response from gitlab api with more than one entry in json
2024-06-24 14:24:53 +02:00
Shogo Takata
fd14479103 accept response from gitlab with more than one entry
(cherry picked from commit 0468061dd2)
2024-06-24 12:24:06 +00:00
Eelco Dolstra
07b9fae361 Fix --no-sandbox
When sandboxing is disabled, we cannot put $TMPDIR underneath an
inaccessible directory.

(cherry picked from commit d54590fdf3)
2024-06-21 17:07:59 +02:00
Eelco Dolstra
71af23ff18 Formatting
(cherry picked from commit 58b7b3fd15)
2024-06-21 17:07:55 +02:00
Eelco Dolstra
0882b75ceb Put the chroot inside a directory that isn't group/world-accessible
Previously, the .chroot directory had permission 750 or 755 (depending
on the uid-range system feature) and was owned by root/nixbld. This
makes it possible for any nixbld user (if uid-range is disabled) or
any user (if uid-range is enabled) to inspect the contents of the
chroot of an active build and maybe interfere with it (e.g. via /tmp
in the chroot, which has 1777 permission).

To prevent this, the root is now a subdirectory of .chroot, which has
permission 700 and is owned by root/root.

(cherry picked from commit ede95b1fc1)
2024-06-21 17:07:51 +02:00
Théophane Hufschmitt
a156c597ff Add a release note for the build-dir hardening
(cherry picked from commit d99c868b04)
2024-06-21 17:07:46 +02:00
Théophane Hufschmitt
930bb21893 Run the builds in a daemon-controled directory
Instead of running the builds under
`$TMPDIR/{unique-build-directory-owned-by-the-build-user}`, run them
under `$TMPDIR/{unique-build-directory-owned-by-the-daemon}/{subdir-owned-by-the-build-user}`
where the build directory is only readable and traversable by the daemon user.

This achieves two things:

1. It prevents builders from making their build directory world-readable
   (or even writeable), which would allow the outside world to interact
   with them.
2. It prevents external processes running as the build user (either
   because that somehow leaked, maybe as a consequence of 1., or because
   `build-users` isn't in use) from gaining access to the build
   directory.

(cherry picked from commit 1d3696f0fb)
2024-06-21 17:07:41 +02:00
Théophane Hufschmitt
022f2db6ef Add a test for the user sandboxing
(cherry picked from commit 717f3eea39)
2024-06-21 17:07:37 +02:00
Robert Hensing
560ca6f54f
Merge pull request #10901 from NixOS/backport-10900-to-2.23-maintenance
[Backport 2.23-maintenance] hash: Compare hash algo second for back compat
2024-06-13 12:37:38 +02:00
John Ericson
bbccb2fc43 hash: Compare hash algo second for back compat
Previously (in cfc18a7739), we forgot to
compare the algo at all. This means we keep the same ordering as before
by making the stuff we always have compared take priority.

(cherry picked from commit 25a9894943)
2024-06-12 23:35:49 +00:00
Eelco Dolstra
97253a92c2 Bump version 2024-06-12 15:00:47 +02:00
Robert Hensing
ba36959311
Merge pull request #10885 from NixOS/backport-10883-to-2.23-maintenance
[Backport 2.23-maintenance] fix: remove usage of XDG_RUNTIME_DIR for TMP
2024-06-10 16:47:22 +02:00
Tom Bereknyei
19b179cb08 fix: remove usage of XDG_RUNTIME_DIR for TMP
(cherry picked from commit 1363f51bcb)
2024-06-10 13:40:45 +00:00
Eelco Dolstra
c148aaa998
Merge pull request #10863 from NixOS/backport-10861-to-2.23-maintenance
[Backport 2.23-maintenance] PackageInfo::queryDrvPath(): Don't dereference an empty optional
2024-06-05 17:17:28 +02:00
Eelco Dolstra
61ab873a22 Typo
(cherry picked from commit 3e72ed9743)
2024-06-05 14:48:28 +00:00
Eelco Dolstra
4d788bda18 PackageInfo::queryDrvPath(): Don't dereference an empty optional
Fixes a regression introduced in f923ed6b6a.

https://hydra.nixos.org/build/262267313
(cherry picked from commit d2eeabf3e6)
2024-06-05 14:48:28 +00:00
Eelco Dolstra
bd8ec66189 Mark official release 2024-06-04 16:23:19 +02:00
Eelco Dolstra
b36aa04b53
Merge pull request #10836 from edolstra/release-notes
2.23 release notes
2024-06-04 13:00:06 +02:00
Eelco Dolstra
21be03b233
Merge pull request #10840 from obsidiansystems/libutil-pkg-config
Create and install a `nix-util.pc`
2024-06-04 12:33:37 +02:00