summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-12-07 18:51:11 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-12-07 18:51:11 +0000
commitd03f0d411740aebd5b27e5a1ac57d8533843ff6b (patch)
tree37df43478b7e5470ffb2dccce30346f21c9f93a6
parentc3286ec020dfa20edcad6ad3cea519546e5207f1 (diff)
downloadguix-d03f0d411740aebd5b27e5a1ac57d8533843ff6b.tar.gz
* Check for lchown.
-rw-r--r--configure.ac10
-rw-r--r--src/nix-setuid-helper/main.cc7
2 files changed, 8 insertions, 9 deletions
diff --git a/configure.ac b/configure.ac
index fb2228a6f1..7a83d8f355 100644
--- a/configure.ac
+++ b/configure.ac
@@ -237,15 +237,7 @@ AM_CONDITIONAL(INIT_STATE, test "$init_state" = "yes")
 
 
 # Setuid installations.
-AC_CHECK_FUNC(setresuid, [HAVE_SETRESUID=1], [HAVE_SETRESUID=])
-if test "$HAVE_SETRESUID" = "1"; then
-    AC_DEFINE(HAVE_SETRESUID, 1, [whether we have setresuid()])
-fi
-
-AC_CHECK_FUNC(setreuid, [HAVE_SETREUID=1], [HAVE_SETREUID=])
-if test "$HAVE_SETREUID" = "1"; then
-    AC_DEFINE(HAVE_SETREUID, 1, [whether we have setreuid()])
-fi
+AC_CHECK_FUNCS([setresuid setreuid lchown])
 
 
 # This is needed if ATerm, Berkeley DB or bzip2 are static libraries,
diff --git a/src/nix-setuid-helper/main.cc b/src/nix-setuid-helper/main.cc
index 26cdc73b79..168cff40a3 100644
--- a/src/nix-setuid-helper/main.cc
+++ b/src/nix-setuid-helper/main.cc
@@ -10,6 +10,7 @@
 #include <iostream>
 #include <vector>
 
+#include "config.h"
 #include "util.hh"
 
 using namespace nix;
@@ -46,8 +47,14 @@ static void secureChown(uid_t uidFrom, gid_t gidFrom,
 
     assert(uidTo != 0 && gidTo != 0);
 
+#if HAVE_LCHOWN
     if (lchown(path.c_str(), uidTo, gidTo) == -1)
         throw Error(error);
+#else
+    if (!S_ISLNK(st.st_mode) &&
+        chown(path.c_str(), uidTo, gidTo) == -1)
+        throw Error(error);
+#endif
 
     if (S_ISDIR(st.st_mode)) {
         Strings names = readDirectory(path);