[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] [PATCH] Use bash for several contrib scripts
From: |
Ingo Schwarze |
Subject: |
Re: [Groff] [PATCH] Use bash for several contrib scripts |
Date: |
Fri, 3 Jan 2014 01:41:32 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Hi,
Tethys wrote on Fri, Jan 03, 2014 at 12:06:31AM +0000:
> Colin Watson writes:
>>Perhaps just:
>>
>> tmp=$d/eqn2graph$${$RANDOM:+-$RANDOM}
>>
>>then?
That, or just
tmp=$d/eqn2graph$$-`date +%Y%m%d%H%M%S`
A collision is not dangerous in terms of security,
and we are only talking about a fallback solution
for systems lacking a proper mktemp(1), so having
something that is pure POSIX and improbable to collide
is maybe better than hoping for urandom(4) and sum(1);
i admit the latter comes from V2 AT&T UNIX, but it isn't
standardized by POSIX.
Yours,
Ingo
> Since it's not guaranteed to be present, why not just ignore $RANDOM
> and use our own randomly generated integer instead? Something like:
>
> groff_rand=$(dd if=/dev/urandom bs=8 count=1 2>/dev/null | sum | sed
> 's/^0*//;s/ .*//')
> tmp="$d/eqn2graph$groff_rand"
>
> should work and be portable. I think pretty much everywhere supports
> /dev/urandom, right? If not we could use /dev/random with the minimal
> chance of it blocking.
>
> Tet