mirror of
https://github.com/troglobit/finit.git
synced 2026-10-28 12:30:44 +00:00
Upgrde to libite version with new tempfile()
The tempfile() replacement in Finit leaked temporary files in /tmp. The mkstemp() based implementation does not remove temporary files when they are closed. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
f1807a32ca
commit
e595e9da5f
3 files changed
+1
-26
No files matched your search
@@ -126,30 +126,6 @@ int atonum(char *str)
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* tempfile - A secure tmpfile() replacement
|
|
||||||
*
|
|
||||||
* This is the secure replacement for tmpfile() that does not exist in GLIBC.
|
|
||||||
* The function uses mkstemp() for security.
|
|
||||||
*
|
|
||||||
* Returns:
|
|
||||||
* An open %FILE pointer, or %NULL on error.
|
|
||||||
*/
|
|
||||||
FILE *tempfile(void)
|
|
||||||
{
|
|
||||||
int fd;
|
|
||||||
mode_t oldmask;
|
|
||||||
char template[] = "/tmp/finit.XXXXXX";
|
|
||||||
|
|
||||||
oldmask = umask(0077);
|
|
||||||
fd = mkstemp(template);
|
|
||||||
umask(oldmask);
|
|
||||||
if (-1 == fd)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return fdopen(fd, "rw");
|
|
||||||
}
|
|
||||||
|
|
||||||
static int encode(int lvl)
|
static int encode(int lvl)
|
||||||
{
|
{
|
||||||
if (!lvl) return 0;
|
if (!lvl) return 0;
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ int makepath (char *path);
|
|||||||
void ifconfig (char *ifname, char *addr, char *mask, int up);
|
void ifconfig (char *ifname, char *addr, char *mask, int up);
|
||||||
|
|
||||||
int atonum (char *str);
|
int atonum (char *str);
|
||||||
FILE *tempfile (void);
|
|
||||||
|
|
||||||
void runlevel_set (int pre, int now);
|
void runlevel_set (int pre, int now);
|
||||||
int runlevel_get (void);
|
int runlevel_get (void);
|
||||||
|
|||||||
+1
-1
Submodule libite updated: 84c3667eba...c5434a4bc0.
Reference in new issue
Block a user