#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include "log.h"
#include "util.h"
int make_tempfile(const std::string &contents)
{
char filename[] = "/tmp/cubemap.XXXXXX";
+ mode_t old_umask = umask(0600);
int fd = mkstemp(filename);
+ umask(old_umask);
if (fd == -1) {
log_perror("mkstemp");
return -1;
ssize_t ret = write(fd, ptr, to_write);
if (ret == -1) {
log_perror("write");
- close(fd);
+ if (close(fd) == -1) {
+ log_perror("close");
+ }
return -1;
}