Module Name: src Committed By: jruoho Date: Tue Aug 14 14:41:07 UTC 2012
Modified Files: src/sbin/rndctl: rndctl.c Log Message: Use _PATH_URANDOM from paths(3). To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sbin/rndctl/rndctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sbin/rndctl/rndctl.c diff -u src/sbin/rndctl/rndctl.c:1.24 src/sbin/rndctl/rndctl.c:1.25 --- src/sbin/rndctl/rndctl.c:1.24 Thu Feb 2 19:42:57 2012 +++ src/sbin/rndctl/rndctl.c Tue Aug 14 14:41:07 2012 @@ -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/0 #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 *n 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");