With the -u option mktemp uses tempnam to generate the temporary file
name.  This mostly works as required, but the TMPDIR environment variable
trumps any path supplied to tempnam.  If TMPDIR is set unexpected behaviour
ensues:

   $ mktemp -u temp.XXXXXX
   temp.4qYDxk
   $ mktemp -u -t temp.XXXXXX
   /tmp/temp.8gP6Pq
   $ export TMPDIR=/tmp
   $ mktemp -u temp.XXXXXX
   mp/temp.BuEBHM

Signed-off-by: Ron Yorston <[email protected]>
---
 debianutils/mktemp.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/debianutils/mktemp.c b/debianutils/mktemp.c
index dbe4309..b6833af 100644
--- a/debianutils/mktemp.c
+++ b/debianutils/mktemp.c
@@ -91,6 +91,7 @@ int mktemp_main(int argc UNUSED_PARAM, char **argv)
                while (--cnt >= 0 && chp[--len] == 'X')
                        chp[len] = '\0';
 
+               unsetenv("TMPDIR");
                chp = tempnam(opts & (OPT_t|OPT_p) ? path : "./", chp);
                if (!chp)
                        return EXIT_FAILURE;
-- 
1.7.4.4

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to