Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurelien Foret <aurelien@archlinux.org>2006-01-21 16:50:01 +0000
committerAurelien Foret <aurelien@archlinux.org>2006-01-21 16:50:01 +0000
commit2d08e902ef07b4a888fa3daf2d5a658dd04dac4e (patch)
tree13c3fbaaf925e735aa10ab945e29e82d23df685f
parentcf94007aed7eb87a38090a62b9ddf606ea1343c9 (diff)
added a FAKEROOT define allowing to use pacman in a fakeroot enivronment (for tests purpose)
-rw-r--r--configure.ac14
-rw-r--r--lib/libalpm/handle.c6
-rw-r--r--src/pacman/pacman.c2
3 files changed, 22 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 5d33fa33..51450c63 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,6 +52,11 @@ AC_ARG_ENABLE(debug,
AC_HELP_STRING([--disable-debug], [Disable debugging support]),
[debug=$enableval], [debug=yes])
+dnl Help line for fakeroot
+AC_ARG_ENABLE(fakeroot,
+ AC_HELP_STRING([--disable-fakeoot], [Disable fakeroot proof support]),
+ [fakeroot=$enableval], [fakeroot=yes])
+
dnl Check for man2html binary
AC_MSG_CHECKING(for support man2html)
if test x$wantman2html = xyes ; then
@@ -111,6 +116,15 @@ else
AC_MSG_RESULT(no)
fi
+dnl Enable or disable fakeroot code
+AC_MSG_CHECKING(for fakeroot proof support)
+if test x$fakeroot = xyes ; then
+ AC_MSG_RESULT(yes)
+else
+ CFLAGS="$CFLAGS -DFAKEROOT"
+ AC_MSG_RESULT(no)
+fi
+
dnl Check for zlib
AC_CHECK_LIB([z], [gzsetparams], [AC_CHECK_HEADER([zlib.h], [LIBZ='-lz'])])
if test -n "$LIBZ"; then
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 59ba46ed..b8a6713b 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -55,13 +55,19 @@ pmhandle_t *handle_new()
#ifndef CYGWIN
/* see if we're root or not */
handle->uid = geteuid();
+#ifndef FAKEROOT
if(!handle->uid && getenv("FAKEROOTKEY")) {
/* fakeroot doesn't count, we're non-root */
handle->uid = 99;
}
+#endif
/* see if we're root or not (fakeroot does not count) */
+#ifndef FAKEROOT
if(handle->uid == 0 && !getenv("FAKEROOTKEY")) {
+#else
+ if(handle->uid == 0) {
+#endif
handle->access = PM_ACCESS_RW;
} else {
handle->access = PM_ACCESS_RO;
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 8511621a..ea3babe3 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -101,10 +101,12 @@ int main(int argc, char *argv[])
#ifndef CYGWIN
/* see if we're root or not */
myuid = geteuid();
+#ifndef FAKEROOT
if(!myuid && getenv("FAKEROOTKEY")) {
/* fakeroot doesn't count, we're non-root */
myuid = 99;
}
+#endif
/* check if we have sufficient permission for the requested operation */
if(myuid > 0) {