Set umask before mkstemp() for some versions of glibc
This commit is contained in:
parent
ee70057f76
commit
b6bd791e24
@ -73,6 +73,11 @@ _child_lock_init(void)
|
|||||||
{
|
{
|
||||||
char lock_file[] = "/tmp/tinyproxy.servers.lock.XXXXXX";
|
char lock_file[] = "/tmp/tinyproxy.servers.lock.XXXXXX";
|
||||||
|
|
||||||
|
/* Only allow u+rw bits. This may be required for some versions
|
||||||
|
* of glibc so that mkstemp() doesn't make us vulnerable.
|
||||||
|
*/
|
||||||
|
umask(0177);
|
||||||
|
|
||||||
lock_fd = mkstemp(lock_file);
|
lock_fd = mkstemp(lock_file);
|
||||||
unlink(lock_file);
|
unlink(lock_file);
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ makedaemon(void)
|
|||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
chdir("/");
|
chdir("/");
|
||||||
umask(077);
|
umask(0177);
|
||||||
|
|
||||||
#if NDEBUG
|
#if NDEBUG
|
||||||
/*
|
/*
|
||||||
|
@ -114,6 +114,11 @@ malloc_shared_memory(size_t size)
|
|||||||
|
|
||||||
strlcpy(buffer, shared_file, sizeof(buffer));
|
strlcpy(buffer, shared_file, sizeof(buffer));
|
||||||
|
|
||||||
|
/* Only allow u+rw bits. This may be required for some versions
|
||||||
|
* of glibc so that mkstemp() doesn't make us vulnerable.
|
||||||
|
*/
|
||||||
|
umask(0177);
|
||||||
|
|
||||||
if ((fd = mkstemp(buffer)) == -1)
|
if ((fd = mkstemp(buffer)) == -1)
|
||||||
return (void *)MAP_FAILED;
|
return (void *)MAP_FAILED;
|
||||||
unlink(buffer);
|
unlink(buffer);
|
||||||
|
@ -165,6 +165,11 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
#endif /* HAVE_SETRLIMIT */
|
#endif /* HAVE_SETRLIMIT */
|
||||||
|
|
||||||
|
/* Only allow u+rw bits. This may be required for some versions
|
||||||
|
* of glibc so that mkstemp() doesn't make us vulnerable.
|
||||||
|
*/
|
||||||
|
umask(0177);
|
||||||
|
|
||||||
/* Default configuration file location */
|
/* Default configuration file location */
|
||||||
config.config_file = DEFAULT_CONF_FILE;
|
config.config_file = DEFAULT_CONF_FILE;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user