summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-02-19 17:50:15 +0100
committerLennart Poettering <lennart@poettering.net>2014-02-19 17:53:50 +0100
commit0f0e240cb8625d832e760ef32ed772e21c316905 (patch)
tree7699be3a9d91b4fa893b85b22f9b0efe8c85402d /src
parent581483bf59ea62147739e71dd2216477be03411c (diff)
sd-id128: use new dev_urandom() call
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd/sd-id128/sd-id128.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/libsystemd/sd-id128/sd-id128.c b/src/libsystemd/sd-id128/sd-id128.c
index 9ee40ab91e..a1e44e6d19 100644
--- a/src/libsystemd/sd-id128/sd-id128.c
+++ b/src/libsystemd/sd-id128/sd-id128.c
@@ -208,22 +208,14 @@ _public_ int sd_id128_get_boot(sd_id128_t *ret) {
}
_public_ int sd_id128_randomize(sd_id128_t *ret) {
- _cleanup_close_ int fd = -1;
sd_id128_t t;
- ssize_t k;
+ int r;
assert_return(ret, -EINVAL);
- fd = open("/dev/urandom", O_RDONLY|O_CLOEXEC|O_NOCTTY);
- if (fd < 0)
- return -errno;
-
- k = loop_read(fd, &t, 16, false);
- if (k < 0)
- return (int) k;
-
- if (k != 16)
- return -EIO;
+ r = dev_urandom(&t, sizeof(t));
+ if (r < 0)
+ return r;
/* Turn this into a valid v4 UUID, to be nice. Note that we
* only guarantee this for newly generated UUIDs, not for