about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-09-27T21·04+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-09-27T21·04+0000
commit4ad6fb7ea3e18361b6021a23a7401af4085d3602 (patch)
tree0b1ef80e76bd342e334660593c19487fe103de63 /src
parent015ac7c7da6dfc93d287b89e443648656a88665d (diff)
* Fix setuid builds.
Diffstat (limited to 'src')
-rw-r--r--src/libmain/shared.cc4
-rw-r--r--src/libutil/util.cc14
2 files changed, 9 insertions, 9 deletions
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
index 3064299c8518..00e197499e36 100644
--- a/src/libmain/shared.cc
+++ b/src/libmain/shared.cc
@@ -9,13 +9,9 @@
 #include <iostream>
 #include <cctype>
 
-#include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
 
-#include <pwd.h>
-#include <grp.h>
-
 #include <aterm2.h>
 
 
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index eac124edbd89..de2dd12ad42e 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -13,6 +13,10 @@
 #include <sys/wait.h>
 #include <fcntl.h>
 
+#include <sys/types.h>
+#include <pwd.h>
+#include <grp.h>
+
 #include "util.hh"
 
 
@@ -913,7 +917,7 @@ void switchToNixUser()
     /* Lookup the Nix gid. */
     struct group * gr = getgrnam(NIX_GROUP);
     if (!gr) {
-        cerr << format("missing group `%1%'\n") % NIX_GROUP;
+        std::cerr << format("missing group `%1%'\n") % NIX_GROUP;
         exit(1);
     }
 
@@ -921,7 +925,7 @@ void switchToNixUser()
     int maxGids = 512, nrGids;
     gid_t gids[maxGids];
     if ((nrGids = getgroups(maxGids, gids)) == -1) {
-        cerr << format("unable to query gids\n");
+        std::cerr << format("unable to query gids\n");
         exit(1);
     }
 
@@ -955,14 +959,14 @@ void switchToNixUser()
        because we cannot do it after we have dropped root uid. */
     nixGid = gr->gr_gid;
     if (_setgid(nixGid) != 0 || getgid() != nixGid || getegid() != nixGid) {
-        cerr << format("unable to set gid to `%1%'\n") % NIX_GROUP;
+        std::cerr << format("unable to set gid to `%1%'\n") % NIX_GROUP;
         exit(1);
     }
 
     /* Lookup the Nix uid. */
     struct passwd * pw = getpwnam(NIX_USER);
     if (!pw) {
-        cerr << format("missing user `%1%'\n") % NIX_USER;
+        std::cerr << format("missing user `%1%'\n") % NIX_USER;
         exit(1);
     }
 
@@ -971,7 +975,7 @@ void switchToNixUser()
        succeeded.*/
     nixUid = pw->pw_uid;
     if (_setuid(nixUid) != 0 || getuid() != nixUid || geteuid() != nixUid) {
-        cerr << format("unable to set uid to `%1%'\n") % NIX_USER;
+        std::cerr << format("unable to set uid to `%1%'\n") % NIX_USER;
         exit(1);
     }