about summary refs log tree commit diff
path: root/src/libstore/local-store.cc (follow)
AgeCommit message (Collapse)AuthorFilesLines
2013-02-28 Handle symlinks properlyEelco Dolstra1-1/+1
Now it's really brown paper bag time...
2013-02-27 Handle hard links to other files in the outputEelco Dolstra1-6/+26
2013-02-27 Refactoring: Split off the non-recursive canonicalisePathMetaData()Eelco Dolstra1-35/+50
Also, change the file mode before changing the owner. This prevents a slight time window in which a setuid binary would be setuid root.
2013-02-26 Security: Don't allow builders to change permissions on files they don't ownEelco Dolstra1-7/+10
It turns out that in multi-user Nix, a builder may be able to do ln /etc/shadow $out/foo Afterwards, canonicalisePathMetaData() will be applied to $out/foo, causing /etc/shadow's mode to be set to 444 (readable by everybody but writable by nobody). That's obviously Very Bad. Fortunately, this fails in NixOS's default configuration because /nix/store is a bind mount, so "ln" will fail with "Invalid cross-device link". It also fails if hard-link restrictions are enabled, so a workaround is: echo 1 > /proc/sys/fs/protected_hardlinks The solution is to check that all files in $out are owned by the build user. This means that innocuous operations like "ln ${pkgs.foo}/some-file $out/" are now rejected, but that already failed in chroot builds anyway.
2013-01-23 Only warn about SQLite being busy onceEelco Dolstra1-1/+5
No need to get annoying.
2013-01-03 Open the database after removing immutable bitsEelco Dolstra1-1/+1
2013-01-03 Clear any immutable bits in the Nix storeEelco Dolstra1-1/+60
Doing this once makes subsequent operations like garbage collecting more efficient since we don't have to call makeMutable() first.
2012-12-11 On SQLITE_BUSY, wait a random amount of timeEelco Dolstra1-1/+1
If all contending processes wait a fixed amount of time (100 ms), there is a good probability that they'll just collide again.
2012-11-09 Use vfork() instead of fork() if availableEelco Dolstra1-5/+16
Hopefully this reduces the chance of hitting ‘unable to fork: Cannot allocate memory’ errors. vfork() is used for everything except starting builders.
2012-11-09 Remove some redundant close() callsEelco Dolstra1-2/+0
They are unnecessary because we set the close-on-exec flag.
2012-11-09 Remove the quickExit functionEelco Dolstra1-1/+1
2012-11-09 Remove a Darwin hack that should no longer be neededEelco Dolstra1-7/+0
2012-11-09 Remove unnecessary call to closeMostFDs()Eelco Dolstra1-1/+0
We have close-on-exec on all FDs now, and there is no security risk in passing open FDs to substituters anyway.
2012-11-06 canonicalizePathMetaData: Fall-back to utimes if lutimes fails due to ENOSYSShea Levy1-0/+2
2012-10-04 nix-store --verify: Continue on errorsEelco Dolstra1-2/+4
2012-10-03 Remove bin2cEelco Dolstra1-0/+2
2012-10-03 Add a ‘--repair’ flag to nix-instantiateEelco Dolstra1-8/+8
This allows repairing corrupted derivations and other source files.
2012-10-03 When repairing a derivation, check and repair the entire output closureEelco Dolstra1-4/+20
If we find a corrupted path in the output closure, we rebuild the derivation that produced that particular path.
2012-10-02 Add a --repair flag to ‘nix-store -r’ to repair derivation outputsEelco Dolstra1-0/+10
With this flag, if any valid derivation output is missing or corrupt, it will be recreated by using a substitute if available, or by rebuilding the derivation. The latter may use hash rewriting if chroots are not available.
2012-10-02 nix-store --verify: Add an option ‘--repair’ to repair all ↵Eelco Dolstra1-5/+20
missing/corrupt paths Also, return a non-zero exit code if errors remain after verifying/repairing.
2012-09-25 Make the store writable before creating /nix/store/.linksEelco Dolstra1-2/+1
2012-09-19 Remove setting of the immutable bitEelco Dolstra1-2/+0
Using the immutable bit is problematic, especially in conjunction with store optimisation. For instance, if the garbage collector deletes a file, it has to clear its immutable bit, but if the file has additional hard links, we can't set the bit afterwards because we don't know the remaining paths. So now that we support having the entire Nix store as a read-only mount, we may as well drop the immutable bit. Unfortunately, we have to keep the code to clear the immutable bit for backwards compatibility.
2012-09-19 Support having /nix/store as a read-only bind mountEelco Dolstra1-0/+39
It turns out that the immutable bit doesn't work all that well. A better way is to make the entire Nix store a read-only bind mount, i.e. by doing $ mount --bind /nix/store /nix/store $ mount -o remount,ro,bind /nix/store (This would typically done in an early boot script, before anything from /nix/store is used.) Since Nix needs to be able to write to the Nix store, it now detects if /nix/store is a read-only bind mount and then makes it writable in a private mount namespace.
2012-09-19 Templatise tokenizeString()Eelco Dolstra1-3/+3
2012-09-13 Vacuum the SQLite DB after running the garbage collectorEelco Dolstra1-0/+7
2012-08-01 Report substituter errors to clients of the Nix daemonEelco Dolstra1-21/+37
2012-07-30 Refactor settings processingEelco Dolstra1-33/+31
Put all Nix configuration flags in a Settings object.
2012-07-30 Pass configuration settings to the substitutersEelco Dolstra1-0/+4
Previously substituters could read nix.conf themselves, but this didn't take --option flags into account.
2012-07-30 Remove unused variablesEelco Dolstra1-2/+0
2012-07-30 Fix whitespaceEelco Dolstra1-71/+71
2012-07-26 Fix the substituter testsEelco Dolstra1-1/+2
2012-07-26 Merge branch 'master' into no-manifestsEelco Dolstra1-9/+23
2012-07-23 Automatically optimise the Nix store when a new path is addedEelco Dolstra1-0/+7
Auto-optimisation is enabled by default. It can be turned off by setting auto-optimise-store to false in nix.conf.
2012-07-23 Use lutimes() if available to canonicalise the timestamp of symlinksEelco Dolstra1-9/+16
Also use utimes() instead of utime() if lutimes() is not available.
2012-07-18 Merge branch 'master' into no-manifestsEelco Dolstra1-0/+24
2012-07-17 Add function queryPathFromHashPart()Eelco Dolstra1-0/+24
To implement binary caches efficiently, Hydra needs to be able to map the hash part of a store path (e.g. "gbg...zr7") to the full store path (e.g. "/nix/store/gbg...kzr7-subversion-1.7.5"). (The binary cache mechanism uses hash parts as a key for looking up store paths to ensure privacy.) However, doing a search in the Nix store for /nix/store/<hash>* is expensive since it requires reading the entire directory. queryPathFromHashPart() prevents this by doing a cheap database lookup.
2012-07-11 Replace hasSubstitutes() with querySubstitutablePaths()Eelco Dolstra1-5/+13
querySubstitutablePaths() takes a set of paths, so this greatly reduces daemon <-> client latency.
2012-07-11 Add a function queryValidPaths()Eelco Dolstra1-0/+9
queryValidPaths() combines multiple calls to isValidPath() in one. This matters when using the Nix daemon because it reduces latency. For instance, on "nix-env -qas \*" it reduces execution time from 5.7s to 4.7s (which is indistinguishable from the non-daemon case).
2012-07-11 Rename queryValidPaths() to queryAllValidPaths()Eelco Dolstra1-2/+2
2012-07-11 Implement querySubstitutablePathInfos() in the daemonEelco Dolstra1-12/+0
Also removed querySubstitutablePathInfo().
2012-07-06 download-from-binary-cache: parallelise fetching of NAR info filesEelco Dolstra1-20/+40
Getting substitute information using the binary cache substituter has non-trivial latency overhead. A package or NixOS system configuration can have hundreds of dependencies, and in the worst case (when the local info cache is empty) we have to do a separate HTTP request for each of these. If the ping time to the server is t, getting N info files will take tN seconds; e.g., with a ping time of 0.1s to nixos.org, sequentially downloading 1000 info files (a typical NixOS config) will take at least 100 seconds. To fix this problem, the binary cache substituter can now perform requests in parallel. This required changing the substituter interface to support a function querySubstitutablePathInfos() that queries multiple paths at the same time, and rewriting queryMissing() to take advantage of parallelism. (Due to local caching, parallelising queryMissing() is sufficient for most use cases, since it's almost always called before building a derivation and thus fills the local info cache.) For example, parallelism speeds up querying all 1056 paths in a particular NixOS system configuration from 116s to 2.6s. It works so well because the eccentricity of the top-level derivation in the dependency graph is only 9. So we only need 10 round-trips (when using an unlimited number of parallel connections) to get everything. Currently we do a maximum of 150 parallel connections to the server. Thus it's important that the binary cache server (e.g. nixos.org) has a high connection limit. Alternatively we could use HTTP pipelining, but WWW::Curl doesn't support it and libcurl has a hard-coded limit of 5 requests per pipeline.
2012-05-29 Reserve some disk space for the garbage collectorEelco Dolstra1-1/+19
We can't open a SQLite database if the disk is full. Since this prevents the garbage collector from running when it's most needed, we reserve some dummy space that we can free just before doing a garbage collection. This actually revives some old code from the Berkeley DB days. Fixes #27.
2012-04-23 Merge pull request #2 from viric/masterEelco Dolstra1-0/+6
Again, adding the sync option
2012-03-26 Make the garbage collector more concurrentEelco Dolstra1-6/+1
Make the garbage collector more concurrent by deleting valid paths outside the region where we're holding the global GC lock. This should greatly reduce the time during which new builds are blocked, since the deletion accounts for the vast majority of the time spent in the GC. To ensure that this is safe, the valid paths are invalidated and renamed to some arbitrary path while we're holding the lock. This ensures that we when we finally delete the path, it's not a (newly) valid or locked path.
2012-03-22 Fixing the default of sync-before-registeringLluís Batlle i Rossell1-1/+5
Setting 'false' as default, as suggested by Eelco. I also added a comment about the setting in the code.
2012-03-22 Adding a nix option to sync before registering a path, for non-ext*Lluís Batlle i Rossell1-0/+2
filesystems.
2012-03-20 nix-store --clear-failed-paths: Clear derivation outputsEelco Dolstra1-1/+3
If the argument to ‘nix-store --clear-failed-paths’ is a derivation, then clear the failed state of its outputs.
2012-03-05 Restore progress indication during nix-copy-closureEelco Dolstra1-0/+2
2012-03-01 Remove dependency on sqlite3_table_column_metadataEelco Dolstra1-7/+0
Not all SQLite builds have the function sqlite3_table_column_metadata. We were only using it in a schema upgrade check for compatibility with databases that were probably never seen in the wild. So remove it.
2012-02-15 On Linux, make the Nix store really read-only by using the immutable bitEelco Dolstra1-0/+7
I was bitten one time too many by Python modifying the Nix store by creating *.pyc files when run as root. On Linux, we can prevent this by setting the immutable bit on files and directories (as in ‘chattr +i’). This isn't supported by all filesystems, so it's not an error if setting the bit fails. The immutable bit is cleared by the garbage collector before deleting a path. The only tricky aspect is in optimiseStore(), since it's forbidden to create hard links to an immutable file. Thus optimiseStore() temporarily clears the immutable bit before creating the link.