From b4f53dbf7ce6450c548743ed496e3e7269b83ef8 Mon Sep 17 00:00:00 2001 From: christos Date: Wed, 16 Apr 1997 16:46:28 +0000 Subject: [PATCH] mktemp() -> mkstemp() --- gnu/usr.bin/ld/ldconfig/ldconfig.c | 14 ++++++-------- sbin/ldconfig/ldconfig.c | 14 ++++++-------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/gnu/usr.bin/ld/ldconfig/ldconfig.c b/gnu/usr.bin/ld/ldconfig/ldconfig.c index 51d2ebc512cc..203e19b8c0f8 100644 --- a/gnu/usr.bin/ld/ldconfig/ldconfig.c +++ b/gnu/usr.bin/ld/ldconfig/ldconfig.c @@ -1,4 +1,4 @@ -/* $NetBSD: ldconfig.c,v 1.16 1997/01/03 07:10:52 mikel Exp $ */ +/* $NetBSD: ldconfig.c,v 1.17 1997/04/16 16:46:28 christos Exp $ */ /* * Copyright (c) 1993,1995 Paul Kranenburg @@ -362,17 +362,11 @@ buildhints() } tmpfile = concat(_PATH_LD_HINTS, ".XXXXXX", ""); - if ((tmpfile = mktemp(tmpfile)) == NULL) { + if ((fd = mkstemp(tmpfile)) == -1) { warn("%s", tmpfile); return -1; } - umask(0); /* Create with exact permissions */ - if ((fd = open(tmpfile, O_RDWR|O_CREAT|O_TRUNC, 0444)) == -1) { - warn("%s", _PATH_LD_HINTS); - return -1; - } - if (write(fd, &hdr, sizeof(struct hints_header)) != sizeof(struct hints_header)) { warn("%s", _PATH_LD_HINTS); @@ -387,6 +381,10 @@ buildhints() warn("%s", _PATH_LD_HINTS); return -1; } + if (fchmod(fd, 0444) == -1) { + warn("%s", _PATH_LD_HINTS); + return -1; + } if (close(fd) != 0) { warn("%s", _PATH_LD_HINTS); return -1; diff --git a/sbin/ldconfig/ldconfig.c b/sbin/ldconfig/ldconfig.c index 51d2ebc512cc..203e19b8c0f8 100644 --- a/sbin/ldconfig/ldconfig.c +++ b/sbin/ldconfig/ldconfig.c @@ -1,4 +1,4 @@ -/* $NetBSD: ldconfig.c,v 1.16 1997/01/03 07:10:52 mikel Exp $ */ +/* $NetBSD: ldconfig.c,v 1.17 1997/04/16 16:46:28 christos Exp $ */ /* * Copyright (c) 1993,1995 Paul Kranenburg @@ -362,17 +362,11 @@ buildhints() } tmpfile = concat(_PATH_LD_HINTS, ".XXXXXX", ""); - if ((tmpfile = mktemp(tmpfile)) == NULL) { + if ((fd = mkstemp(tmpfile)) == -1) { warn("%s", tmpfile); return -1; } - umask(0); /* Create with exact permissions */ - if ((fd = open(tmpfile, O_RDWR|O_CREAT|O_TRUNC, 0444)) == -1) { - warn("%s", _PATH_LD_HINTS); - return -1; - } - if (write(fd, &hdr, sizeof(struct hints_header)) != sizeof(struct hints_header)) { warn("%s", _PATH_LD_HINTS); @@ -387,6 +381,10 @@ buildhints() warn("%s", _PATH_LD_HINTS); return -1; } + if (fchmod(fd, 0444) == -1) { + warn("%s", _PATH_LD_HINTS); + return -1; + } if (close(fd) != 0) { warn("%s", _PATH_LD_HINTS); return -1;