Sweets / hummingbird

Hummingbird init system for Linux based operating systems.
MIT License
250 stars 7 forks source link

rc.init: fixed slow loading during setup_random #9

Closed lieux closed 5 years ago

lieux commented 5 years ago

/dev/random generates PRNGs slower than /dev/urandom which is suspected to slow down the setup_random function during boot

Taken from: https://git.2f30.org/ports/file/fs/bin/rc.init.html#l86 https://git.2f30.org/ports/file/fs/bin/rc.shutdown.html#l43

Sweets commented 5 years ago

/dev/random slow-downs are due to its security. It will block until enough entropy is collected to be more random than off of a cold boot alone (entropy is collected from mouse movements, keyboard input, microphone input, etc).

I don't know that speed and security should necessarily be a trade-off. So, I think what I may do is have the seeding forked into the background during boot.

lieux commented 5 years ago

So does this mean that input (mouse movements, keyboard input, microphone input, etc.) is always necessary during boot?

Sweets commented 5 years ago

Not necessarily; it's hardware dependent, but even if there's no external USB devices, the kernel still draws entropy from jack inputs with nothing plugged in. Some systems may generate entropy faster than others. This is the point behind a seed file, though.

That being said, a seed file is created on a safe shutdown using hummingbird. If you don't mind testing something for me, start your machine, log in, and then shutdown using the shutdown command. The next boot should pan out without needing input at all.

Sweets commented 5 years ago

Alright, so I reverted the input file to be the random device, and changed the directory to /var; I didn't want to use another temporary directory in the event that it gets washed by another process for whatever reason, and the seed is by some definition variable data.

This should suffice; it will have you do input and such on the first boot, but the following reboots should be fine. I also changed it so the file isn't removed. This was for no real reason other than the seed not being in a temporary directory anymore, so it has no reason to be removed.

Sweets commented 5 years ago

If these changes work on your system as well, I'll merge them in, just let me know.

lieux commented 5 years ago

Working fine. Thank you.