Commit Graph

15002 Commits

Author SHA1 Message Date
Puck Meerburg
b61952212e fix passing CA files into builtins:fetchurl sandbox
This patch has been manually adapted from
14dc84ed03

Tested with:

$ NIX_SSL_CERT_FILE=$(nix-build '<nixpkgs>' -A cacert)/etc/ssl/certs/ca-bundle.crt nix-build --store $(mktemp -d) -E 'import <nix/fetchurl.nix> { url = https://google.com; }'
warning: found empty hash, assuming 'sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA='
this derivation will be built:
  /nix/store/4qljhy0jj2b0abjzpsbyarpia1bqylwc-google.com.drv
building '/nix/store/4qljhy0jj2b0abjzpsbyarpia1bqylwc-google.com.drv'...
error:
       … writing file '/nix/store/0zynn4n8yx59bczy1mgh1lq2rnprvvrc-google.com'

       error: unable to download 'https://google.com': Problem with the SSL CA cert (path? access rights?) (77)
error: builder for '/nix/store/4qljhy0jj2b0abjzpsbyarpia1bqylwc-google.com.drv' failed with exit code 1

Now returns:

nix-env % NIX_SSL_CERT_FILE=$(nix-build '<nixpkgs>' -A cacert)/etc/ssl/certs/ca-bundle.crt nix-build --store $(mktemp -d) -E 'import <nix/fetchurl.nix> { url = https://google.com; }'
this derivation will be built:
  /nix/store/4qljhy0jj2b0abjzpsbyarpia1bqylwc-google.com.drv
building '/nix/store/4qljhy0jj2b0abjzpsbyarpia1bqylwc-google.com.drv'...
error: hash mismatch in fixed-output derivation '/nix/store/4qljhy0jj2b0abjzpsbyarpia1bqylwc-google.com.drv':
         specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
            got:    sha256-5xXEhGtnRdopaUTqaz2M1o2NE7ovhU0SjcSOPwntqwY=

