summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
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{