Description: fix install permissions
 Without this patch, the makefile will try to install directories and
 files with incompatible permissions for ejabberd, which run as an
 ejabberd user.
Author: Johan Oudinet <johan.oudinet@gmail.com>

Index: ejabberd/Makefile.in
===================================================================
--- ejabberd.orig/Makefile.in	2014-10-28 12:36:49.228713322 +0100
+++ ejabberd/Makefile.in	2014-10-28 13:53:13.538888807 +0100
@@ -91,10 +91,10 @@ spec:
 install: all
 	#
 	# Configuration files
-	$(INSTALL) -d -m 750 $(G_USER) $(ETCDIR)
+	$(INSTALL) -d $(ETCDIR)
 	[ -f $(ETCDIR)/ejabberd.yml ] \
-		&& $(INSTALL) -b -m 640 $(G_USER) ejabberd.yml.example $(ETCDIR)/ejabberd.yml-new \
-		|| $(INSTALL) -b -m 640 $(G_USER) ejabberd.yml.example $(ETCDIR)/ejabberd.yml
+		&& $(INSTALL) -b -m 644 $(G_USER) ejabberd.yml.example $(ETCDIR)/ejabberd.yml-new \
+		|| $(INSTALL) -b -m 644 $(G_USER) ejabberd.yml.example $(ETCDIR)/ejabberd.yml
 	$(SED) -e "s*{{rootdir}}*@prefix@*" \
 		-e "s*{{installuser}}*@INSTALLUSER@*" \
 		-e "s*{{libdir}}*@libdir@*" \
@@ -104,13 +104,12 @@ install: all
 		-e "s*{{erl}}*@ERL@*" ejabberdctl.template \
 		> ejabberdctl.example
 	[ -f $(ETCDIR)/ejabberdctl.cfg ] \
-		&& $(INSTALL) -b -m 640 $(G_USER) ejabberdctl.cfg.example $(ETCDIR)/ejabberdctl.cfg-new \
-		|| $(INSTALL) -b -m 640 $(G_USER) ejabberdctl.cfg.example $(ETCDIR)/ejabberdctl.cfg
+		&& $(INSTALL) -b -m 644 $(G_USER) ejabberdctl.cfg.example $(ETCDIR)/ejabberdctl.cfg-new \
+		|| $(INSTALL) -b -m 644 $(G_USER) ejabberdctl.cfg.example $(ETCDIR)/ejabberdctl.cfg
 	$(INSTALL) -b -m 644 $(G_USER) inetrc $(ETCDIR)/inetrc
 	#
 	# Administration script
-	[ -d $(SBINDIR) ] || $(INSTALL) -d -m 755 $(SBINDIR)
-	$(INSTALL) -m 550 $(G_USER) ejabberdctl.example $(SBINDIR)/ejabberdctl
+	$(INSTALL) -D ejabberdctl.example $(SBINDIR)/ejabberdctl
 	#
 	# Init script
 	$(SED) -e "s*@ctlscriptpath@*$(SBINDIR)*" \
@@ -129,10 +128,7 @@ install: all
 	$(INSTALL) -m 644 include/*.hrl $(INCLUDEDIR)
 	#
 	# Binary C programs
-	$(INSTALL) -d $(PBINDIR)
-	$(INSTALL) -m 750 $(O_USER) tools/captcha.sh $(PBINDIR)
-	-[ -f deps/p1_pam/priv/bin/epam ] \
-		&& $(INSTALL) -m 750 $(O_USER) deps/p1_pam/priv/bin/epam $(PBINDIR)
+	$(INSTALL) -D tools/captcha.sh $(PBINDIR)/captcha.sh
 	#
 	# Binary system libraries
 	$(INSTALL) -d $(SODIR)
@@ -140,22 +136,6 @@ install: all
 	# Translated strings
 	$(INSTALL) -d $(MSGSDIR)
 	$(INSTALL) -m 644 priv/msgs/*.msg $(MSGSDIR)
-	#
-	# Spool directory
-	$(INSTALL) -d -m 750 $(O_USER) $(SPOOLDIR)
-	$(CHOWN_COMMAND) -R @INSTALLUSER@ $(SPOOLDIR) >$(CHOWN_OUTPUT)
-	chmod -R 750 $(SPOOLDIR)
-	[ ! -f $(COOKIEFILE) ] || { $(CHOWN_COMMAND) @INSTALLUSER@ $(COOKIEFILE) >$(CHOWN_OUTPUT) ; chmod 400 $(COOKIEFILE) ; }
-	#
-	# ejabberdctl lock directory
-	$(INSTALL) -d -m 750 $(O_USER) $(CTLLOCKDIR)
-	$(CHOWN_COMMAND) -R @INSTALLUSER@ $(CTLLOCKDIR) >$(CHOWN_OUTPUT)
-	chmod -R 750 $(CTLLOCKDIR)
-	#
-	# Log directory
-	$(INSTALL) -d -m 750 $(O_USER) $(LOGDIR)
-	$(CHOWN_COMMAND) -R @INSTALLUSER@ $(LOGDIR) >$(CHOWN_OUTPUT)
-	chmod -R 750 $(LOGDIR)
 
 uninstall: uninstall-binary

