diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2002-06-18 14:36:54 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2002-06-18 14:36:54 +0000 |
commit | 6988e5b9730596facdb54fe60f0e2d7c369043b7 (patch) | |
tree | 29edab9af37205f01c5b3c743a0810a33b49580b /lib/libcrypto/engine | |
parent | 92081a79ad800ef4ebc3362730d416ca84ebfc5e (diff) |
unbreak sshd with privsep: open /dev/crypto, keep fd, and call
CRIOGET per EVP_Init(); ok niklas@, miod@
Diffstat (limited to 'lib/libcrypto/engine')
-rw-r--r-- | lib/libcrypto/engine/hw_cryptodev.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/libcrypto/engine/hw_cryptodev.c b/lib/libcrypto/engine/hw_cryptodev.c index 859af048ee5..b8217cdea1d 100644 --- a/lib/libcrypto/engine/hw_cryptodev.c +++ b/lib/libcrypto/engine/hw_cryptodev.c @@ -112,17 +112,32 @@ static struct { * Return a fd if /dev/crypto seems usable, 0 otherwise. */ static int +open_dev_crypto() +{ + static int fd = -1; + + if (fd == -1) { + if (fd = open("/dev/crypto", O_RDWR, 0) == -1) + return (-1); + /* close on exec */ + if (fcntl(fd, F_SETFD, 1) == -1) { + close(fd); + fd = -1; + return (-1); + } + } + return (fd); +} + +static int get_dev_crypto() { int fd, retfd; - if ((fd = open("/dev/crypto", O_RDWR, 0)) == -1) + if ((fd = open_dev_crypto()) == -1) return (-1); - if (ioctl(fd, CRIOGET, &retfd) == -1) { - close(fd); + if (ioctl(fd, CRIOGET, &retfd) == -1) return (-1); - } - close(fd); /* close on exec */ if (fcntl(retfd, F_SETFD, 1) == -1) { |