[Toybox] [PATCH] mktemp: fix the tests and the logic.

Rob Landley rob at landley.net
Fri Dec 7 07:34:39 PST 2018


On 12/6/18 1:11 PM, enh wrote:
> On Thu, Dec 6, 2018 at 10:48 AM Rob Landley <rob at landley.net> wrote:
>>
>> On 12/6/18 10:55 AM, enh wrote:
>>> it occurred to me overnight that the passwd code allows '/'. plus, as
>>> i've said, it seems to be slightly wrong. so i've just sent a
>>> replacement for my second patch (to be applied on top of the first
>>> patch) that just does the simplest xgetrandom + convert to valid
>>> character loop.
>>>
>>> can we at least get the first patch in, since mktemp is pretty broken
>>> right now (_except_ for -u, which was all the old tests exercised)?
>>
>> Can you send me just a tests/mktemp.test patch to demonstrate the failures? I'll
>> try to fix it this evening. (Too many changes at once, I need to know what
>> success looks like...)
> 
> you could just apply the two patches... that way you'll have the tests
> _and_ they'll pass. (the _real_ question is whether we're still
> missing important tests, since we were only testing -u until now. plus
> testing "the Xs get replaced with random data" is inherently hard to
> test.)
> 
> i've attached "just the tests" to this mail.

Sorry for the delay replying, gmail unsubscribed everybody from the list again
and I had to do the web gui dance.

I just pushed a version that passes all those tests, but there's probably more
corner cases to add to mktemp.test. My notes are to check what -p "" and
TMPDIR="" do (set but act like not set), look at unifying the passwd and salt
and mktemp random char functions, and my "I tested this while developing" cut
and paste backscroll is:

$ TMPDIR=. mktemp -u blah.XXX
blah.Iq2
$ TMPDIR=/tmp mktemp -u murgle blah.XXX
mktemp: too many templates
$ TMPDIR=/tmp mktemp -p murgle/ blah.XXX
mktemp: failed to create file via template ‘murgle/blah.XXX’: No such file or
directory
$ TMPDIR=/tmp mktemp -up murgle/ blah.XXX
murgle/blah.jjs
$ TMPDIR=/tmp mktemp -tup murgle/ blah.XXX
/tmp/blah.3NR
$ mktemp -tup murgle/ blah.XXX
murgle/blah.rel
$ mktemp -tup "" blah.XXX
blah.V6Q
$ TMPDIR=/woot mktemp -tup "" blah.XXX
/woot/blah.lpm
$ TMPDIR=/woot mktemp -up "" blah.XXX
/woot/blah.Fh5

But it is $DAYJOB time again...

Rob



More information about the Toybox mailing list