mirror of
https://github.com/troglobit/libite.git
synced 2026-10-02 13:52:51 +07:00
Handle missing O_TMPFILE gracefully and document tempfile() in README
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
@@ -39,7 +39,7 @@ STRIPINST := $(INSTALL) -s --strip-program=$(CROSS)strip -m 0755
|
||||
CFLAGS += -fPIC
|
||||
CFLAGS += -Os
|
||||
CPPFLAGS += -D_GNU_SOURCE
|
||||
CPPFLAGS += -W -Wall -Werror
|
||||
CPPFLAGS += -W -Wall
|
||||
ARFLAGS = crus
|
||||
MAKEFLAGS = --no-print-directory --silent
|
||||
|
||||
|
||||
@@ -74,6 +74,12 @@ Generic Functions
|
||||
Very simple `rsync()` to copy files files and directories
|
||||
recursively.
|
||||
|
||||
- `tempfile()`
|
||||
|
||||
Secure replacement for `tmpfile()`. Creates an invisible temporary
|
||||
file in `/tmp` that is removed when the returned %FILE pointer is
|
||||
closed.
|
||||
|
||||
|
||||
OpenBSD Functions
|
||||
-----------------
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user