(cherry picked from commit 1fbdf409524bb350b8614f3d95067cb9ba3c57f2)
2024-10-14 15:26:31 +02:00
Puck Meerburg
8f3bda8276 fixup! Add a test for builtin:fetchurl cert verification 2024-10-14 15:26:25 +02:00
Eelco Dolstra
fb02a952bd Bump version 2024-09-26 11:58:04 +02:00
Eelco Dolstra
501a805fcd
Merge pull request #11586 from NixOS/mergify/bp/2.18-maintenance/pr-11585
builtin:fetchurl: Enable TLS verification (backport #11585)
2024-09-26 00:49:30 +02:00
Eelco Dolstra
798e0bc75e Typo
(cherry picked from commit ef8987955b)
2024-09-26 00:18:08 +02:00
Eelco Dolstra
5e76cdbc79 Add release note
(cherry picked from commit 7b39cd631e)
2024-09-26 00:18:08 +02:00
Eelco Dolstra
c65ce6c6ec builtin:fetchurl: Enable TLS verification
This is better for privacy and to avoid leaking netrc credentials in a
MITM attack, but also the assumption that we check the hash no longer
holds in some cases (in particular for impure derivations).

Partially reverts 5db358d4d7.

(cherry picked from commit c04bc17a5a)
2024-09-25 21:53:27 +00:00
Eelco Dolstra
691f67d83e Bump version 2024-09-19 19:29:05 +02:00
John Ericson
d4d300c208
Merge pull request #11534 from fricklerhandwerk/backport-10652-to-2.18-maintenance
[backport 2.18] libstore: check additionalSandboxProfile
2024-09-18 15:42:38 -04:00
Théophane Hufschmitt
1524ad38d2 libstore: check additionalSandboxProfile
Make sure that `extraSandboxProfile` is set before we check whether it's
empty or not (in the `sandbox=true` case).

Also adds a test case for this.

Co-Authored-By: Artemis Tosini <lix@artem.ist>
Co-Authored-By: Eelco Dolstra <edolstra@gmail.com>
(cherry picked from commit 9bd1191fcc)
2024-09-18 21:17:07 +02:00
Eelco Dolstra
9f526847e4 Bump version 2024-09-16 20:45:50 +02:00
tomberek
a8196707ad
Merge pull request #11415 from NixOS/mergify/bp/2.18-maintenance/pr-10919
install-darwin: fix _nixbld uids for macOS sequoia (backport #10919)
2024-09-16 09:19:45 -04:00
Robert Hensing
aa6f7561eb
Merge pull request #11478 from NixOS/mergify/bp/2.18-maintenance/pr-11473
Fix making the build directory kept by `keep-failed` readable (backport #11473)
2024-09-16 12:38:33 +02:00
Artturin
30994e6ef4 Fix making the build directory kept by keep-failed readable
Caused by 1d3696f0fb

Without this fix the kept build directory is readable only by root

```
$ sudo ls -ld /comp-temp/nix-build-openssh-static-x86_64-unknown-linux-musl-9.8p1.drv-5
drwx------ root root 60 B Wed Sep 11 00:09:48 2024  /comp-temp/nix-build-openssh-static-x86_64-unknown-linux-musl-9.8p1.drv-5/

$ sudo ls -ld /comp-temp/nix-build-openssh-static-x86_64-unknown-linux-musl-9.8p1.drv-5/build
drwxr-xr-x nixbld1 nixbld 80 B Wed Sep 11 00:09:58 2024  /comp-temp/nix-build-openssh-static-x86_64-unknown-linux-musl-9.8p1.drv-5/build/
```

(cherry picked from commit ebebe626ff)
2024-09-11 12:54:09 +00:00
tomberek
e818523eb1
Merge branch '2.18-maintenance' into mergify/bp/2.18-maintenance/pr-10919 2024-09-10 23:39:51 -04:00
tomberek
e0fdea89c3
Merge pull request #11474 from NixOS/mergify/bp/2.18-maintenance/pr-9639
installer: allow overriding of NIX_FIRST_BUILD_ID on darwin (backport #9639)
2024-09-10 23:21:12 -04:00
Mel Zuser
c42e3e5b33 installer: allow overriding of NIX_FIRST_BUILD_ID on darwin
because there are often already users in the 300 range and it's painful
to work around.

revives #6466

(cherry picked from commit fa4bbe53e8)
2024-09-11 01:35:09 +00:00
Robert Hensing
6354f84475
Merge pull request #11445 from eclairevoyant/backport-10564-to-2.18
[backport 2.18-maintenance] AttrCursor: Remove forceErrors
2024-09-09 18:42:57 +02:00
Robert Hensing
ffaeb4b076
Merge pull request #11450 from NixOS/backport-11009-to-2.18-maintenance
installerScriptForGHA: aarch64-darwin
2024-09-09 17:57:40 +02:00
Robert Hensing
1b0805d451 installerScriptForGHA: aarch64-darwin
Backport of https://github.com/NixOS/nix/pull/11009
2024-09-09 17:47:27 +02:00
Robert Hensing
5bcc7069be Store ref<EvalState> in CachedEvalError
This makes the previous commits work.
Newer versions store it in all EvalErrors.
2024-09-09 00:38:28 +02:00
éclairevoyant
ef63ba10a2
fix 2024-09-08 12:04:26 -04:00
Eelco Dolstra
fc14197935
Typo
(cherry picked from commit eeb4c40867)
2024-09-08 10:31:25 -04:00
Eelco Dolstra
8e5ec819f8
AttrCursor: Remove forceErrors
Instead, force evaluation of the original value only if we need to
show the exception to the user.

(cherry picked from commit 2c88930ef2)
2024-09-08 10:31:23 -04:00
Eelco Dolstra
e3c55dd0d3
Add test for the evaluation cache
(cherry picked from commit 8b86f415c1)
2024-09-08 10:26:47 -04:00
Emily
517b48ffc4 install-darwin: increment base UID by 1 (#15)
(cherry picked from commit 11cf29b15c)
2024-09-03 23:57:06 +00:00
Travis A. Everett
4851e171b8 install-darwin: move nixbld gid to match first UID
(cherry picked from commit 75567423fb)

# Conflicts:
#	scripts/install-multi-user.sh
#	scripts/install-systemd-multi-user.sh
2024-09-03 23:57:05 +00:00
Travis A. Everett
3d380ed77a install-darwin: fix _nixbld uids for macOS sequoia
Starting in macOS 15 Sequoia, macOS daemon UIDs are encroaching on our
default UIDs of 301-332. This commit relocates our range up to avoid
clashing with the current UIDs of 301-304 and buy us a little time
while still leaving headroom for people installing more than 32 users.

(cherry picked from commit df36ff0d1e)

# Conflicts:
#	scripts/install-darwin-multi-user.sh
2024-09-03 23:57:05 +00:00
Robert Hensing
e154f412b7
Merge pull request #11336 from NixOS/backport-11332-to-2.18-maintenance
[Backport 2.18-maintenance] [Backport 2.22-maintenance] fix: check to see if there are any lines before
2024-08-19 17:05:38 +02:00
Tom Bereknyei
0d24420f9c fix: check to see if there are any lines before
(cherry picked from commit 59db8fd62b)
(cherry picked from commit aab801db98)
2024-08-19 14:28:08 +00:00
Eelco Dolstra
195c3e931f Bump version 2024-07-08 13:41:12 +02:00
Robert Hensing
217fadd993
Merge pull request #11047 from NixOS/backport-11046-to-2.18-maintenance
[Backport 2.18-maintenance] [Backport 2.21-maintenance] libstore: fix sandboxed builds on macOS
2024-07-05 19:40:45 +02:00
Emily
0b97319ed4 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)
(cherry picked from commit 9feee13952)
2024-07-05 15:59:20 +00:00
Emily
ff7b9a1fd3 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)
(cherry picked from commit 0d68b40dda)
2024-07-05 15:59:20 +00:00
Robert Hensing
5e160c9cfe
Merge pull request #11024 from NixOS/backport-11022-to-2.18-maintenance
[Backport 2.18-maintenance] Use proper struct sockpeercred for SO_PEERCRED for OpenBSD
2024-07-03 19:58:35 +02:00
kn
454adc40f7 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:56:59 +00:00
John Ericson
1836493f67 Ident some CPP in nix daemon
Makes it easier for me to read.

(cherry picked from commit a09360400b)
2024-07-03 15:56:59 +00:00
Eelco Dolstra
ab9f629150 Bump version 2024-06-27 11:24:27 +02:00
tomberek
1ee7a9b84f
Merge pull request from GHSA-q82p-44mg-mgh5
Fix sandbox escape 2.18
2024-06-26 18:49:22 -04:00
Eelco Dolstra
2778076699 Fix --no-sandbox
When sandboxing is disabled, we cannot put $TMPDIR underneath an
inaccessible directory.

(cherry picked from commit 86ca2d6d94c0581fda0c666c5e022784952f3542)
(cherry picked from commit 8f58b98770)
2024-06-21 16:51:11 +02:00
Eelco Dolstra
c211d3d9fe 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 af280e72fa0e62e1c2eaccfb992c0dbb6f27f895)
2024-06-21 16:50:12 +02:00
Eelco Dolstra
5d7d7d8648 Bump version 2024-06-19 18:33:05 +02:00
Robert Hensing
c7d35a4a4d
Merge pull request #10889 from NixOS/backport-10883-to-2.18-maintenance
[Backport 2.18-maintenance] fix: remove usage of XDG_RUNTIME_DIR for TMP
2024-06-10 21:01:27 +02:00
Tom Bereknyei
15fe2a81d9 fix: remove usage of XDG_RUNTIME_DIR for TMP
(cherry picked from commit 1363f51bcb)
2024-06-10 15:07:28 +00:00
Robert Hensing
fbe66d11d9
Merge pull request #10887 from NixOS/backport-10303-to-2.18-maintenance
[Backport 2.18-maintenance] fix: Treat empty TMPDIR as unset (#10303)
2024-06-10 16:48:31 +02:00
Robert Hensing
20a46e17a8 Fix includes for cherry-picks 2024-06-10 16:22:11 +02:00
Robert Hensing
45d900f5c2 HttpBinaryCacheStore: Remove *all* trailing slashes
(cherry picked from commit 850c9a6caf)
2024-06-10 16:11:04 +02:00
Robert Hensing
d1848506f8 local-derivation-goal.cc: Remove *all* trailing slashes
(cherry picked from commit dd26f41379)
2024-06-10 16:11:04 +02:00
Robert Hensing
28fc0e4f58 local-derivation-goal.cc: Reuse defaultTempDir()
(cherry picked from commit fd31945742)
2024-06-10 16:11:04 +02:00
Robert Hensing
c1f69dfc5e fix: Treat empty XDG_RUNTIME_DIR as unset
See preceding commit. Not observed in the wild, but is sensible
and consistent with TMPDIR behavior.

(cherry picked from commit b9e7f5aa2d)
2024-06-10 16:11:03 +02:00