[PATCH v2] seedrng: import SeedRNG utility for kernel RNG seed files
Jason A. Donenfeld
Jason at zx2c4.com
Sun Apr 10 20:53:16 UTC 2022
Hi Bernhard,
On Sun, Apr 10, 2022 at 10:34 PM Bernhard Reutner-Fischer
<rep.dot.nop at gmail.com> wrote:
> well that'd be xopen_xwrite_close(), fsync and then rename_or_warn but
> since for fsync we'd need an fd there might no (big?) net benefit.
Right, we need the fd before closing it. And rename_or_warn doesn't
help us at all. So dead end here.
> btw for the getuid() failure, we have bb_msg_you_must_be_root[] or
> bb_msg_perm_denied_are_you_root[]
Oh, nice. Will use that. Saves 27 bytes.
> So what about the errno in seed_rng.
> Can we just leave errno alone and report a failure in this function
> only? And only afterwards return -1 and remove the diagnostics from the
> caller?
We _could_, but the call to RNDADDENTROPY is the big thing that this
program does. If it goes wrong, that's the primary place where a user
really wants to learn why. If there ever were an occasion to preserve
errno, it'd be here.
> And just to make that explicit: What's the deal with all those bits in
> the exit code. Are these really necessary?
The tool keeps pummeling through attempting to do at least something
useful. The bits in the error exit code let a caller choose how to
respond to partial successes of different kinds. This is meant to be
called from shell scripts that might want to do that sort of thing.
> I forgot, isn't O_RDONLY sufficient for ioctl? And IIRC there was even
> a non-io mode to just obtain the fd, linux specific, wasn't there.
> Doesn't save anything of course, but RDONLY looks cleaner..
Nice catch, will fix.
v7 coming right up! Hope this is it...
Jason
More information about the busybox
mailing list