Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] zsh/random module [UPDATED]





On 11/24/22 03:58, Clinton Bunch wrote:
[snip]
+/**/
+int
+setup_(UNUSED(Module m))
+{
+#ifdef USE_URANDOM
+    /* Check for the existence of /dev/urandom */
+
+    struct stat st;
+
+    if (lstat("/dev/urandom",&st) < 0) {
Why not stat()?
Is it appropriate for /dev/urandom to be a symlink?

Yes, for example that is the case on freebsd where urandom is just a symlink to random for compatibility with programs that expect urandom to be there (random blocks until the randomness pool is seeded and then doesn't block anymore).


+    zwarn("No kernel random pool found.");
+    return 1;
+    }
+
+    if (!(S_ISCHR(st.st_mode)) ) {
+    zwarn("No kernel random pool found.");
+    return 1;
+    }

So this check would be wrong on freebsd (or use random directly and give an option to use urandom on systems where random starts to block for some reason after being seeded, but no idea if there is a good reason for random being a symlink).

[snip]




Messages sorted by: Reverse Date, Date, Thread, Author