summaryrefslogtreecommitdiff
path: root/AUTHORS
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2022-10-17 23:44:31 -0400
committerPaul Smith <psmith@gnu.org>2022-10-18 14:20:44 -0400
commit9f55e9fd13c82e67754ec219f4160fda9de32a2b (patch)
tree07c59eb1a93616f8a29d44bf75f82ba996247a4f /AUTHORS
parent7bb7bb4ba49967e71abf14d7d59036b9a0eddf93 (diff)
downloadmake-git-9f55e9fd13c82e67754ec219f4160fda9de32a2b.tar.gz
Rework temp file handling to avoid GNU libc warnings
Original patch provided by Paul Eggert <eggert@cs.ucla.edu>. GNU libc will generate a link-time warning if we use mktemp() even though we are using it safely (we only use it with mkfifo()). Avoid this and clean up some handling. First, check all calls related to temporary files and exit with a fatal error and a useful message if we can't obtain them. In some situations it might be possible to continue with reduced capability but it's not worth the effort. On POSIX systems we can create anonymous temp files using O_TMPFILE if it's supported, else if we're using the default location and we have dup(2), we can use standard tmpfile() and get an FD from it. If we need a named temp file and FILE* and we have mkstemp() we can use that, else if we have fdopen() we can get a temp FD and open it. If none of those are available all we can do is generate a temp name then open it with fopen() which is not secure. * src/makeint.h (get_tmpdir): Declare it for use elsewhere. * src/misc.c (get_tmpdir): Make it public not static. (get_tmptemplate): Simplify the implementation. (get_tmppath): Only define this if we have to have it to avoid warnings from GNU libc. (get_tmpfd): Generate fatal errors on error. (get_tmpfile): Ditto. Open files in "wb+" mode to match tmpfile(). Require a filename pointer (all callers want it). * src/os.h (os_anontmp): Implement for posixos.c as well. * src/posix.c (jobserver_setup): Don't use mktemp to avoid GNU libc errors. Instead construct the FIFO name based on the PID. (osync_setup): get_tmpfd() can't fail so don't check it. (os_anontmp): If the system supports O_TMPFILE use it. If not, and we want to create the temporary file in the default directory, we can use tmpfile() then use dup() to copy the file descriptor. * src/main.c (main): get_tmpfile() can't fail. * src/vmsjobs.c (child_execute_job): get_tmpfile() can't fail.
Diffstat (limited to 'AUTHORS')
0 files changed, 0 insertions, 0 deletions