On Thursday 20 September 2012 13:31:55 Ron Yorston wrote: > 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 <r...@tigress.co.uk> > --- > 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; >
Hi, a cleaner fix without unsetting env vars could be: --- debianutils/mktemp.c.original 2012-09-20 15:32:32.000000000 +0200 +++ debianutils/mktemp.c 2012-09-20 15:34:47.000000000 +0200 @@ -95,7 +95,7 @@ if (!chp) return EXIT_FAILURE; if (!(opts & (OPT_t|OPT_p))) - chp += 2; + chp = bb_get_last_path_component_strip(chp); goto ret; } This seems to work for me as expected eventually needs more testing. Ciao, Tito
Fix ./busybox mktemp -u temp.XXXXXX returning garbage: mp/temp.ddTkNr when TMPDIR env var is set. Signed-off by Tito Ragusa <farmat...@tiscali.it> --- debianutils/mktemp.c.original 2012-09-20 15:32:32.000000000 +0200 +++ debianutils/mktemp.c 2012-09-20 15:34:47.000000000 +0200 @@ -95,7 +95,7 @@ if (!chp) return EXIT_FAILURE; if (!(opts & (OPT_t|OPT_p))) - chp += 2; + chp = bb_get_last_path_component_strip(chp); goto ret; }
_______________________________________________ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox