summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hostfile.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/hostfile.c b/hostfile.c
index 9de1b383b..ea6bc6fc8 100644
--- a/hostfile.c
+++ b/hostfile.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: hostfile.c,v 1.62 2015/01/26 03:04:45 djm Exp $ */ 1/* $OpenBSD: hostfile.c,v 1.63 2015/01/26 13:36:53 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -551,6 +551,8 @@ hostfile_replace_entries(const char *filename, const char *host,
551 mode_t omask; 551 mode_t omask;
552 size_t i; 552 size_t i;
553 553
554 omask = umask(077);
555
554 memset(&ctx, 0, sizeof(ctx)); 556 memset(&ctx, 0, sizeof(ctx));
555 ctx.host = host; 557 ctx.host = host;
556 ctx.quiet = quiet; 558 ctx.quiet = quiet;
@@ -568,7 +570,6 @@ hostfile_replace_entries(const char *filename, const char *host,
568 goto fail; 570 goto fail;
569 } 571 }
570 572
571 omask = umask(077);
572 if ((fd = mkstemp(temp)) == -1) { 573 if ((fd = mkstemp(temp)) == -1) {
573 oerrno = errno; 574 oerrno = errno;
574 error("%s: mkstemp: %s", __func__, strerror(oerrno)); 575 error("%s: mkstemp: %s", __func__, strerror(oerrno));
@@ -636,6 +637,7 @@ hostfile_replace_entries(const char *filename, const char *host,
636 if (ctx.out != NULL) 637 if (ctx.out != NULL)
637 fclose(ctx.out); 638 fclose(ctx.out);
638 free(ctx.skip_keys); 639 free(ctx.skip_keys);
640 umask(omask);
639 if (r == SSH_ERR_SYSTEM_ERROR) 641 if (r == SSH_ERR_SYSTEM_ERROR)
640 errno = oerrno; 642 errno = oerrno;
641 return r; 643 return r;