efreet: Fix file opening
- Store result from mkstemp so we don't leak file descriptor - No need to chmod, as we set correct umask before createing file - Use fdopen to open file from file descriptor, not from path
This commit is contained in:
parent
1cd3449e23
commit
7eebd55ebe
|
@ -28,24 +28,20 @@ main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
FILE *log;
|
FILE *log;
|
||||||
|
int fd;
|
||||||
mode_t um;
|
mode_t um;
|
||||||
|
|
||||||
strcpy(path, "/tmp/efreetd_XXXXXX");
|
strcpy(path, "/tmp/efreetd_XXXXXX");
|
||||||
um = umask(0077);
|
um = umask(S_IRWXG|S_IRWXO);
|
||||||
if (mkstemp(path) < 0)
|
fd = mkstemp(path);
|
||||||
|
umask(um);
|
||||||
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
perror("mkstemp");
|
perror("mkstemp");
|
||||||
umask(um);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
umask(um);
|
|
||||||
if (chmod(path, 0700) < 0)
|
|
||||||
{
|
|
||||||
perror("chmod");
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
log = fopen(path, "wb");
|
log = fdopen(fd, "wb");
|
||||||
if (!log) return 1;
|
if (!log) return 1;
|
||||||
|
|
||||||
if (!eina_init()) return 1;
|
if (!eina_init()) return 1;
|
||||||
|
|
Loading…
Reference in New Issue