-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Okay, here's a patch that does the following:

  Only chown if root
  Only mkdir if root or DESTDIR is set

I haven't committed it to the repository yet because I'm not sure if it
addresses the issues correctly.  If you're working on packaging vpopmail,
let me know if this does the trick, or what further changes are still
needed.

Thanks!
- --
/*
    Matt Brookings <m...@inter7.com>       GnuPG Key D9414F70
    Software developer                     Systems technician
    Inter7 Internet Technologies, Inc.     (815)776-9465
*/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAknU+CMACgkQ6QgvSNlBT3CU1ACfdX9NEDBFsL16TS6+WU7X90ii
o8EAoJYW3Kw8rBCTPRY65tsX/sGzIGeW
=FYc3
-----END PGP SIGNATURE-----
Index: Makefile.in
===================================================================
--- Makefile.in	(revision 878)
+++ Makefile.in	(working copy)
@@ -12,6 +12,7 @@
 LDFLAGS = @LDFLAGS@
 DEPS = Makefile
 INSTALL = @INSTALL@
+IDCOMMAND = @idcommand@
 CCC = $(CC) $(CFLAGS)
 PICC = $(CC) $(CFLAGS) -fPIC
 LINK = $(CC) $(LDFLAGS)
@@ -235,8 +236,35 @@
 
 install-strip: install
 
-install: $(BUILD_ALL)
+pre-install:
 	@echo
+	@echo "Checking installation pre-requisites..."
+	@echo
+	
+	@if test -z "$(IDCOMMAND)"; then \
+	   echo; \
+	   echo "Cannot determine your uid because IDCOMMAND is not set."; \
+	   echo; \
+	fi
+	
+	@if test "`$(IDCOMMAND)`" != "0"; then \
+	  if test -z "$${DESTDIR}"; then \
+		 echo; \
+		 echo "You can't install vpopmail because you aren't root"; \
+		 echo "and you don't have DESTDIR set."; \
+		 echo; \
+		 false; \
+	  fi; \
+	  if test "$${DESTDIR:0:1}" != "/"; then \
+		 echo; \
+		 echo "DESTDIR must be an absolute path starting with /"; \
+		 echo; \
+		 false; \
+	  fi ;\
+	fi
+
+install: pre-install $(BUILD_ALL)
+	@echo
 	@echo "Installing..."
 	@echo
 	
@@ -244,15 +272,40 @@
 	@# Create directories
 	@#
 	
-	for i in $(INSTALL_DIRS); do if test ! -d $${i}; then mkdir -p $${i}; chown @vpopuser@:@vpopgroup@ $${i}; fi; done
-	chmod 700 $(VPOPMAIL_DIR_DOMAINS)
+	for i in $(INSTALL_DIRS); do \
+	   if test ! -d $${i}; then \
+		 mkdir -p $${i}; \
+		 if test "`$(IDCOMMAND)`" = "0"; then \
+			chown @vpopuser@:@vpopgroup@ $${i}; \
+		 fi; \
+	   fi; \
+    done
 	
+	if test "`$(IDCOMMAND)`" = "0" || test ! -z "$${DESTDIR}"; then \
+	  chmod 700 $(DESTDIR)$(VPOPMAIL_DIR_DOMAINS); \
+    fi
+	
 	@#
 	@# Copy binaries, libraries and headers
 	@#
 	
-	for i in $(BUILD_BINS); do $(INSTALL) -s -o @vpopuser@ -g @vpopgroup@ $${i} $(DESTDIR)$(VPOPMAIL_DIR_BIN); chmod 711 $(DESTDIR)$(VPOPMAIL_DIR_BIN)/$${i}; done
-	for i in $(BUILD_LIBS); do $(INSTALL) $${i} $(DESTDIR)$(VPOPMAIL_DIR_LIB); chmod 644 $(DESTDIR)$(VPOPMAIL_DIR_LIB)/$${i}; done
+	for i in $(BUILD_BINS); do \
+	   $(INSTALL) -s $${i} $(DESTDIR)$(VPOPMAIL_DIR_BIN); \
+	   if test "`$(IDCOMMAND)`" = "0"; then \
+		 chown @vpopuser@:@vpopgroup@ $(DESTDIR)$(VPOPMAIL_DIR_BIN)/$${i}; \
+	   fi; \
+	   if test "`$(IDCOMMAND)`" = "0" || test ! -z "$${DESTDIR}"; then \
+		 chmod 711 $(DESTDIR)$(VPOPMAIL_DIR_BIN)/$${i}; \
+	   fi; \
+    done
+	
+	for i in $(BUILD_LIBS); do \
+	   $(INSTALL) $${i} $(DESTDIR)$(VPOPMAIL_DIR_LIB); \
+	   if test "`$(IDCOMMAND)`" = "0" || test ! -z "$${DESTDIR}"; then \
+		 chmod 644 $(DESTDIR)$(VPOPMAIL_DIR_LIB)/$${i}; \
+	   fi; \
+    done
+	
 	$(INSTALL) -m 444 config.h $(DESTDIR)$(VPOPMAIL_DIR_INCLUDE)/vpopmail_config.h
 	for i in $(INSTALL_HEADERS); do $(INSTALL) -m 444 $${i} $(DESTDIR)$(VPOPMAIL_DIR_INCLUDE); done
 	
