summaryrefslogtreecommitdiffstats
path: root/usr.bin/ssh/ssh-keysign.c
diff options
context:
space:
mode:
authordjm <djm@openbsd.org>2005-09-13 23:40:07 +0000
committerdjm <djm@openbsd.org>2005-09-13 23:40:07 +0000
commit399d21a6cfe67883be6695b6e094d8fa8afa845e (patch)
tree9659a3b415cc9cd4d5df3df311dad5e9bea6b656 /usr.bin/ssh/ssh-keysign.c
parentmore Package/FatPackage common code: separate the proxy 'next' into two (diff)
downloadwireguard-openbsd-399d21a6cfe67883be6695b6e094d8fa8afa845e.tar.xz
wireguard-openbsd-399d21a6cfe67883be6695b6e094d8fa8afa845e.zip
ensure that stdio fds are attached; ok deraadt@
Diffstat (limited to 'usr.bin/ssh/ssh-keysign.c')
-rw-r--r--usr.bin/ssh/ssh-keysign.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/usr.bin/ssh/ssh-keysign.c b/usr.bin/ssh/ssh-keysign.c
index e3e4c33ada7..d26ec1e4fb6 100644
--- a/usr.bin/ssh/ssh-keysign.c
+++ b/usr.bin/ssh/ssh-keysign.c
@@ -22,7 +22,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "includes.h"
-RCSID("$OpenBSD: ssh-keysign.c,v 1.18 2004/08/23 14:29:23 dtucker Exp $");
+RCSID("$OpenBSD: ssh-keysign.c,v 1.19 2005/09/13 23:40:07 djm Exp $");
#include <openssl/evp.h>
#include <openssl/rand.h>
@@ -146,6 +146,13 @@ main(int argc, char **argv)
u_int slen, dlen;
u_int32_t rnd[256];
+ /* Ensure that stdin and stdout are connected */
+ if ((fd = open(_PATH_DEVNULL, O_RDWR)) < 2)
+ exit(1);
+ /* Leave /dev/null fd iff it is attached to stderr */
+ if (fd > 2)
+ close(fd);
+
key_fd[0] = open(_PATH_HOST_RSA_KEY_FILE, O_RDONLY);
key_fd[1] = open(_PATH_HOST_DSA_KEY_FILE, O_RDONLY);