[PATCH] mktemp: fix -u option if TMPDIR is set

walter harms wharms at bfs.de
Thu Sep 20 12:21:45 UTC 2012


I can no reproduce that.
What libc you are using ?
What mktemp ? (busybox or others ? if Busybox what version ?)

re,
 wh

Am 20.09.2012 13:31, schrieb Ron Yorston:
> 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 <rmy at 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;


More information about the busybox mailing list