]> git.ipfire.org Git - thirdparty/util-linux.git/commit
lib/randutils: don't break on EAGAIN, use usleep()
authorKarel Zak <kzak@redhat.com>
Tue, 20 Mar 2018 13:17:24 +0000 (14:17 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 20 Mar 2018 13:17:24 +0000 (14:17 +0100)
commitedc1c90cb972fdca1f66be5a8e2b0706bd2a4949
treee523d85686a7a0f59e22428685f5eae5df07980c
parent6ffdfda8460b1a336165a18b08f0f5946af9cd11
lib/randutils: don't break on EAGAIN, use usleep()

The current code uses lose_counter to make more attempts to read
random numbers. It seems better to wait a moment between attempts to
avoid busy loop (we do the same in all-io.h).

The worst case is 1 second delay for all random_get_bytes() on systems
with uninitialized entropy pool -- for example you call sfdisk (MBR Id
or GPT UUIDs) on very first boot, etc. In this case it will use libc
rand() as a fallback solution.

Note that we do not use random numbers for security sensitive things
like keys or so. It's used for random based UUIDs etc.

Addresses: https://github.com/karelzak/util-linux/pull/603
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/randutils.c