Commit Graph

3752 Commits

Author SHA1 Message Date
Daniel Hahler ba5888bccd Fix typos: s/the the/the/ 2015-06-03 21:59:57 +02:00
Eelco Dolstra 67af480244 Use chroots for all derivations
If ‘build-use-chroot’ is set to ‘true’, fixed-output derivations are
now also chrooted. However, unlike normal derivations, they don't get
a private network namespace, so they can still access the
network. Also, the use of the ‘__noChroot’ derivation attribute is
no longer allowed.

Setting ‘build-use-chroot’ to ‘relaxed’ gives the old behaviour.

Note for Guix: unlike Nix commit 99897f6, we keep 'settings.useChroot'.
2015-06-03 21:55:59 +02:00
Harald van Dijk 638f3675e1 Use pivot_root in addition to chroot when possible
chroot only changes the process root directory, not the mount namespace root
directory, and it is well-known that any process with chroot capability can
break out of a chroot "jail". By using pivot_root as well, and unmounting the
original mount namespace root directory, breaking out becomes impossible.

Non-root processes typically have no ability to use chroot() anyway, but they
can gain that capability through the use of clone() or unshare(). For security
reasons, these syscalls are limited in functionality when used inside a normal
chroot environment. Using pivot_root() this way does allow those syscalls to be
put to their full use.
2015-06-03 21:39:02 +02:00
Eelco Dolstra 8ab23f2924 Simplify parseHash32 2015-06-03 18:34:49 +02:00
Eelco Dolstra 70c3d2f176 Simplify printHash32 2015-06-03 18:34:05 +02:00
Eelco Dolstra 7a7a15877f Doh^2 2015-06-03 18:30:50 +02:00
Eelco Dolstra 8c94a864d8 Doh 2015-06-03 18:30:22 +02:00
Eelco Dolstra 35605c4407 Set /nix/store permission to 1737
I.e., not readable to the nixbld group. This improves purity a bit for
non-chroot builds, because it prevents a builder from enumerating
store paths (i.e. it can only access paths it knows about).
2015-06-03 18:29:21 +02:00
aszlig 0b9c4a8b80 libutil: Limit readLink() error to only overflows.
Let's not just improve the error message itself, but also the behaviour
to actually work around the ntfs-3g symlink bug. If the readlink() call
returns a smaller size than the stat() call, this really isn't a problem
even if the symlink target really has changed between the calls.

So if stat() reports the size for the absolute path, it's most likely
that the relative path is smaller and thus it should also work for file
system bugs as mentioned in 93002d69fc58c2b71e2dfad202139230c630c53a.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Tested-by: John Ericson <Ericson2314@Yahoo.com>
2015-06-03 18:20:44 +02:00
aszlig 0fed5fde65 libutil: Improve errmsg on readLink size mismatch.
A message like "error: reading symbolic link `...' : Success" really is
quite confusing, so let's not indicate "success" but rather point out
the real issue.

We could also limit the check of this to just check for non-negative
values, but this would introduce a race condition between stat() and
readlink() if the link target changes between those two calls, thus
leading to a buffer overflow vulnerability.

Reported by @Ericson2314 on IRC. Happened due to a possible ntfs-3g bug
where a relative symlink returned the absolute path (st_)size in stat()
while readlink() returned the relative size.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Tested-by: John Ericson <Ericson2314@Yahoo.com>
2015-06-03 18:19:32 +02:00
Eelco Dolstra 7dfd3f5c8f Pedantry 2015-06-03 18:16:31 +02:00
Marko Durkovic 45a145c8b2 Explicitly include required C headers 2015-06-03 18:15:57 +02:00
Eelco Dolstra 66d086cc26 Better error message 2015-06-03 18:15:11 +02:00
Eelco Dolstra b499d2efbf Silence some warnings on GCC 4.9 2015-06-03 18:14:48 +02:00
Eelco Dolstra 159b7103a7 Shut up a Valgrind warning 2015-06-03 18:08:58 +02:00
Eelco Dolstra 7930b2cb76 Fix some memory leaks 2015-06-03 18:08:39 +02:00
Eelco Dolstra 5c84e4950d Ensure we're writing to stderr in the builder
http://hydra.nixos.org/build/17862041
2015-06-03 18:05:33 +02:00
Eelco Dolstra ccade8c120 Get rid of unnecessary "interrupted by the user" message with -vvv 2015-06-03 18:04:04 +02:00
Eelco Dolstra 8d9a0be278 Remove tabs 2015-06-03 18:03:14 +02:00
Eelco Dolstra 1f8456ff13 Use PR_SET_PDEATHSIG to ensure child cleanup 2015-06-03 17:59:53 +02:00
Ludovic Courtès 909f1260e2 Rename 'initChild' to 'runChild'.
This is similar to commit b5ed5b6 in upstream Nix.
2015-06-03 17:54:33 +02:00
Eelco Dolstra 3bfa70b796 Don't wait for PID -1
The pid field can be -1 if forking the substituter process failed.
2015-05-11 17:44:08 +02:00
Eelco Dolstra 5241aec531 Build derivations in a more predictable order
Derivations are now built in order of derivation name, so a package
named "aardvark" is built before "baboon".

