mktemp() -> mkstemp()
This commit is contained in:
parent
c9b0c57620
commit
b4f53dbf7c
|
@ -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
|
* Copyright (c) 1993,1995 Paul Kranenburg
|
||||||
|
@ -362,17 +362,11 @@ buildhints()
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpfile = concat(_PATH_LD_HINTS, ".XXXXXX", "");
|
tmpfile = concat(_PATH_LD_HINTS, ".XXXXXX", "");
|
||||||
if ((tmpfile = mktemp(tmpfile)) == NULL) {
|
if ((fd = mkstemp(tmpfile)) == -1) {
|
||||||
warn("%s", tmpfile);
|
warn("%s", tmpfile);
|
||||||
return -1;
|
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)) !=
|
if (write(fd, &hdr, sizeof(struct hints_header)) !=
|
||||||
sizeof(struct hints_header)) {
|
sizeof(struct hints_header)) {
|
||||||
warn("%s", _PATH_LD_HINTS);
|
warn("%s", _PATH_LD_HINTS);
|
||||||
|
@ -387,6 +381,10 @@ buildhints()
|
||||||
warn("%s", _PATH_LD_HINTS);
|
warn("%s", _PATH_LD_HINTS);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (fchmod(fd, 0444) == -1) {
|
||||||
|
warn("%s", _PATH_LD_HINTS);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (close(fd) != 0) {
|
if (close(fd) != 0) {
|
||||||
warn("%s", _PATH_LD_HINTS);
|
warn("%s", _PATH_LD_HINTS);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -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
|
* Copyright (c) 1993,1995 Paul Kranenburg
|
||||||
|
@ -362,17 +362,11 @@ buildhints()
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpfile = concat(_PATH_LD_HINTS, ".XXXXXX", "");
|
tmpfile = concat(_PATH_LD_HINTS, ".XXXXXX", "");
|
||||||
if ((tmpfile = mktemp(tmpfile)) == NULL) {
|
if ((fd = mkstemp(tmpfile)) == -1) {
|
||||||
warn("%s", tmpfile);
|
warn("%s", tmpfile);
|
||||||
return -1;
|
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)) !=
|
if (write(fd, &hdr, sizeof(struct hints_header)) !=
|
||||||
sizeof(struct hints_header)) {
|
sizeof(struct hints_header)) {
|
||||||
warn("%s", _PATH_LD_HINTS);
|
warn("%s", _PATH_LD_HINTS);
|
||||||
|
@ -387,6 +381,10 @@ buildhints()
|
||||||
warn("%s", _PATH_LD_HINTS);
|
warn("%s", _PATH_LD_HINTS);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (fchmod(fd, 0444) == -1) {
|
||||||
|
warn("%s", _PATH_LD_HINTS);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (close(fd) != 0) {
|
if (close(fd) != 0) {
|
||||||
warn("%s", _PATH_LD_HINTS);
|
warn("%s", _PATH_LD_HINTS);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue