25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

Don't leak DESTDIR in files copied by 'make install'

This fixes issue #3819
This commit is contained in:
Paweł Chmielowski 2022-05-19 12:20:42 +02:00
parent e6c1bf9c9a
commit 75a771bfec

View File

@ -10,27 +10,27 @@ exec_prefix = @exec_prefix@
DESTDIR = DESTDIR =
# /etc/ejabberd/ # /etc/ejabberd/
ETCDIR = $(DESTDIR)@sysconfdir@/ejabberd ETCDIR = @sysconfdir@/ejabberd
# /bin/ # /bin/
BINDIR = $(DESTDIR)@bindir@ BINDIR = @bindir@
# /sbin/ # /sbin/
SBINDIR = $(DESTDIR)@sbindir@ SBINDIR = @sbindir@
# /lib/ # /lib/
LIBDIR = $(DESTDIR)@libdir@ LIBDIR = @libdir@
# /lib/ejabberd/ # /lib/ejabberd/
EJABBERDDIR = $(DESTDIR)@libdir@/ejabberd EJABBERDDIR = @libdir@/ejabberd
# /share/doc/ejabberd # /share/doc/ejabberd
PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
datarootdir = @datarootdir@ datarootdir = @datarootdir@
DOCDIR = $(DESTDIR)@docdir@ DOCDIR = @docdir@
# /share/doc/man/man5 # /share/doc/man/man5
MANDIR = $(DESTDIR)@mandir@/man5 MANDIR = @mandir@/man5
# /usr/lib/ejabberd/ebin/ # /usr/lib/ejabberd/ebin/
BEAMDIR = $(EJABBERDDIR)/ebin BEAMDIR = $(EJABBERDDIR)/ebin
@ -66,10 +66,10 @@ SQLDIR = $(PRIVDIR)/sql
LUADIR = $(PRIVDIR)/lua LUADIR = $(PRIVDIR)/lua
# /var/lib/ejabberd/ # /var/lib/ejabberd/
SPOOLDIR = $(DESTDIR)@localstatedir@/lib/ejabberd SPOOLDIR = @localstatedir@/lib/ejabberd
# /var/log/ejabberd/ # /var/log/ejabberd/
LOGDIR = $(DESTDIR)@localstatedir@/log/ejabberd LOGDIR = @localstatedir@/log/ejabberd
INSTALLUSER=@INSTALLUSER@ INSTALLUSER=@INSTALLUSER@
# if no user was enabled, don't set privileges or ownership # if no user was enabled, don't set privileges or ownership
@ -201,7 +201,7 @@ ELIXIR_TO_DEST=$(LIBDIR) $(call VERSIONED_DEP,$(word 2,$(1))) $(wordlist 5,1000,
DEPS_TO_DEST=$(LIBDIR) $(call VERSIONED_DEP,$(word 2,$(1))) $(wordlist 3,1000,$(1)) DEPS_TO_DEST=$(LIBDIR) $(call VERSIONED_DEP,$(word 2,$(1))) $(wordlist 3,1000,$(1))
MAIN_TO_DEST=$(LIBDIR) $(call VERSIONED_DEP,ejabberd) $(1) MAIN_TO_DEST=$(LIBDIR) $(call VERSIONED_DEP,ejabberd) $(1)
TO_DEST_SINGLE=$(if $(subst X$(DEPSBASE)X,,X$(word 1,$(1))X),$(call MAIN_TO_DEST,$(1)),$(if $(subst XlibX,,X$(word $(LIBIX),$(1))X),$(call DEPS_TO_DEST,$(wordlist $(DEPIX),1000,$(1))),$(call ELIXIR_TO_DEST,$(wordlist $(DEPIX),1000,$(1))))) TO_DEST_SINGLE=$(if $(subst X$(DEPSBASE)X,,X$(word 1,$(1))X),$(call MAIN_TO_DEST,$(1)),$(if $(subst XlibX,,X$(word $(LIBIX),$(1))X),$(call DEPS_TO_DEST,$(wordlist $(DEPIX),1000,$(1))),$(call ELIXIR_TO_DEST,$(wordlist $(DEPIX),1000,$(1)))))
TO_DEST=$(foreach path,$(1),$(call JOIN_PATHS,$(call TO_DEST_SINGLE,$(subst /, ,$(path))))) TO_DEST=$(foreach path,$(1),$(call JOIN_PATHS,$(DESTDIR)$(call TO_DEST_SINGLE,$(subst /, ,$(path)))))
FILTER_DIRS=$(foreach path,$(1),$(if $(wildcard $(path)/*),,$(path))) FILTER_DIRS=$(foreach path,$(1),$(if $(wildcard $(path)/*),,$(path)))
FILES_WILDCARD=$(call FILTER_DIRS,$(foreach w,$(1),$(wildcard $(w)))) FILES_WILDCARD=$(call FILTER_DIRS,$(foreach w,$(1),$(wildcard $(w))))
@ -242,7 +242,7 @@ $(foreach file,$(DEPS_FILES_FILTERED) $(MAIN_FILES),$(eval $(call COPY_template,
$(foreach file,$(BINARIES),$(eval $(call COPY_BINARY_template,$(file)))) $(foreach file,$(BINARIES),$(eval $(call COPY_BINARY_template,$(file))))
$(sort $(call TO_DEST,$(MAIN_DIRS) $(DEPS_DIRS))): $(sort $(call TO_DEST,$(MAIN_DIRS) $(DEPS_DIRS))):
$(INSTALL) -d $@ $(INSTALL) -d $@
$(call TO_DEST,priv/sql/lite.sql): sql/lite.sql $(call TO_DEST,priv/sql) $(call TO_DEST,priv/sql/lite.sql): sql/lite.sql $(call TO_DEST,priv/sql)
$(INSTALL) -m 644 $< $@ $(INSTALL) -m 644 $< $@
@ -311,23 +311,23 @@ ejabberdctl.example: vars.config
install: copy-files ejabberdctl.example install: copy-files ejabberdctl.example
# #
# Configuration files # Configuration files
$(INSTALL) -d -m 750 $(G_USER) $(ETCDIR) $(INSTALL) -d -m 750 $(G_USER) $(DESTDIR)$(ETCDIR)
[ -f $(ETCDIR)/ejabberd.yml ] \ [ -f $(DESTDIR)$(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 $(DESTDIR)$(ETCDIR)/ejabberd.yml-new \
|| $(INSTALL) -b -m 640 $(G_USER) ejabberd.yml.example $(ETCDIR)/ejabberd.yml || $(INSTALL) -b -m 640 $(G_USER) ejabberd.yml.example $(DESTDIR)$(ETCDIR)/ejabberd.yml
[ -f $(ETCDIR)/ejabberdctl.cfg ] \ [ -f $(DESTDIR)$(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 $(DESTDIR)$(ETCDIR)/ejabberdctl.cfg-new \
|| $(INSTALL) -b -m 640 $(G_USER) ejabberdctl.cfg.example $(ETCDIR)/ejabberdctl.cfg || $(INSTALL) -b -m 640 $(G_USER) ejabberdctl.cfg.example $(DESTDIR)$(ETCDIR)/ejabberdctl.cfg
$(INSTALL) -b -m 644 $(G_USER) inetrc $(ETCDIR)/inetrc $(INSTALL) -b -m 644 $(G_USER) inetrc $(DESTDIR)$(ETCDIR)/inetrc
# #
# Administration script # Administration script
[ -d $(SBINDIR) ] || $(INSTALL) -d -m 755 $(SBINDIR) [ -d $(DESTDIR)$(SBINDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(SBINDIR)
$(INSTALL) -m 550 $(G_USER) ejabberdctl.example $(SBINDIR)/ejabberdctl $(INSTALL) -m 550 $(G_USER) ejabberdctl.example $(DESTDIR)$(SBINDIR)/ejabberdctl
# Elixir binaries # Elixir binaries
[ -d $(BINDIR) ] || $(INSTALL) -d -m 755 $(BINDIR) [ -d $(DESTDIR)$(BINDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(BINDIR)
[ -f $(DEPSDIR)/elixir/bin/iex ] && $(INSTALL) -m 550 $(G_USER) $(DEPSDIR)/elixir/bin/iex $(BINDIR)/iex || true [ -f $(DEPSDIR)/elixir/bin/iex ] && $(INSTALL) -m 550 $(G_USER) $(DEPSDIR)/elixir/bin/iex $(DESTDIR)$(BINDIR)/iex || true
[ -f $(DEPSDIR)/elixir/bin/elixir ] && $(INSTALL) -m 550 $(G_USER) $(DEPSDIR)/elixir/bin/elixir $(BINDIR)/elixir || true [ -f $(DEPSDIR)/elixir/bin/elixir ] && $(INSTALL) -m 550 $(G_USER) $(DEPSDIR)/elixir/bin/elixir $(DESTDIR)$(BINDIR)/elixir || true
[ -f $(DEPSDIR)/elixir/bin/mix ] && $(INSTALL) -m 550 $(G_USER) $(DEPSDIR)/elixir/bin/mix $(BINDIR)/mix || true [ -f $(DEPSDIR)/elixir/bin/mix ] && $(INSTALL) -m 550 $(G_USER) $(DEPSDIR)/elixir/bin/mix $(DESTDIR)$(BINDIR)/mix || true
# #
# Init script # Init script
$(SED) -e "s*@ctlscriptpath@*$(SBINDIR)*g" \ $(SED) -e "s*@ctlscriptpath@*$(SBINDIR)*g" \
@ -342,59 +342,59 @@ install: copy-files ejabberdctl.example
chmod 644 ejabberd.service chmod 644 ejabberd.service
# #
# Spool directory # Spool directory
$(INSTALL) -d -m 750 $(O_USER) $(SPOOLDIR) $(INSTALL) -d -m 750 $(O_USER) $(DESTDIR)$(SPOOLDIR)
$(CHOWN_COMMAND) -R @INSTALLUSER@ $(SPOOLDIR) >$(CHOWN_OUTPUT) $(CHOWN_COMMAND) -R @INSTALLUSER@ $(DESTDIR)$(SPOOLDIR) >$(CHOWN_OUTPUT)
chmod -R 750 $(SPOOLDIR) chmod -R 750 $(DESTDIR)$(SPOOLDIR)
# #
# Log directory # Log directory
$(INSTALL) -d -m 750 $(O_USER) $(LOGDIR) $(INSTALL) -d -m 750 $(O_USER) $(DESTDIR)$(LOGDIR)
$(CHOWN_COMMAND) -R @INSTALLUSER@ $(LOGDIR) >$(CHOWN_OUTPUT) $(CHOWN_COMMAND) -R @INSTALLUSER@ $(DESTDIR)$(LOGDIR) >$(CHOWN_OUTPUT)
chmod -R 750 $(LOGDIR) chmod -R 750 $(DESTDIR)$(LOGDIR)
# #
# Documentation # Documentation
$(INSTALL) -d $(MANDIR) $(INSTALL) -d $(DESTDIR)$(MANDIR)
$(INSTALL) -d $(DOCDIR) $(INSTALL) -d $(DESTDIR)$(DOCDIR)
[ -f man/ejabberd.yml.5 ] \ [ -f man/ejabberd.yml.5 ] \
&& $(INSTALL) -m 644 man/ejabberd.yml.5 $(MANDIR) \ && $(INSTALL) -m 644 man/ejabberd.yml.5 $(DESTDIR)$(MANDIR) \
|| echo "Man page not included in sources" || echo "Man page not included in sources"
$(INSTALL) -m 644 COPYING $(DOCDIR) $(INSTALL) -m 644 COPYING $(DESTDIR)$(DOCDIR)
uninstall: uninstall-binary uninstall: uninstall-binary
uninstall-binary: uninstall-binary:
rm -f $(SBINDIR)/ejabberdctl rm -f $(DESTDIR)$(SBINDIR)/ejabberdctl
rm -f $(BINDIR)/iex rm -f $(DESTDIR)$(BINDIR)/iex
rm -f $(BINDIR)/elixir rm -f $(DESTDIR)$(BINDIR)/elixir
rm -f $(BINDIR)/mix rm -f $(DESTDIR)$(BINDIR)/mix
rm -fr $(DOCDIR) rm -fr $(DESTDIR)$(DOCDIR)
rm -f $(BEAMDIR)/*.beam rm -f $(DESTDIR)$(BEAMDIR)/*.beam
rm -f $(BEAMDIR)/*.app rm -f $(DESTDIR)$(BEAMDIR)/*.app
rm -fr $(BEAMDIR) rm -fr $(DESTDIR)$(BEAMDIR)
rm -f $(INCLUDEDIR)/*.hrl rm -f $(DESTDIR)$(INCLUDEDIR)/*.hrl
rm -fr $(INCLUDEDIR) rm -fr $(DESTDIR)$(INCLUDEDIR)
rm -fr $(PBINDIR) rm -fr $(DESTDIR)$(PBINDIR)
rm -f $(SODIR)/*.so rm -f $(DESTDIR)$(SODIR)/*.so
rm -fr $(SODIR) rm -fr $(DESTDIR)$(SODIR)
rm -f $(MSGSDIR)/*.msg rm -f $(DESTDIR)$(MSGSDIR)/*.msg
rm -fr $(MSGSDIR) rm -fr $(DESTDIR)$(MSGSDIR)
rm -f $(CSSDIR)/*.css rm -f $(DESTDIR)$(CSSDIR)/*.css
rm -fr $(CSSDIR) rm -fr $(DESTDIR)$(CSSDIR)
rm -f $(IMGDIR)/*.png rm -f $(DESTDIR)$(IMGDIR)/*.png
rm -fr $(IMGDIR) rm -fr $(DESTDIR)$(IMGDIR)
rm -f $(JSDIR)/*.js rm -f $(DESTDIR)$(JSDIR)/*.js
rm -fr $(JSDIR) rm -fr $(DESTDIR)$(JSDIR)
rm -f $(SQLDIR)/*.sql rm -f $(DESTDIR)$(SQLDIR)/*.sql
rm -fr $(SQLDIR) rm -fr $(DESTDIR)$(SQLDIR)
rm -fr $(LUADIR)/*.lua rm -fr $(DESTDIR)$(LUADIR)/*.lua
rm -fr $(LUADIR) rm -fr $(DESTDIR)$(LUADIR)
rm -fr $(PRIVDIR) rm -fr $(DESTDIR)$(PRIVDIR)
rm -fr $(EJABBERDDIR) rm -fr $(DESTDIR)$(EJABBERDDIR)
uninstall-all: uninstall-binary uninstall-all: uninstall-binary
rm -rf $(ETCDIR) rm -rf $(DESTDIR)$(ETCDIR)
rm -rf $(EJABBERDDIR) rm -rf $(DESTDIR)$(EJABBERDDIR)
rm -rf $(SPOOLDIR) rm -rf $(DESTDIR)$(SPOOLDIR)
rm -rf $(LOGDIR) rm -rf $(DESTDIR)$(LOGDIR)
clean: clean:
rm -rf $(DEPSDIR)/.got rm -rf $(DEPSDIR)/.got