Date: Sat, 8 Jan 2000 23:02:44 -0800 (PST) From: Kris Kennaway <kris@hub.freebsd.org> To: audit@freebsd.org Subject: Re: ldconfig and mkstemp Message-ID: <Pine.BSF.4.21.0001082301530.55612-200000@hub.freebsd.org> In-Reply-To: <Pine.BSF.4.21.0001082151540.33985-200000@hub.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On Sat, 8 Jan 2000, Kris Kennaway wrote:
> This patch removes the tempfile race in ldconfig..please review
Oops, forgot the fcmod..
Kris
[-- Attachment #2 --]
Index: ldconfig.c
===================================================================
RCS file: /home/ncvs/src/sbin/ldconfig/ldconfig.c,v
retrieving revision 1.30
diff -u -r1.30 ldconfig.c
--- ldconfig.c 1999/08/28 00:13:21 1.30
+++ ldconfig.c 2000/01/09 06:29:04
@@ -465,17 +465,13 @@
errx(1, "str_index(%d) != strtab_sz(%d)", str_index, strtab_sz);
}
- tmpfile = concat(hints_file, ".XXXXXX", "");
- if ((tmpfile = mktemp(tmpfile)) == NULL) {
- warn("%s", tmpfile);
- return -1;
- }
-
+ tmpfile = concat(hints_file, ".XXXXXXXXXX", "");
umask(0); /* Create with exact permissions */
- if ((fd = open(tmpfile, O_RDWR|O_CREAT|O_TRUNC, 0444)) == -1) {
- warn("%s", hints_file);
+ if ((fd = mkstemp(tmpfile)) == -1) {
+ warn("%s", tmpfile);
return -1;
}
+ fchmod(fd, 0444);
if (write(fd, &hdr, sizeof(struct hints_header)) !=
sizeof(struct hints_header)) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0001082301530.55612-200000>
