diff options
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -24,7 +24,7 @@ | |||
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include "includes.h" | 26 | #include "includes.h" |
27 | RCSID("$OpenBSD: misc.c,v 1.34 2005/07/08 09:26:18 dtucker Exp $"); | 27 | RCSID("$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 | ||
510 | void | ||
511 | sanitise_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 | |||
510 | char * | 530 | char * |
511 | tohex(const u_char *d, u_int l) | 531 | tohex(const u_char *d, u_int l) |
512 | { | 532 | { |