From 9bb0d5766eeb200dae447a616903f14a0079aa63 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 22 Jul 2008 09:20:52 +0200 Subject: [PATCH] tests: ensure "make check" w/tainted build dir no longer impacts $HOME * maint.mk (taint-distcheck): New rule. (maintainer-distcheck): Make it. --- maint.mk | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/maint.mk b/maint.mk index 19b7f121e..eb241b60b 100644 --- a/maint.mk +++ b/maint.mk @@ -667,6 +667,7 @@ cvs-check: vc-diff-check maintainer-distcheck: $(MAKE) distcheck + $(MAKE) taint-distcheck $(MAKE) my-distcheck @@ -695,6 +696,36 @@ TMPDIR ?= /tmp t=$(TMPDIR)/$(PACKAGE)/test pfx=$(t)/i +# More than once, tainted build and source directory names would +# have caused at least one "make check" test to apply "chmod 700" +# to all directories under $HOME. Make sure it doesn't happen again. +tp := $(shell echo "$(TMPDIR)/$(PACKAGE)-$$$$") +t_prefix = $(tp)/a +t_taint = '$(t_prefix) b' +fake_home = $(tp)/home + +# Ensure that tests run from tainted build and src dir names work, +# and don't affect anything in $HOME. Create witness files in $HOME, +# record their attributes, and build/test. Then ensure that the +# witnesses were not affected. +taint-distcheck: $(DIST_ARCHIVES) + test -d $(t_taint) && chmod -R 700 $(t_taint) || : + -rm -rf $(t_taint) $(fake_home) + mkdir -p $(t_prefix) $(t_taint) $(fake_home) + GZIP=$(GZIP_ENV) $(AMTAR) -C $(t_taint) -zxf $(distdir).tar.gz + mkfifo $(fake_home)/fifo + touch $(fake_home)/f + mkdir -p $(fake_home)/d/e + ls -lR $(fake_home) $(t_prefix) > $(tp)/.ls-before + cd $(t_taint)/$(distdir) \ + && ./configure \ + && $(MAKE) \ + && HOME=$(fake_home) $(MAKE) check \ + && ls -lR $(fake_home) $(t_prefix) > $(tp)/.ls-after \ + && diff $(tp)/.ls-before $(tp)/.ls-after \ + && test -d $(t_prefix) + rm -rf $(tp) + # Verify that a twisted use of --program-transform-name=PROGRAM works. define install-transform-check rm -rf $(pfx); \ -- 2.34.1