about summary refs log tree commit diff
path: root/src/libmain/shared.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2004-09-09T14·16+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2004-09-09T14·16+0000
commite043fc7d0b68bedaabe236c2f2080a33bb967ee5 (patch)
tree1151f6df4c82e8ee17ac95097d0d68e63d994fcc /src/libmain/shared.cc
parent550d960586c1532ea1066b8df418c6629f0e7288 (diff)
* Set the umask to known value (0022). This is important in a
  setuid installation, since the calling user may have a more fascist
  umask (say, 0077), which would cause the store objects built by Nix
  to be unreadable to anyone other than the Nix user.

Diffstat (limited to 'src/libmain/shared.cc')
-rw-r--r--src/libmain/shared.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
index 7917407bb2..a5c45d853b 100644
--- a/src/libmain/shared.cc
+++ b/src/libmain/shared.cc
@@ -91,6 +91,12 @@ static void initAndRun(int argc, char * * argv)
     if (sigaction(SIGPIPE, &act, &oact))
         throw SysError("ignoring SIGPIPE");
 
+    /* There is no privacy in the Nix system ;-)  At least not for
+       now.  In particular, store objects should be readable by
+       everybody.  This prevents nasty surprises when using a shared
+       store (with the setuid() hack). */
+    umask(0022);
+
     /* Process the NIX_LOG_TYPE environment variable. */
     string lt = getEnv("NIX_LOG_TYPE");
     if (lt != "") setLogType(lt);