Fixes #399.
2015-05-11 17:42:53 +02:00
Eelco Dolstra 9f355738e1 Don't create unnecessary substitution goals for derivations 2015-05-11 17:42:43 +02:00
Eelco Dolstra 554eaf5e8c Disable vacuuming the DB after garbage collection
Especially in WAL mode on a highly loaded machine, this is not a good
idea because it results in a WAL file of approximately the same size
ad the database, which apparently cannot be deleted while anybody is
accessing it.
2015-05-11 17:42:18 +02:00
Eelco Dolstra 4eb62b5230 nix-daemon: Call exit(), not _exit()
This was preventing destructors from running. In particular, it was
preventing the deletion of the temproot file for each worker
process. It may also have been responsible for the excessive WAL
growth on Hydra (due to the SQLite database not being closed
properly).

Apparently broken by accident in
8e9140cfde.
2015-05-11 17:41:56 +02:00
Eelco Dolstra f160a30d56 Clean up temp roots in a more C++ way 2015-05-11 17:40:44 +02:00
Eelco Dolstra a64744477d Fix message 2015-05-11 17:40:28 +02:00
Eelco Dolstra b73de6e49b Don't use ADDR_LIMIT_3GB
This gives 32-bit builds on x86_64-linux more memory.
2015-05-11 17:39:31 +02:00
Eelco Dolstra e0825bd36b Make ~DerivationGoal more reliable 2015-05-11 17:39:20 +02:00
Eelco Dolstra 86b9e6d457 nix-store --gc: Don't warn about missing manifests directory 2015-05-11 17:39:01 +02:00
Eelco Dolstra 1129a982c4 Improve error message if the daemon worker fails to start 2015-05-11 17:38:34 +02:00
Shea Levy bed17f40fc Fix build on gcc < 4.7 2015-05-11 17:37:20 +02:00
Eelco Dolstra ee8601cac4 Improved error message when encountering unsupported file types
Fixes #269.
2015-05-11 17:36:33 +02:00
Eelco Dolstra c2b65dd197 Remove some duplicate code 2015-05-11 17:36:05 +02:00
Eelco Dolstra c957422835 createDirs(): Handle ‘path’ being a symlink
In particular, this fixes "nix-build -o /tmp/result" on Mac OS X
(where /tmp is a symlink).
2015-05-11 17:35:25 +02:00
Eelco Dolstra 6092a48603 nix-daemon: Close unnecessary fd 2015-05-11 17:34:24 +02:00
Eelco Dolstra e74390a16f Remove bogus comment 2015-05-11 17:33:22 +02:00
Eelco Dolstra e63c8aaa05 On Linux, disable address space randomization 2015-05-11 17:33:04 +02:00
Eelco Dolstra 55939b1a4b Settings: Add bool get() 2015-05-11 17:32:30 +02:00
Ludovic Courtès 6621195e48 Add an 'optimiseStore' remote procedure call. 2015-05-11 17:31:02 +02:00
Eelco Dolstra 3bb89c3a31 Add disallowedReferences / disallowedRequisites
For the "stdenv accidentally referring to bootstrap-tools", it seems
easier to specify the path that we don't want to depend on, e.g.

  disallowedRequisites = [ bootstrapTools ];
2015-05-11 17:30:29 +02:00
Gergely Risko abd9d61e62 Introduce allowedRequisites feature 2015-05-11 17:29:11 +02:00
Joel Taylor 8c766e48d5 fix disappearing bash arguments 2015-05-11 17:26:37 +02:00
Eelco Dolstra d4e7c195fa Make hook shutdown more reliable 2015-05-11 17:25:20 +02:00
Eelco Dolstra ea837e470f Doh 2015-05-11 17:25:16 +02:00
Eelco Dolstra 790271559c Reduce verbosity 2015-05-11 17:25:13 +02:00
Eelco Dolstra 3f6d4f63ec Propagate remote timeouts properly 2015-05-11 17:25:05 +02:00
Eelco Dolstra aa98ba5067 Use regular file GC roots if possible
This makes hydra-eval-jobs create roots as regular files. See
1c208f2b7ef8ffb5e6d435d703dad83223a67bd6.
2015-05-11 17:23:33 +02:00
Eelco Dolstra 5fe5ff7780 Remove unnecessary call to addTempRoot() 2015-05-11 17:22:39 +02:00