summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2005-10-03 18:11:24 +1000
committerDarren Tucker <dtucker@zip.com.au>2005-10-03 18:11:24 +1000
commitce321d8a30a81222d11a4c27fd353804a9afecd3 (patch)
tree9b43bd892b03286fbbda2f032fe16a0f6cf9bb74 /misc.c
parentd89dbf29ff288ac8ba1755d15f63d2bd58dcb71b (diff)
- djm@cvs.openbsd.org 2005/09/13 23:40:07
[sshd.c ssh.c misc.h sftp.c ssh-keygen.c ssh-keysign.c sftp-server.c scp.c misc.c ssh-keyscan.c ssh-add.c ssh-agent.c] ensure that stdio fds are attached; ok deraadt@
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/misc.c b/misc.c
index 2dd8ae6e3..27b947f0c 100644
--- a/misc.c
+++ b/misc.c
@@ -24,7 +24,7 @@
24 */ 24 */
25 25
26#include "includes.h" 26#include "includes.h"
27RCSID("$OpenBSD: misc.c,v 1.34 2005/07/08 09:26:18 dtucker Exp $"); 27RCSID("$OpenBSD: misc.c,v 1.35 2005/09/13 23:40:07 djm Exp $");
28 28
29#include "misc.h" 29#include "misc.h"
30#include "log.h" 30#include "log.h"
@@ -507,6 +507,26 @@ read_keyfile_line(FILE *f, const char *filename, char *buf, size_t bufsz,
507 return -1; 507 return -1;
508} 508}
509 509
510void
511sanitise_stdfd(void)
512{
513 int nullfd;
514
515 if ((nullfd = open(_PATH_DEVNULL, O_RDWR)) == -1) {
516 fprintf(stderr, "Couldn't open /dev/null: %s", strerror(errno));
517 exit(1);
518 }
519 while (nullfd < 2) {
520 if (dup2(nullfd, nullfd + 1) == -1) {
521 fprintf(stderr, "dup2: %s", strerror(errno));
522 exit(1);
523 }
524 nullfd++;
525 }
526 if (nullfd > 2)
527 close(nullfd);
528}
529
510char * 530char *
511tohex(const u_char *d, u_int l) 531tohex(const u_char *d, u_int l)
512{ 532{