hurd: Make getrandom return ENOSYS when /dev/random is not set up
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Sat, 1 Jul 2023 12:23:40 +0000 (14:23 +0200)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Sat, 1 Jul 2023 12:23:40 +0000 (14:23 +0200)
So that callers (e.g. __arc4random_buf) don't try calling it again.

sysdeps/mach/hurd/getrandom.c

index 0d28f5c260284b6eda9d20f1fa25271abbe1547f..a7706afe82d1d293241739286d1a6b2f93088d7e 100644 (file)
@@ -123,8 +123,13 @@ again:
                                                     open_flags, 0);
       __libc_rwlock_unlock (lock);
       if (!MACH_PORT_VALID (server))
-        /* No luck.  */
-        return -1;
+       {
+         if (errno == ENOENT)
+           /* No translator set up, we won't have support for it.  */
+           errno = ENOSYS;
+         /* No luck.  */
+         return -1;
+       }
 
       goto again;
     }