From 876aa5390477c5333cb247d6f9e32c5ef429e16f Mon Sep 17 00:00:00 2001 From: markus Date: Tue, 18 Jun 2002 14:36:53 +0000 Subject: unbreak sshd with privsep: open /dev/crypto, keep fd, and call CRIOGET per EVP_Init(); ok niklas@, miod@ --- lib/libssl/src/crypto/engine/hw_cryptodev.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'lib/libssl/src') diff --git a/lib/libssl/src/crypto/engine/hw_cryptodev.c b/lib/libssl/src/crypto/engine/hw_cryptodev.c index 859af048ee5..b8217cdea1d 100644 --- a/lib/libssl/src/crypto/engine/hw_cryptodev.c +++ b/lib/libssl/src/crypto/engine/hw_cryptodev.c @@ -111,18 +111,33 @@ 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) { -- cgit v1.2.3-59-g8ed1b