forked from lix-project/lix
* Check for lchown.
This commit is contained in:
parent
c3286ec020
commit
d03f0d4117
10
configure.ac
10
configure.ac
|
@ -237,15 +237,7 @@ AM_CONDITIONAL(INIT_STATE, test "$init_state" = "yes")
|
||||||
|
|
||||||
|
|
||||||
# Setuid installations.
|
# Setuid installations.
|
||||||
AC_CHECK_FUNC(setresuid, [HAVE_SETRESUID=1], [HAVE_SETRESUID=])
|
AC_CHECK_FUNCS([setresuid setreuid lchown])
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
# This is needed if ATerm, Berkeley DB or bzip2 are static libraries,
|
# This is needed if ATerm, Berkeley DB or bzip2 are static libraries,
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
#include "util.hh"
|
#include "util.hh"
|
||||||
|
|
||||||
using namespace nix;
|
using namespace nix;
|
||||||
|
@ -46,8 +47,14 @@ static void secureChown(uid_t uidFrom, gid_t gidFrom,
|
||||||
|
|
||||||
assert(uidTo != 0 && gidTo != 0);
|
assert(uidTo != 0 && gidTo != 0);
|
||||||
|
|
||||||
|
#if HAVE_LCHOWN
|
||||||
if (lchown(path.c_str(), uidTo, gidTo) == -1)
|
if (lchown(path.c_str(), uidTo, gidTo) == -1)
|
||||||
throw Error(error);
|
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)) {
|
if (S_ISDIR(st.st_mode)) {
|
||||||
Strings names = readDirectory(path);
|
Strings names = readDirectory(path);
|
||||||
|
|
Loading…
Reference in a new issue