summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormarkus <>2002-06-18 14:36:53 +0000
committermarkus <>2002-06-18 14:36:53 +0000
commitafa3750ba89b7b016ff076ba513472cbd392c24e (patch)
tree7f1b1c95359c41a617713a7b7fb07fcdbaf598ae /src
parent346e8e94df63fe8b64bfb3a62d0a89569fba9626 (diff)
downloadopenbsd-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.c25
-rw-r--r--src/lib/libssl/src/crypto/engine/hw_cryptodev.c25
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 */
114static int 114static int
115open_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
132static int
115get_dev_crypto() 133get_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 */
114static int 114static int
115open_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
132static int
115get_dev_crypto() 133get_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) {