]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
random-seed: drop falling back to O_WRONLY if O_RDWR on /dev/urandom doesn't work
authorLennart Poettering <lennart@poettering.net>
Mon, 22 Jul 2019 08:24:50 +0000 (10:24 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 25 Jul 2019 16:20:50 +0000 (18:20 +0200)
There's no reason why writing should work if reading and writing
doesn't. Let's simplify this hence. /dev/urandom is generally an r/w
device, and everything else would be a serious system misconfiguration.

src/random-seed/random-seed.c

index 1a1ce8caa4af1b988139c28c3a346001ea42ad54..dc148ebc86a3acffcbecc9675cdbc3e7e9e66f19 100644 (file)
@@ -67,13 +67,8 @@ static int run(int argc, char *argv[]) {
                         write_seed_file = true;
 
                 random_fd = open("/dev/urandom", O_RDWR|O_CLOEXEC|O_NOCTTY, 0600);
-                if (random_fd < 0) {
-                        write_seed_file = false;
-
-                        random_fd = open("/dev/urandom", O_WRONLY|O_CLOEXEC|O_NOCTTY, 0600);
-                        if (random_fd < 0)
-                                return log_error_errno(errno, "Failed to open /dev/urandom: %m");
-                }
+                if (random_fd < 0)
+                        return log_error_errno(errno, "Failed to open /dev/urandom: %m");
 
                 read_seed_file = true;