On Fri, Oct 01, 2010 at 11:36:25AM -0400, Ted Unangst wrote:
> nobody should really be using srandom, but we provide it and it's a
> tempting target, so they do. let's give them arandom instead. they'll
> never know the difference, except it may actually work. :)
>
> i included a conversion for urandom on the same principle.
I'm not sure i like this more than a man page patch or symlink, but it's
certainly not my bikeshed. A few trivial comments inline.
> Index: rnd.c
> ===================================================================
> RCS file: /home/tedu/cvs/src/sys/dev/rnd.c,v
> retrieving revision 1.102
> diff -u -r1.102 rnd.c
> --- rnd.c 20 Apr 2010 22:05:41 -0000 1.102
> +++ rnd.c 30 Sep 2010 00:28:48 -0000
> @@ -1073,10 +1039,7 @@
>
> revents = events & (POLLOUT | POLLWRNORM); /* always writable */
> if (events & (POLLIN | POLLRDNORM)) {
> - if (minor(dev) == RND_SRND && random_state.entropy_count <= 0)
> - selrecord(p, &rnd_rsel);
> - else
> - revents |= events & (POLLIN | POLLRDNORM);
> + revents |= events & (POLLIN | POLLRDNORM);
> }
>
> return (revents);
You don't need the if() here anymore, just replace the whole thing with
revents = events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM);
> @@ -1164,8 +1127,7 @@
> }
> }
>
> - if ((minor(dev) == RND_ARND || minor(dev) == RND_ARND_OLD) &&
> - !ret)
> + if (!ret)
> arc4random_initialized = 0;
>
> free(buf, M_TEMP);
>
While you're there, you may also want to replace the 'n / 4' a few lines
above by 'n / sizeof(uint32_t)', for consistency.
I'm running with this patch now, and nothing is obviously broken.
Joachim