Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/rndctl Use _PATH_URANDOM from paths(3).



details:   https://anonhg.NetBSD.org/src/rev/a6dd91ba8568
branches:  trunk
changeset: 780997:a6dd91ba8568
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Tue Aug 14 14:41:07 2012 +0000

description:
Use _PATH_URANDOM from paths(3).

diffstat:

 sbin/rndctl/rndctl.c |  19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diffs (85 lines):

diff -r d4c5d837ef47 -r a6dd91ba8568 sbin/rndctl/rndctl.c
--- a/sbin/rndctl/rndctl.c      Tue Aug 14 14:38:02 2012 +0000
+++ b/sbin/rndctl/rndctl.c      Tue Aug 14 14:41:07 2012 +0000
@@ -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 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <err.h>
+#include <paths.h>
 #include <string.h>
 
 typedef struct {
@@ -133,11 +134,11 @@
 
        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 @@
        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 @@
        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 @@
        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 @@
        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 @@
        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");
 



Home | Main Index | Thread Index | Old Index