1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-29 21:50:58 +01:00
Commit graph

4078 commits

Author SHA1 Message Date
regnat
3dbd83b9a1 Check the CA hash when importing stuff in the local store
When adding a path to the local store (via `LocalStore::addToStore`),
ensure that the `ca` field of the provided `ValidPathInfo` does indeed
correspond to the content of the path.
Otherwise any untrusted user (or any binary cache) can add arbitrary
content-addressed paths to the store (as content-addressed paths don’t
need a signature).
2021-06-01 15:21:01 +02:00
Eelco Dolstra
dac86f84c3
Merge pull request #4634 from ianthehenry/backport-user-env-assertion-fix
backport #4411
2021-03-15 16:34:33 +01:00
David McFarland
2fe57daadd Fix insufficent attribute capacity in user profile 2021-03-13 17:32:47 +00:00
Bernardo Meurer
da1629d744
nix-build: set execfail
When starting a nix-shell with `-i` it was previously possible for it to
silently fail in the scenario where the specified interpreter didn't
exist. This happened due to the `exec` call masking the issue.

With this change we enable `execfail`, which causes the script using
`nix-shell` as interpreter to correctly exit with code 127.

Fixes: #4598
(cherry picked from commit 6e849e3b0a)
2021-03-08 02:09:12 -08:00
Matthew Bauer
f95c320500 Handle missing etag in 304 Not Modified response
GitHub now omits the etag, but 304 implies it matches the one we
provided. Just use that one to avoid having an etag-less resource.

Fixes #4469

