summaryrefslogtreecommitdiff
path: root/sys/arch/sparc64
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2020-05-25 15:49:43 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2020-05-25 15:49:43 +0000
commit5ce625e7c5642adeba16b429ba1752db1a5d7be7 (patch)
tree302bc073f2670faccebdbd94d62a18999450d60b /sys/arch/sparc64
parentbc8712ab4fd641aadc8101b3230acb05ff47cb86 (diff)
make loadrandom() return 0 for success, -1 for failure. While here,
relax the fstat() check because the system will have left the file in the right mode. ok visa kettenis
Diffstat (limited to 'sys/arch/sparc64')
-rw-r--r--sys/arch/sparc64/stand/ofwboot/boot.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/sys/arch/sparc64/stand/ofwboot/boot.c b/sys/arch/sparc64/stand/ofwboot/boot.c
index 839a2193ad6..8357c7652a5 100644
--- a/sys/arch/sparc64/stand/ofwboot/boot.c
+++ b/sys/arch/sparc64/stand/ofwboot/boot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: boot.c,v 1.33 2020/01/04 18:32:15 kettenis Exp $ */
+/* $OpenBSD: boot.c,v 1.34 2020/05/25 15:49:42 deraadt Exp $ */
/* $NetBSD: boot.c,v 1.3 2001/05/31 08:55:19 mrg Exp $ */
/*
* Copyright (c) 1997, 1999 Eduardo E. Horvath. All rights reserved.
@@ -285,24 +285,24 @@ int
loadrandom(char *path, char *buf, size_t buflen)
{
struct stat sb;
- int fd, i;
+ int fd, i, error = 0;
#define O_RDONLY 0
fd = open(path, O_RDONLY);
if (fd == -1)
return -1;
- if (fstat(fd, &sb) == -1 ||
- sb.st_uid != 0 ||
- (sb.st_mode & (S_IWOTH|S_IROTH)))
- goto fail;
- if (read(fd, buf, buflen) != buflen)
- goto fail;
- close(fd);
- return 0;
-fail:
+ if (fstat(fd, &sb) == -1) {
+ error = -1;
+ goto done;
+ }
+ if (read(fd, buf, buflen) != buflen) {
+ error = -1;
+ goto done;
+ }
+done:
close(fd);
- return (-1);
+ return (error);
}
#ifdef SOFTRAID
@@ -471,8 +471,8 @@ main(void)
_rtt();
}
}
- if (loadrandom(BOOTRANDOM, rnddata, sizeof(rnddata)))
- printf("open %s: %s\n", BOOTRANDOM, strerror(errno));
+ if (loadrandom(BOOTRANDOM, rnddata, sizeof(rnddata)) == 0)
+ boothowto |= RB_GOODRANDOM;
rc4_keysetup(&randomctx, rnddata, sizeof rnddata);
rc4_skip(&randomctx, 1536);