Use _PATH_URANDOM from paths(3).

This commit is contained in:
jruoho 2012-08-14 14:41:07 +00:00
parent ce0335d479
commit dd68a56f79
1 changed files with 10 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: rndctl.c,v 1.24 2012/02/02 19:42:57 tls Exp $ */
/* $NetBSD: rndctl.c,v 1.25 2012/08/14 14:41:07 jruoho Exp $ */
/*-
* Copyright (c) 1997 Michael Graff.
@ -33,7 +33,7 @@
#include <sha1.h>
#ifndef lint
__RCSID("$NetBSD: rndctl.c,v 1.24 2012/02/02 19:42:57 tls Exp $");
__RCSID("$NetBSD: rndctl.c,v 1.25 2012/08/14 14:41:07 jruoho Exp $");
#endif
@ -48,6 +48,7 @@ __RCSID("$NetBSD: rndctl.c,v 1.24 2012/02/02 19:42:57 tls Exp $");
#include <fcntl.h>
#include <errno.h>
#include <err.h>
#include <paths.h>
#include <string.h>
typedef struct {
@ -133,11 +134,11 @@ do_save(const char *const filename)
int fd;
fd = open("/dev/urandom", O_RDONLY, 0644);
fd = open(_PATH_URANDOM, O_RDONLY, 0644);
if (fd < 0) {
err(1, "device open");
}
if (ioctl(fd, RNDGETPOOLSTAT, &rp) < 0) {
err(1, "ioctl(RNDGETPOOLSTAT)");
}
@ -171,7 +172,7 @@ do_save(const char *const filename)
if (fd < 0) {
err(1, "output open");
}
if (write(fd, &rs, sizeof(rs)) != sizeof(rs)) {
unlink(filename);
fsync_range(fd, FDATASYNC|FDISKSYNC, (off_t)0, (off_t)0);
@ -221,7 +222,7 @@ do_load(const char *const filename)
rd.entropy = rs.entropy;
memcpy(rd.data, rs.data, MIN(sizeof(rd.data), sizeof(rs.data)));
fd = open("/dev/urandom", O_RDWR, 0644);
fd = open(_PATH_URANDOM, O_RDWR, 0644);
if (fd < 0) {
err(1, "device open");
}
@ -238,7 +239,7 @@ do_ioctl(rndctl_t *rctl)
int fd;
int res;
fd = open("/dev/urandom", O_RDONLY, 0644);
fd = open(_PATH_URANDOM, O_RDONLY, 0644);
if (fd < 0)
err(1, "open");
@ -283,7 +284,7 @@ do_list(int all, u_int32_t type, char *name)
uint32_t i;
u_int32_t start;
fd = open("/dev/urandom", O_RDONLY, 0644);
fd = open(_PATH_URANDOM, O_RDONLY, 0644);
if (fd < 0)
err(1, "open");
@ -339,7 +340,7 @@ do_stats(void)
rndpoolstat_t rs;
int fd;
fd = open("/dev/urandom", O_RDONLY, 0644);
fd = open(_PATH_URANDOM, O_RDONLY, 0644);
if (fd < 0)
err(1, "open");