[libvirt] PATCH: 21/25: Use random_r for random numbers

Jim Meyering jim at meyering.net
Wed Jan 21 06:23:04 UTC 2009


"Daniel P. Berrange" <berrange at redhat.com> wrote:
> How about this then....

Looks fine.  Thanks!

> BTW, what's good practice for actually initializing a seed ?
>
>  time() ?
>  time() ^ getpid() ?
>
> anything better ?

You could mix in some more get*id numbers.
If we really care, using gnulib's gethrxtime module
would be nice, but parts of it are GPL'd.
Here's part of coreutils' gl/lib/rand-isaac.c:

void
isaac_seed (struct isaac_state *s)
{
  isaac_seed_start (s);

  { pid_t t = getpid ();   ISAAC_SEED (s, t); }
  { pid_t t = getppid ();  ISAAC_SEED (s, t); }
  { uid_t t = getuid ();   ISAAC_SEED (s, t); }
  { gid_t t = getgid ();   ISAAC_SEED (s, t); }

  {
    xtime_t t = gethrxtime ();
    ISAAC_SEED (s, t);
  }

  isaac_seed_finish (s);
}

> diff --git a/Makefile.maint b/Makefile.maint

ACK




More information about the libvir-list mailing list