@@ -272,7 +325,10 @@
 	@#
 	
 	if test ! -r $(DESTDIR)$(VPOPMAIL_DIR_ETC)/vusagec.conf; then \
-	   $(INSTALL) -o @vpopuser@ -g @vpopgroup@ -m 644 vusagec.conf $(DESTDIR)$(VPOPMAIL_DIR_ETC)/vusagec.conf; \
+	   $(INSTALL) -m 644 vusagec.conf $(DESTDIR)$(VPOPMAIL_DIR_ETC)/vusagec.conf; \
+	   if test "`$(IDCOMMAND)`" = "0"; then \
+		 chown @vpopuser@:@vpopgroup@ $(DESTDIR)$(VPOPMAIL_DIR_ETC)/vusagec.conf; \
+	   fi; \
     fi
 	
 	@#
Index: configure.ac
===================================================================
--- configure.ac	(revision 872)
+++ configure.ac	(working copy)
@@ -114,6 +114,7 @@
 esac
 
 AC_MSG_RESULT($idcommand)
+AC_SUBST(idcommand)
 
 #
 # ps command
@@ -252,13 +253,13 @@
 
 #----------------------------------------------------------------------
 
-if $idtest && test `$idcommand` != "0"
-then
-  AC_MSG_WARN(=== vpopmail must be configured as root. ===)
-  AC_MSG_WARN(=== please switch to the root user and   ===)
-  AC_MSG_WARN(=== run ./configure.                     ===)
-  AC_MSG_ERROR(aborted.)
-fi
+#if $idtest && test `$idcommand` != "0"
+#then
+#  AC_MSG_WARN(=== vpopmail must be configured as root. ===)
+#  AC_MSG_WARN(=== please switch to the root user and   ===)
+#  AC_MSG_WARN(=== run ./configure.                     ===)
+#  AC_MSG_ERROR(aborted.)
+#fi
 
 #
 # Locate the qmail directory
Index: configure
===================================================================
--- configure	(revision 872)
+++ configure	(working copy)
@@ -674,6 +674,7 @@
 GREP
 EGREP
 LIBOBJS
+idcommand
 vpopuser
 vpopgroup
 VPOPMAIL_DIR_BIN
@@ -6252,6 +6253,7 @@
 { echo "$as_me:$LINENO: result: $idcommand" >&5
 echo "${ECHO_T}$idcommand" >&6; }
 
+
 #
 # ps command
 #
@@ -6613,18 +6615,13 @@
 
 #----------------------------------------------------------------------
 
-if $idtest && test `$idcommand` != "0"
-then
-  { echo "$as_me:$LINENO: WARNING: === vpopmail must be configured as root. ===" >&5
-echo "$as_me: WARNING: === vpopmail must be configured as root. ===" >&2;}
-  { echo "$as_me:$LINENO: WARNING: === please switch to the root user and   ===" >&5
-echo "$as_me: WARNING: === please switch to the root user and   ===" >&2;}
-  { echo "$as_me:$LINENO: WARNING: === run ./configure.                     ===" >&5
-echo "$as_me: WARNING: === run ./configure.                     ===" >&2;}
-  { { echo "$as_me:$LINENO: error: aborted." >&5
-echo "$as_me: error: aborted." >&2;}
-   { (exit 1); exit 1; }; }
-fi
+#if $idtest && test `$idcommand` != "0"
+#then
+#  AC_MSG_WARN(=== vpopmail must be configured as root. ===)
+#  AC_MSG_WARN(=== please switch to the root user and   ===)
+#  AC_MSG_WARN(=== run ./configure.                     ===)
+#  AC_MSG_ERROR(aborted.)
+#fi
 
 #
 # Locate the qmail directory
@@ -10035,6 +10032,7 @@
 GREP!$GREP$ac_delim
 EGREP!$EGREP$ac_delim
 LIBOBJS!$LIBOBJS$ac_delim
+idcommand!$idcommand$ac_delim
 vpopuser!$vpopuser$ac_delim
 vpopgroup!$vpopgroup$ac_delim
 VPOPMAIL_DIR_BIN!$VPOPMAIL_DIR_BIN$ac_delim
@@ -10051,7 +10049,7 @@
 LTLIBOBJS!$LTLIBOBJS$ac_delim
 _ACEOF
 
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 75; then
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 76; then
     break
   elif $ac_last_try; then
     { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
Index: vusaged/Makefile.in
===================================================================
--- vusaged/Makefile.in	(revision 878)
+++ vusaged/Makefile.in	(working copy)
@@ -58,5 +58,5 @@
 	rm -rf config.log config.status Makefile autom4te.cache contrib/rc.vusaged
 
 install: $(BINS)
-	$(INSTALL) -s -m 0700 vusaged $(DESTDIR)$(VPOPMAIL_DIR_BIN)
+	$(INSTALL) -s -m 0700 vusaged $(DESTDIR)$(VPOPMAIL_DIR_BIN)/vusaged
 	if test ! -r $(DESTDIR)$(VPOPMAIL_DIR_ETC)/vusaged.conf; then $(INSTALL) -m 0600 etc/vusaged.conf $(DESTDIR)$(VPOPMAIL_DIR_ETC)/vusaged.conf; fi

Reply via email to