[PATCH v2 1/2] mktemp: avoid removed mktemp()
Denys Vlasenko
vda.linux at googlemail.com
Mon Apr 14 12:29:21 UTC 2014
On Mon, Apr 14, 2014 at 12:20 PM, Bernhard Reutner-Fischer
<rep.dot.nop at gmail.com> wrote:
>> This is a change in behavior - now we would
>> actually create, and then immediately delete the directory
>> if run as "mktemp -du".
>>
>> I have mixed feelings about that.
>> Do you think it's ok?
>
> I think it's ok, yes. The race-window is about the same as
> before, the creat()/unlink() do make it a bit slower but that
> is IMO ok.
There was no race at all before for "mktemp -n" case:
if (opts & OPT_u) {
chp = mktemp(chp);
if (chp[0] == '\0')
goto error;
} else ...
puts(chp);
return EXIT_SUCCESS;
No race here.
Your patch would add one.
> An alternative would be to export a uClibc-specific
> __gen_tempname() function to avoid all those duplicate implementations
> (in busybox, coreutils etc, etc) but i don't really think it's worth the effort
> given that only mktemp(1) has something like it's -u and -u
> obviously should not be used in the first place (due to races).
We need to support compatibility anyway. So...
> An alternative would be to export a uClibc-specific
> __gen_tempname() function
How about exporting a function named mktemp()?
;)
POSIX removing it from its text doesn't mean that
a conforming libc must *not* provide it.
--
vda
More information about the busybox
mailing list