diff options
author | markus <> | 2002-06-18 14:36:53 +0000 |
---|---|---|
committer | markus <> | 2002-06-18 14:36:53 +0000 |
commit | afa3750ba89b7b016ff076ba513472cbd392c24e (patch) | |
tree | 7f1b1c95359c41a617713a7b7fb07fcdbaf598ae /src | |
parent | 346e8e94df63fe8b64bfb3a62d0a89569fba9626 (diff) | |
download | openbsd-afa3750ba89b7b016ff076ba513472cbd392c24e.tar.gz openbsd-afa3750ba89b7b016ff076ba513472cbd392c24e.tar.bz2 openbsd-afa3750ba89b7b016ff076ba513472cbd392c24e.zip |
unbreak sshd with privsep: open /dev/crypto, keep fd, and call
CRIOGET per EVP_Init(); ok niklas@, miod@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/engine/hw_cryptodev.c | 25 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/engine/hw_cryptodev.c | 25 |
2 files changed, 40 insertions, 10 deletions
diff --git a/src/lib/libcrypto/engine/hw_cryptodev.c b/src/lib/libcrypto/engine/hw_cryptodev.c index 859af048ee..b8217cdea1 100644 --- a/src/lib/libcrypto/engine/hw_cryptodev.c +++ b/src/lib/libcrypto/engine/hw_cryptodev.c | |||
@@ -112,17 +112,32 @@ static struct { | |||
112 | * Return a fd if /dev/crypto seems usable, 0 otherwise. | 112 | * Return a fd if /dev/crypto seems usable, 0 otherwise. |
113 | */ | 113 | */ |
114 | static int | 114 | static int |
115 | open_dev_crypto() | ||
116 | { | ||
117 | static int fd = -1; | ||
118 | |||
119 | if (fd == -1) { | ||
120 | if (fd = open("/dev/crypto", O_RDWR, 0) == -1) | ||
121 | return (-1); | ||
122 | /* close on exec */ | ||
123 | if (fcntl(fd, F_SETFD, 1) == -1) { | ||
124 | close(fd); | ||
125 | fd = -1; | ||
126 | return (-1); | ||
127 | } | ||
128 | } | ||
129 | return (fd); | ||
130 | } | ||
131 | |||
132 | static int | ||
115 | get_dev_crypto() | 133 | get_dev_crypto() |
116 | { | 134 | { |
117 | int fd, retfd; | 135 | int fd, retfd; |
118 | 136 | ||
119 | if ((fd = open("/dev/crypto", O_RDWR, 0)) == -1) | 137 | if ((fd = open_dev_crypto()) == -1) |
120 | return (-1); | 138 | return (-1); |
121 | if (ioctl(fd, CRIOGET, &retfd) == -1) { | 139 | if (ioctl(fd, CRIOGET, &retfd) == -1) |
122 | close(fd); | ||
123 | return (-1); | 140 | return (-1); |
124 | } | ||
125 | close(fd); | ||
126 | 141 | ||
127 | /* close on exec */ | 142 | /* close on exec */ |
128 | if (fcntl(retfd, F_SETFD, 1) == -1) { | 143 | if (fcntl(retfd, F_SETFD, 1) == -1) { |
diff --git a/src/lib/libssl/src/crypto/engine/hw_cryptodev.c b/src/lib/libssl/src/crypto/engine/hw_cryptodev.c index 859af048ee..b8217cdea1 100644 --- a/src/lib/libssl/src/crypto/engine/hw_cryptodev.c +++ b/src/lib/libssl/src/crypto/engine/hw_cryptodev.c | |||
@@ -112,17 +112,32 @@ static struct { | |||
112 | * Return a fd if /dev/crypto seems usable, 0 otherwise. | 112 | * Return a fd if /dev/crypto seems usable, 0 otherwise. |
113 | */ | 113 | */ |
114 | static int | 114 | static int |
115 | open_dev_crypto() | ||
116 | { | ||
117 | static int fd = -1; | ||
118 | |||
119 | if (fd == -1) { | ||
120 | if (fd = open("/dev/crypto", O_RDWR, 0) == -1) | ||
121 | return (-1); | ||
122 | /* close on exec */ | ||
123 | if (fcntl(fd, F_SETFD, 1) == -1) { | ||
124 | close(fd); | ||
125 | fd = -1; | ||
126 | return (-1); | ||
127 | } | ||
128 | } | ||
129 | return (fd); | ||
130 | } | ||
131 | |||
132 | static int | ||
115 | get_dev_crypto() | 133 | get_dev_crypto() |
116 | { | 134 | { |
117 | int fd, retfd; | 135 | int fd, retfd; |
118 | 136 | ||
119 | if ((fd = open("/dev/crypto", O_RDWR, 0)) == -1) | 137 | if ((fd = open_dev_crypto()) == -1) |
120 | return (-1); | 138 | return (-1); |
121 | if (ioctl(fd, CRIOGET, &retfd) == -1) { | 139 | if (ioctl(fd, CRIOGET, &retfd) == -1) |
122 | close(fd); | ||
123 | return (-1); | 140 | return (-1); |
124 | } | ||
125 | close(fd); | ||
126 | 141 | ||
127 | /* close on exec */ | 142 | /* close on exec */ |
128 | if (fcntl(retfd, F_SETFD, 1) == -1) { | 143 | if (fcntl(retfd, F_SETFD, 1) == -1) { |