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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Daniel P. Berrange" <berrange@xxxxxxxxxx> 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

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]