aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/util.cc
AgeCommit message (Collapse)Author
2013-08-26Fix typos, especially those that end up in the Nix manualIvan Kozik
2013-08-19Store Nix integers as longsEelco Dolstra
So on 64-bit systems, integers are now 64-bit. Fixes #158.
2013-07-30killUser: Don't let the child kill itself on AppleShea Levy
The kill(2) in Apple's libc follows POSIX semantics, which means that kill(-1, SIGKILL) will kill the calling process too. Since nix has no way to distinguish between the process successfully killing everything and the process being killed by a rogue builder in that case, it can't safely conclude that killUser was successful. Luckily, the actual kill syscall takes a parameter that determines whether POSIX semantics are followed, so we can call that syscall directly and avoid the issue on Apple. Signed-off-by: Shea Levy <shea@shealevy.com>
2013-07-12Garbage collector: Don't follow symlinks arbitrarilyEelco Dolstra
Only indirect roots (symlinks to symlinks to the Nix store) are now supported.
2013-06-20Don't keep "disabled" substituters runningEelco Dolstra
For instance, it's pointless to keep copy-from-other-stores running if there are no other stores, or download-using-manifests if there are no manifests. This also speeds things up because we don't send queries to those substituters.
2013-01-03Remove tabsEelco Dolstra
2013-01-03Clear any immutable bits in the Nix storeEelco Dolstra
Doing this once makes subsequent operations like garbage collecting more efficient since we don't have to call makeMutable() first.
2012-11-26Make "nix-build -A <derivation>.<output>" do the right thingEelco Dolstra
For example, given a derivation with outputs "out", "man" and "bin": $ nix-build -A pkg produces ./result pointing to the "out" output; $ nix-build -A pkg.man produces ./result-man pointing to the "man" output; $ nix-build -A pkg.all produces ./result, ./result-man and ./result-bin; $ nix-build -A pkg.all -A pkg2 produces ./result, ./result-man, ./result-bin and ./result-2.
2012-11-15Don't use std::cerr in a few placesEelco Dolstra
Slightly scared of using std::cerr in a vforked process...
2012-11-15Add some debug codeEelco Dolstra
2012-11-09Use vfork() instead of fork() if availableEelco Dolstra
Hopefully this reduces the chance of hitting ‘unable to fork: Cannot allocate memory’ errors. vfork() is used for everything except starting builders.
2012-11-09Remove some redundant close() callsEelco Dolstra
They are unnecessary because we set the close-on-exec flag.
2012-11-09Remove the quickExit functionEelco Dolstra
2012-09-28Handle octal escapes in /proc/self/mountinfoEelco Dolstra
2012-09-19Templatise tokenizeString()Eelco Dolstra
2012-08-27Merge branch 'master' into no-manifestsEelco Dolstra
2012-08-20In the chroot, make all mounted filesystems privateEelco Dolstra
This is required on systemd, which mounts filesystems as "shared" subtrees. Changes to shared trees in a private mount namespace are propagated to the outside world, which is bad.
2012-08-01Drop the block count in the garbage collectorEelco Dolstra
2012-08-01DohEelco Dolstra
2012-08-01Report substituter errors to clients of the Nix daemonEelco Dolstra
2012-07-26Set permissions on temporary build directories to 0700Eelco Dolstra
Fixes #39.
2012-06-25When using chroots, use a private PID namespaceEelco Dolstra
In a private PID namespace, processes have PIDs that are separate from the rest of the system. The initial child gets PID 1. Processes in the chroot cannot see processes outside of the chroot. This improves isolation between builds. However, processes on the outside can see processes in the chroot and send signals to them (if they have appropriate rights). Since the builder gets PID 1, it serves as the reaper for zombies in the chroot. This might turn out to be a problem. In that case we'll need to have a small PID 1 process that sits in a loop calling wait().
2012-03-05Set the close-on-exec flag on file descriptorsEelco Dolstra
2012-02-15On Linux, make the Nix store really read-only by using the immutable bitEelco Dolstra
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.
2012-02-09Use data() instead of c_str() where appropriateEelco Dolstra
2011-12-22* In the garbage collector, delete invalid paths before deletingEelco Dolstra
unreachable paths. This matters when using --max-freed etc.: unreachable paths could become reachable again, so it's nicer to keep them if there is "real" garbage to be deleted. Also, don't use readDirectory() but read the Nix store and delete invalid paths in parallel. This reduces GC latency on very large Nix stores.
2010-12-13* nix-instantiate: return exit status 100 to denote a permanent buildEelco Dolstra
failure. The build hook can use this to distinguish between transient and permanent failures on the remote side.
2010-12-13* createDirs(path): if path already exists, make sure it's aEelco Dolstra
directory. * Provide a C++ wrapper around lstat().
2010-10-04* Sync with the trunk.Eelco Dolstra
2010-10-04* In printMsg(), ignore failing writes to stderr if we're in anEelco Dolstra
exception handler, otherwise throw an exception. We need to ignore write errors in exception handlers to ensure that cleanup code runs to completion if the other side of stderr has been closed unexpectedly.
2010-08-27* Experimental feature: allow a derivation to tell the build hook thatEelco Dolstra
it requires a certain feature on the build machine, e.g. requiredSystemFeatures = [ "kvm" ]; We need this in Hydra to make sure that builds that require KVM support are forwarded to machines that have KVM support. Probably this should also be enforced for local builds.
2010-08-04* Sync with the trunk.Eelco Dolstra
2010-06-24src/libutil/util.cc: include <limit.h> to ensure that PATH_MAX is definedPeter Simons
2010-05-12* Sync with the trunk.Eelco Dolstra
2010-04-20* Sync with the trunk.Eelco Dolstra
2010-04-19* Don't use the ATerm library for parsing/printing .drv files.Eelco Dolstra
2010-04-12* Remove some obsolete functions.Eelco Dolstra
2010-03-19* Clean up error messages in killUser().Eelco Dolstra
2010-02-24* Don't use fdatasync since it doesn't work on Snow Leopard.Eelco Dolstra
* Don't refer to config.h in util.hh, because config.h is not installed (http://hydra.nixos.org/build/303053).
2010-02-24* Remove the fdatasync check since it's no longer needed.Eelco Dolstra
2010-02-10Don't rely on `PATH_MAX' on GNU.Ludovic Courtès
2010-02-02* Remove most Cygwin-specific code. Cygwin 1.7 implements advisoryEelco Dolstra
POSIX locks, and simulates Unix-style file deletion semantics sufficiently. Note that this means that Nix won't work on Cygwin 1.5 anymore.
2010-01-29* Added an option "fsync-metadata" to fsync() changes toEelco Dolstra
/nix/var/nix/db. * Removed the function writeStringToFile since it does (almost) the same thing as writeFile.
2009-11-24* Templatise getIntArg / string2Int.Eelco Dolstra
2009-11-24* In the garbage collector, don't count files with a link count > 1 inEelco Dolstra
the "bytes/blocks freed" statistics.
2009-06-30* Don't show trace information by default (`--show-trace' to enable).Eelco Dolstra
NixOS evaluation errors in particular look intimidating and generally aren't very useful. Ideally the builtins.throw messages should be self-contained.
2009-03-28* Simplify communication with the hook a bit (don't use fileEelco Dolstra
descriptors 3/4, just use stdin/stderr).
2008-12-04* Don't ignore errors from writing to stderr. That way, whenEelco Dolstra
nix-store -r (or some other operation) is started via ssh, it will at least have a chance of terminating quickly when the connection is killed. Right now it just runs to completion, because it never notices that stderr is no longer connected to anything. Of course it would be better if sshd would just send a SIGHUP, but it doesn't (https://bugzilla.mindrot.org/show_bug.cgi?id=396).
2008-08-25* Strip off the `.nix' suffix from the attribute name for files inEelco Dolstra
~/.nix-defexpr, otherwise the attribute cannot be selected with the `-A' option. Useful if you want to stick a Nix expression directly in ~/.nix-defexpr.
2008-08-02* Make nix-env --dry-run print the paths to be substituted correctlyEelco Dolstra
again. (After the previous substituter mechanism refactoring I didn't update the code that obtains the references of substitutable paths.) This required some refactoring: the substituter programs are now kept running and receive/respond to info requests via stdin/stdout.