Handle missing O_TMPFILE gracefully and document tempfile() in README

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2015-06-22 22:02:39 +02:00
parent c5434a4bc0
commit 35b43c5c56
3 changed files with 14 additions and 1 deletions
+7
View File
@@ -21,6 +21,11 @@
#include <stdio.h> /* fdopen() */
#include <sys/stat.h> /* umask() */
#ifndef O_TMPFILE /* Too old GLIBC or kernel */
#warning O_TMPFILE missing on your system, tempfile() may not work!
#define O_TMPFILE 020200000 /* Define and let it fail at runtime */
#endif
/**
* tempfile - A secure tmpfile() replacement
*
@@ -29,6 +34,8 @@
* for security. When the %FILE is fclose()'ed the file contents is
* lost. The file is hidden in the %_PATH_TMP directory on the system.
*
* This function requires Linux 3.11, or later, due to %O_TMPFILE.
*
* Returns:
* An open %FILE pointer, or %NULL on error.
*/