(cherry picked from commit a766824660)
2021-01-25 12:18:57 -06:00
Stéphan Kochen
024c0eaad1 Fix compatibility with newer AWS SDKs (#4316)
Tested against AWS SDK 1.8.99. Fixes #3201.

(cherry picked from commit e20a3ec756)
2020-12-26 09:09:21 +00:00
Robert Hensing
c29fffeaaa DerivationGoal: only retry if output closure incomplete is only problem
(cherry picked from commit bd9eb5c743)
2020-12-22 11:46:22 +01:00
Domen Kožar
6de15f722d
Allow HTTP binary cache to request absolute uris 2020-12-16 14:13:15 +01:00
Nikola Knezevic
0f35904915 Add support for \u escape in fromJSON
As fromTOML supports \u and \U escapes, bring fromJSON on par. As JSON defaults
to UTF-8 encoding (every JSON parser must support UTF-8), this change parses the
`\u hex hex hex hex` sequence (\u followed by 4 hexadecimal digits) into an
UTF-8 representation.

Add a test to verify correct parsing, using all escape sequences from json.org.
2020-12-15 18:49:32 +01:00
Nikola Knezevic
b595df5423 Remove redundant check in parseJSONString 2020-12-15 18:48:49 +01:00
Luke Granger-Brown
2239953894 When moving paths out of sandbox, ensure we have write permission.
If we're a single-user installation of Nix, then we won't have root
superpowers to just ignore the permission bits. This means that we'll
need permission on the directory (if it's a directory) that we're moving
in order to move it with rename, because it must update the ".."
directory entry.

Fixes #4295.

This is already working in master, thanks to
e913a2989f (and followup cleanups).
2020-12-04 04:33:33 +00:00
Eelco Dolstra
7f1de4d5ed
Merge pull request #3405 from hercules-ci/issue-3398-path-info-cache-ttls-backport-2.3
pathInfoCache: Respect disk cache TTLs #3398 (2.3 backport)
2020-10-29 12:44:16 +01:00
Eelco Dolstra
f09b375837
Prevent a deadlock when user namespace setup fails
Observed on Centos 7 when user namespaces are disabled:
DerivationGoal::startBuilder() throws an exception, ~DerivationGoal()
waits for the child process to exit, but the child process hangs
forever in drainFD(userNamespaceSync.readSide.get()) in
DerivationGoal::runChild(). Not sure why the SIGKILL doesn't get
through.

Issue #4092.

(cherry picked from commit d761485010)
2020-10-07 09:10:24 +02:00
Daiderd Jordan
f6ff68479e never use /var/folders for TMPDIR on darwin
This doesn't just cause problems for nix-store --serve but also results
in certain build failures. Builds that use unix domain sockets in their
tests often fail because the /var/folders prefix already consumes more
than half of the maximum length of socket paths.

    struct sockaddr_un {
       sa_family_t sun_family;               /* AF_UNIX */
       char        sun_path[108];            /* Pathname */
    };

(cherry picked from commit 4d9db420ff)
2020-09-02 15:41:43 +02:00
Eelco Dolstra
d5c7efae38 repl.cc: Check for HAVE_BOEHMGC
Fixes #3906.

(cherry picked from commit 59067f0f58)
2020-08-13 04:34:36 +02:00
Eelco Dolstra
8b04d28a5b
createUnixDomainSocket(): Fix off-by-one error in copying the socket path
Reported by Kane York.

(cherry picked from commit 2292814049)
2020-07-24 20:50:05 +02:00
Jude Taylor
15876ec4a0 nix auto-gc: use fragment size
(cherry picked from commit e2fc575c61)
2020-07-07 15:40:24 +02:00
Eelco Dolstra
3933cf56af
NAR parser: Fix missing name field check
Discovered by @Kloenk.

(cherry picked from commit 2b834d48aa)
2020-06-30 17:53:17 +02:00
Eelco Dolstra
96310a4d7d
nix repl: Scan NixRepl for GC roots
Fixes #3175.

(cherry picked from commit b244e65cdb)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-06-18 10:31:40 +02:00
John Ericson
d2008f2fff
unbreak build without pch
(cherry picked from commit d64ab5131c)
2020-06-02 23:09:19 +02:00
Brian McKenna
35f5da530a
Disable use-sqlite-wal under WSL
Before:

    $ nix-channel --update
    unpacking channels...
    warning: SQLite database '/nix/var/nix/db/db.sqlite' is busy (SQLITE_PROTOCOL)
    warning: SQLite database '/nix/var/nix/db/db.sqlite' is busy (SQLITE_PROTOCOL)
    warning: SQLite database '/nix/var/nix/db/db.sqlite' is busy (SQLITE_PROTOCOL)
    warning: SQLite database '/nix/var/nix/db/db.sqlite' is busy (SQLITE_PROTOCOL)
    warning: SQLite database '/nix/var/nix/db/db.sqlite' is busy (SQLITE_PROTOCOL)

After:

    $ inst/bin/nix-channel --update
    unpacking channels...
    created 1 symlinks in user environment

I've seen complaints that "sandbox" caused problems under WSL but I'm
having no problems. I think recent changes could have fixed the issue.

(cherry picked from commit d25923263e)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-06-01 17:15:33 +02:00
Daiderd Jordan
07e29830c5
sandbox: fix /bin/sh on catalina
Sadly 10.15 changed /bin/sh to a shim which executes bash, this means it
can't be used anymore without also opening up the sandbox to allow bash.

    Failed to exec /bin/bash as variant for /bin/sh (1: Operation not permitted).

(cherry picked from commit 2e9bc1245c)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 12:55:19 +02:00
Daiderd Jordan
27e7153771
sandbox: allow pty devices
Nix now runs builds with a pseudo-terminal to enable colored build
output.

(cherry picked from commit f6c122aaeb)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 12:55:15 +02:00
Daiderd Jordan
f953a51d43
libstore: relax default sandbox-paths on darwin
(cherry picked from commit 7f2df903d9)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 12:55:11 +02:00
Daiderd Jordan
ec9bfa7afd
libstore: disable resolve-system-dependencies hook
This is used to determine the dependency tree of impure libraries so nix
knows what paths to open in the sandbox.  With the less restrictive
defaults it isn't needed anymore.

(cherry picked from commit afb78ebd34)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-05-26 12:55:04 +02:00
Tobias Möst
a25214a2bc
Fix PR_SET_PDEATHSIG results in Broken pipe (#2395)
The ssh client is lazily started by the first worker thread, that
requires a ssh connection. To avoid the ssh client to be killed, when
the worker process is stopped, do not set PR_SET_PDEATHSIG.

(cherry picked from commit 3e347220c8)
2020-04-10 10:45:45 +02:00
Eelco Dolstra
6d01e9a623
Simplify
(cherry picked from commit d1b238ec3c)
2020-04-10 10:45:40 +02:00
Profpatsch
7afd8321ed
libstore/ssh: Improve error message on failing execvp
If the `throw` is reached, this means that execvp into `ssh` wasn’t
successful. We can hint at a usual problem, which is a missing `ssh`
executable.

Test with:

```
env PATH= ./result/bin/nix-copy-closure --builders '' unusedhost
```

and the bash version with

```
env PATH= ./result/bin/nix-copy-closure --builders '' localhost
```

(cherry picked from commit 38b29fb72c)
2020-04-10 10:45:34 +02:00
mlatus
2007b4a89b fix placeholder not substituted in passAsFile
(cherry picked from commit 12556e5709)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-04-10 10:39:35 +02:00
Daiderd Jordan
eba0892d08 libexpr: show expression in assertion errors
Includes the expression of the condition in the assertion message if
the assertion failed, making assertions much easier to debug. eg.

    error: assertion (withPython -> (python2Packages != null)) failed at pkgs/tools/security/nmap/default.nix:11:1

(cherry picked from commit 307bcb9a8e)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-04-10 10:39:35 +02:00
Cole Helbling
7fee49ef37 Don't retry on "unsupported protocol" error
When encountering an unsupported protocol, there's no need to retry.
Chances are, it won't suddenly be supported between retry attempts;
error instead. Otherwise, you see something like the following:

    $ nix-env -i -f git://git@github.com/foo/bar
    warning: unable to download 'git://git@github.com/foo/bar': Unsupported protocol (1); retrying in 335 ms
    warning: unable to download 'git://git@github.com/foo/bar': Unsupported protocol (1); retrying in 604 ms
    warning: unable to download 'git://git@github.com/foo/bar': Unsupported protocol (1); retrying in 1340 ms
    warning: unable to download 'git://git@github.com/foo/bar': Unsupported protocol (1); retrying in 2685 ms

With this change, you now see:

    $ nix-env -i -f git://git@github.com/foo/bar
    error: unable to download 'git://git@github.com/foo/bar': Unsupported protocol (1)

(cherry picked from commit c976cb0b8a)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-04-10 10:39:35 +02:00
Eelco Dolstra
e914cfb06f Downloader: Only write data to the sink on a 200 response
Hopefully fixes #3278.

(cherry picked from commit 1ab8d6ac18)
Signed-off-by: Domen Kožar <domen@dev.si>
2020-04-10 10:39:35 +02:00
Robert Hensing
d549250069 pathInfoCache: Respect disk cache TTLs #3398 2020-03-12 10:33:52 +01:00
Eelco Dolstra
2097983218
Doh 2020-02-18 21:30:31 +01:00
Eelco Dolstra
2f0122b23c
Disable the progress bar if $TERM == dumb or unset
Fixes #3363.

(cherry picked from commit d8fd31f50f)
2020-02-18 18:36:33 +01:00
Robin Gloster
b51ecc02c8
structured-attrs: chown .attrs.* files to builder
Otherwise `chmod .`'ing the build directory doesn't work anymore, which
is done in nixpkgs if sourceRoot is set to '.'.

(cherry picked from commit f8dbde0813)
2020-02-18 16:45:43 +01:00
Domen Kožar
ed25fdd66e
retry on HTTP status code 429
(cherry picked from commit 48ddb8e481)
2020-02-18 16:45:34 +01:00
Eelco Dolstra
e3eecb5927 Move #include
(cherry picked from commit 8beedd4486)
(cherry picked from commit 0678e4d56a)
2020-01-05 16:30:52 +01:00
Eelco Dolstra
f84c3f9d65 Hide FunctionCallTrace constructor/destructor
This prevents them from being inlined. On gcc 9, this reduces the
stack size needed for

  nix-instantiate '<nixpkgs>' -A texlive.combined.scheme-full --dry-run

from 12.9 MiB to 4.8 MiB.

(cherry picked from commit cb90e382b5)
2020-01-05 16:30:38 +01:00
zimbatm
c94fd5f51a function-trace: always show the trace
If the user invokes nix with --trace-function-calls it means that they
want to see the trace.

(cherry picked from commit 619cc4af85)
2020-01-05 16:30:32 +01:00
Puck Meerburg
59bbc31701 Ensure enough space in attrset bindings when using both __overrides and dynamic attributes
(cherry picked from commit cd55f91ad2)
2020-01-04 14:12:13 +01:00
Robin Gloster
3130aafd01 builtins.toJSON: fix __toString usage
(cherry picked from commit e583df5280)
2020-01-04 14:10:56 +01:00
Matthew Bauer
421f1f4493 Move tmpDirInSandbox to initTmpDir
(cherry picked from commit 96c84937c4)
2020-01-04 13:41:42 +01:00
Matthew Bauer
10bf5340ca Fix sandbox fallback settings
The tmpDirInSandbox is different when in sandboxed vs. non-sandboxed.
Since we don’t know ahead of time here whether sandboxing is enabled,
we need to reset all of the env vars we’ve set previously. This fixes
the issue encountered in https://github.com/NixOS/nixpkgs/issues/70856.

(cherry picked from commit 499b038875)
2020-01-04 13:41:35 +01:00
Eelco Dolstra
8b44ed08e7 ssh-ng: Don't set CPU affinity on the remote
Fixes #3138.

(cherry picked from commit 906d56a96b)
2020-01-04 13:41:06 +01:00
Eelco Dolstra
1ac8c0269a SourceExprCommand::getSourceExpr(): Allocate more space
Fixes #3140.

(cherry picked from commit 389a2cebed)
2020-01-04 13:40:56 +01:00
ng0
a53e4e217b include netinet/in.h in src/nix/main.cc
Fixes #3186

(cherry picked from commit b811bd2172)
2020-01-04 13:40:14 +01:00
Harald van Dijk
61855a4e7b Fix progress bar when nix-prefetch-url is piped.
The intent of the code was that if the window size cannot be determined,
it would be treated as having the maximum possible size. Because of a
missing assignment, it was actually treated as having a width of 0.

The reason the width could not be determined was because it was obtained
from stdout, not stderr, even though the printing was done to stderr.

This commit addresses both issues.

(cherry picked from commit c935ad3f02)
2020-01-04 13:40:03 +01:00
Brian Wignall
9b4e99801f Fix typos
(cherry picked from commit 8737980e75)
2020-01-04 13:39:19 +01:00
Eelco Dolstra
8be0440d44 EvalState::callFunction(): Make FunctionCallTrace use less stack space
The FunctionCallTrace object consumes a few hundred bytes of stack
space, even when tracing is disabled. This was causing stack overflows:

  $ nix-instantiate '<nixpkgs> -A texlive.combined.scheme-full --dry-run
  error: stack overflow (possible infinite recursion)

This is with the default stack size of 8 MiB.

Putting the object on the heap reduces stack usage to < 5 MiB.

(cherry picked from commit 98ef11677c)
2020-01-04 13:38:42 +01:00