Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/pci_virtio_rnd.c
Show All 37 Lines | |||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#ifndef WITHOUT_CAPSICUM | #ifndef WITHOUT_CAPSICUM | ||||
#include <sys/capsicum.h> | #include <sys/capsicum.h> | ||||
#endif | #endif | ||||
#include <sys/linker_set.h> | #include <sys/linker_set.h> | ||||
#include <sys/uio.h> | #include <sys/uio.h> | ||||
#ifndef WITHOUT_CAPSICUM | |||||
#include <capsicum_helpers.h> | |||||
#endif | |||||
#include <err.h> | #include <err.h> | ||||
#include <errno.h> | #include <errno.h> | ||||
#include <fcntl.h> | #include <fcntl.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#include <assert.h> | #include <assert.h> | ||||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | #endif | ||||
* Should always be able to open /dev/random. | * Should always be able to open /dev/random. | ||||
*/ | */ | ||||
fd = open("/dev/random", O_RDONLY | O_NONBLOCK); | fd = open("/dev/random", O_RDONLY | O_NONBLOCK); | ||||
assert(fd >= 0); | assert(fd >= 0); | ||||
#ifndef WITHOUT_CAPSICUM | #ifndef WITHOUT_CAPSICUM | ||||
cap_rights_init(&rights, CAP_READ); | cap_rights_init(&rights, CAP_READ); | ||||
if (cap_rights_limit(fd, &rights) == -1 && errno != ENOSYS) | if (caph_rights_limit(fd, &rights) == -1) | ||||
errx(EX_OSERR, "Unable to apply rights for sandbox"); | errx(EX_OSERR, "Unable to apply rights for sandbox"); | ||||
#endif | #endif | ||||
/* | /* | ||||
* Check that device is seeded and non-blocking. | * Check that device is seeded and non-blocking. | ||||
*/ | */ | ||||
len = read(fd, &v, sizeof(v)); | len = read(fd, &v, sizeof(v)); | ||||
if (len <= 0) { | if (len <= 0) { | ||||
Show All 37 Lines |