WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: busybox mktemp  (Read 4721 times)

Offline gutmensch

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 605
  • I can make it disappear, have no fear!
    • remembrance blog
busybox mktemp
« on: June 15, 2010, 12:47:25 PM »
mktemp creates a temporary file in the current directory instead of /tmp/ which is quite confusing compared to other linux distros.

If that is intentionally, then I don't know why ;-)
If I seem unduly clear to you, you must have misunderstood what I said. (Alan Greenspan)

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: busybox mktemp
« Reply #1 on: June 15, 2010, 01:32:09 PM »
Gutmensch:
According to 'man mktemp' you need to use the -t or -p option to create the tmp file in another directory.
I just tested mktemp on V3a7, and it works as expected.

Offline gutmensch

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 605
  • I can make it disappear, have no fear!
    • remembrance blog
Re: busybox mktemp
« Reply #2 on: June 15, 2010, 01:59:50 PM »
@gerald:
My man page (for coreutils mktemp) says:
Quote
       -p DIR use DIR as a prefix; implies -t [deprecated]
 
        -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]
(the word about to notice is of course "deprecated")

and (busybox mktemp)

Code: [Select]
$ mktemp --help
[snip]...[/snip]
For -t or -p, directory is chosen as follows:
[b]$TMPDIR if set, else -p DIR, else /tmp[/b]

There we go ... else /tmp.

mktemp defaults to /tmp without using any -p or -t ! That's exactly the way it works on my fedora and debian with the GNU version too. So in tinycore it does not work as expected because it does not default to /tmp. ;-) The coreutils version of mktemp works correctly and defaults to /tmp. Maybe a busybox issue?
If I seem unduly clear to you, you must have misunderstood what I said. (Alan Greenspan)

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: busybox mktemp
« Reply #3 on: June 15, 2010, 03:14:03 PM »
Gutmensch:
You are correct.
According to the manual, if no template is provided, -t is implied.

Offline gutmensch

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 605
  • I can make it disappear, have no fear!
    • remembrance blog
Re: busybox mktemp
« Reply #4 on: June 15, 2010, 03:22:12 PM »
hmm, well the busybox mktemp has a different behaviour than the coreutils mktemp.

coreutils:
$ /usr/local/bin/mktemp
/tmp/tmp.CN07yOXahI

busybox:
$ /bin/mktemp
tmp.QOBI2I

$ /bin/mktemp -t
/tmp/tmp.mhRcRH

So for the busybox version you need either TMPDIR or -t to get a full path rooted temp file in /tmp. I'd call that a "deprecated" behaviour of the busybox rebuild and I cannot say that I find it very useful. ;-)


If I seem unduly clear to you, you must have misunderstood what I said. (Alan Greenspan)

Offline ^thehatsrule^

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 1726
Re: busybox mktemp
« Reply #5 on: June 15, 2010, 03:39:47 PM »
So for the busybox version you need either TMPDIR or -t to get a full path rooted temp file in /tmp. I'd call that a "deprecated" behaviour of the busybox rebuild and I cannot say that I find it very useful. ;-)
Or the usual way by specifying it in the template

If this is really a problem, perhaps you can file it in upstream busybox.

Offline gutmensch

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 605
  • I can make it disappear, have no fear!
    • remembrance blog
Re: busybox mktemp
« Reply #6 on: June 18, 2010, 03:46:46 AM »
@hats: that's what I did ;-)

Quote
On Wednesday 16 June 2010 00:06, Robert wrote:
> > Kind greetings from a new ML member ;-)
> >
> > Forgive me if I'm reviving an old topic but ML search did not reveal
> > anything related to that topic. I wondered today whether the busybox
> > mktemp(b) and the GNU coreutils mktemp(c) (b and c just as abbr.) have a
> > different behaviour.
> >
> > mktemp(c) states the options -t and -p as deprecated and mktemp(b) only
> > works like mktemp(c), when the option -t is specified.
> >
> > Example:
> >
> > $ mktemp(c)
> > /tmp/tmp.8fM3VmH3PF
> >
> > $ mktemp(b)
> > tmp.DqP4t2
> >
> > $ mktemp(b) -t
> > /tmp/tmp.Amsp3O
> >
> > Is there any special intention about that difference? As coreutils
> > states -t and -p as deprecated I would prefer to not writing scripts
> > with the -t option (when that might lead to an error in the future).
> > Would it be possible to change the default behaviour of mktemp(b) to use
> > the absolute path of the /tmp/ folder like it is in coreutils?

You are right. Here is the fix:

http://git.busybox.net/busybox/commit/?id=9b814ca6335806a6eb47e22805620ec81d5d849d

-- vda
If I seem unduly clear to you, you must have misunderstood what I said. (Alan Greenspan)

Offline grisxa

  • Newbie
  • *
  • Posts: 27
Re: busybox mktemp
« Reply #7 on: July 29, 2010, 03:45:59 AM »
Hello!
This patch should be applied to TCL' busybox
http://busybox.net/downloads/fixes-1.17.0/busybox-1.17.0-mktemp.patch
Otherwise mktemp fails to create a file with absolute mask:
$ mktemp /tmp/tmp.XXXXXX
Because it tries to prepend default tempdir: /tmp/tmp/tmp.XXXXXX