From 9ec9d7e56028a0563a9eed261e5e3a61153422c4 Mon Sep 17 00:00:00 2001 From: sjg Date: Sun, 4 Jul 2021 01:28:54 +0000 Subject: [PATCH] Do not assume /tmp is safe to use if TMPDIR is set --- usr.bin/make/unit-tests/objdir-writable.exp | 2 +- usr.bin/make/unit-tests/objdir-writable.mk | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/usr.bin/make/unit-tests/objdir-writable.exp b/usr.bin/make/unit-tests/objdir-writable.exp index 9c507f647f8c..e7298a66d369 100644 --- a/usr.bin/make/unit-tests/objdir-writable.exp +++ b/usr.bin/make/unit-tests/objdir-writable.exp @@ -1,5 +1,5 @@ make warning: TMPDIR/roobj: Permission denied. -/tmp +TMPDIR TMPDIR/roobj TMPDIR/roobj exit status 0 diff --git a/usr.bin/make/unit-tests/objdir-writable.mk b/usr.bin/make/unit-tests/objdir-writable.mk index 9fc1c69afb56..b09baa3c32b2 100644 --- a/usr.bin/make/unit-tests/objdir-writable.mk +++ b/usr.bin/make/unit-tests/objdir-writable.mk @@ -1,8 +1,9 @@ -# $NetBSD: objdir-writable.mk,v 1.4 2020/11/14 07:36:00 sjg Exp $ +# $NetBSD: objdir-writable.mk,v 1.5 2021/07/04 01:28:54 sjg Exp $ # test checking for writable objdir -RO_OBJDIR?= ${TMPDIR:U/tmp}/roobj +TMPDIR?= /tmp +RO_OBJDIR?= ${TMPDIR}/roobj .if make(do-objdir) # this should succeed @@ -20,12 +21,12 @@ rm-objdir: @rmdir ${RO_OBJDIR} no-objdir: - @MAKEOBJDIR=${RO_OBJDIR} ${.MAKE} -r -f /dev/null -C /tmp -V .OBJDIR + @MAKEOBJDIR=${RO_OBJDIR} ${.MAKE} -r -f /dev/null -C ${TMPDIR} -V .OBJDIR ro-objdir: - @MAKEOBJDIR=${RO_OBJDIR} ${.MAKE} -r -f /dev/null -C /tmp -V .OBJDIR MAKE_OBJDIR_CHECK_WRITABLE=no + @MAKEOBJDIR=${RO_OBJDIR} ${.MAKE} -r -f /dev/null -C ${TMPDIR} -V .OBJDIR MAKE_OBJDIR_CHECK_WRITABLE=no explicit-objdir: - @MAKEOBJDIR=/tmp ${.MAKE} -r -f ${MAKEFILE:tA} -C /tmp do-objdir -V .OBJDIR + @MAKEOBJDIR=${TMPDIR} ${.MAKE} -r -f ${MAKEFILE:tA} -C ${TMPDIR} do-objdir -V .OBJDIR .endif