Fwd: Re: [PATCH] v5 mktemp: make -u option work more like coreutils

Tito farmatito at tiscali.it
Mon Oct 8 13:28:34 UTC 2012


On Monday 08 October 2012 14:40:29 Denys Vlasenko wrote:
> On Mon, Oct 8, 2012 at 1:50 PM, Tito <farmatito at tiscali.it> wrote:
> >> > +   /* Don't allow directory separator in template */
> >> > +   if ((opts & OPT_t) && bb_basename(chp) != chp) {
> >> > +           errno = EINVAL;
> >> > +           goto error;
> >> >     }
> >>
> >> Why? Can't we just allow this to work?
> >
> > man page says:
> >
> >   -t     interpret TEMPLATE as a __single file name___ component, relative to a directory:  $TMPDIR,
> >               if set; else the directory specified via -p; else /tmp [deprecated]
> >
> > and on debian:
> >
> > mktemp -t tmp/tmp.XXXXXXX
> > mktemp: invalid template, `tmp/tmp.XXXXXXX', contains directory separator
> 
> I don't see the point in increasing binary's size
> in order to _restrict_ what the tool can do.
> 
> 

Hi,
the point could be to mimic to expected behaviour of
the real mktemp program as stated by the manpage.
It allows slashes in template only with --tmpdir option
that we don't support yet.

 --tmpdir[=DIR]
              interpret TEMPLATE relative to DIR.  If DIR is not specified, use $TMPDIR if set, else
              /tmp.   With this option, TEMPLATE must not be an absolute name.  Unlike with -t, TEM‐
              PLATE may contain slashes, but mktemp creates only the final component


There could be surprising and not intuitive results:

mkdir /tmp

./busybox mktemp -tu /tmp/prova.XXXXXX
/tmp/tmp/prova.00LtVI


./busybox mktemp -t /tmp/prova.XXXXXX
mktemp: No such file or directory

./busybox mktemp -td /tmp/prova.XXXXXX
mktemp: No such file or directory

but with -p it works without error

./busybox mktemp -t -p /tmp prova.XXXXXX
/tmp/prova.XaBMU0

and without slashes it also works without error

./busybox mktemp -t prova.XXXXXX
/tmp/prova.HwpMCX


Ciao,
Tito



More information about the busybox mailing list