Re: cvs commit: src/games/fortune/fortune fortune.c

From: Greg 'groggy' Lehey <grog_at_FreeBSD.org>
Date: Sat, 23 Jul 2005 16:14:49 +0930
On Friday, 22 July 2005 at 23:12:30 -0700, Doug Barton wrote:
> Changing venue to -current, since these kinds of protracted discussions
> don't belong on the commit mailing lists.
>
> Greg 'groggy' Lehey wrote:
>
>> But for whatever reasons, many systems seem to have incorrect
>> random(4) initialization.
>
> I don't think it has anything to do with /dev/random initialization, I
> think that there is an error somewhere in the fortune code that is causing
> this problem.

You should take a look at what I committed.  It simply uses the
microsecond value returned by getlocaltime() for the automatic seeding
by srandomdev().  It fixes the problem.  I can see only two
explanations:

1.  srandomdev(), random(4) or friends are broken.
2.  random(4) has been initialized incorrectly.

Currently I'm guessing (2), but I don't care much either way.

> I have seen the same problem Greg has for a long time now,
> but for me it's the fortune with the CVS $FreeBSD$ tag that comes up about
> 8 times out of 10. This is still true even on a system that has been up and
> running for hours, and has kern.random.sys.seeded: 1
>
> I can't tell if it's a problem with how the files are randomized in the
> first place, or how they get played back, but I haven't looked at this very
> hard yet.

The obvious thing is to try this patch and see what happens.

>> You'll recall the debate about removing Rush Limbaugh fortunes recently
>
> I didn't see this debate as I've had e-mail "issues" for the last couple of
> days, what list was it on? 

This was early 2004, it seems.  I've told you the details on IRC (and
I've dropped the buffer from Emacs, so I've forgotten the details;
sorry to the rest of you, but ISTR it was a message from Stephen Mckay
to -chat on 4 January 2004).

> In any case, I would not be at all happy if these fortunes were
> removed. I agreed to add them to the "offensive" fortune database
> because the rule there is that you don't add -o or -a to your
> command line unless you are willing to run the risk of being
> offended.  If every committer gets to go through the fortune
> database and remove every fortune that they find offensive, it's
> going to be a mighty small file.

There was no discussion of that.  If you go back to the thread I
mentioned, you'll see that, though I don't like them, I found it
inappropriate to remove them.

>> This is the only place where it seems to make any difference, so
>> it's easier to use a different seed.
>
> Since my thesis is that this is not a /dev/random initialization
> problem, I tend to agree with you. Just to be on the safe side, I
> have bumped up both the size and number of my /var/db/entropy files,
> and I'll gladly be proven wrong on this one. However, I sincerely
> doubt that this is actually a problem with /dev/random.

It's certainly worth following up on.  From the PoV of fortune, it's
really not worth worrying about the most perfect random number
generator; I suspect that the microsecond seed will satisfy everybody
except possibly the purists.  That doesn't mean that we should forget
the potential issues with random(4).

Greg
--
The virus once contained in this message has lost interest in life,
shrivelled up and died.  LEMIS anti-virus has given it an appropriate
burial.
For further details see http://www.lemis.com/grog/lemis-virus.html

Finger grog_at_FreeBSD.org for PGP public key.
See complete headers for address and phone numbers.

Received on Sat Jul 23 2005 - 04:44:52 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:39 UTC