diff options
Diffstat (limited to 'src/nix-setuid-helper')
-rw-r--r-- | src/nix-setuid-helper/main.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/nix-setuid-helper/main.cc b/src/nix-setuid-helper/main.cc index 26cdc73b7911..168cff40a3f6 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); |