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];
|
||||
FILE *log;
|
||||
int fd;
|
||||
mode_t um;
|
||||
|
||||
strcpy(path, "/tmp/efreetd_XXXXXX");
|
||||
um = umask(0077);
|
||||
if (mkstemp(path) < 0)
|
||||
um = umask(S_IRWXG|S_IRWXO);
|
||||
fd = mkstemp(path);
|
||||
umask(um);
|
||||
if (fd < 0)
|
||||
{
|
||||
perror("mkstemp");
|
||||
umask(um);
|
||||
return 1;
|
||||
}
|
||||
umask(um);
|
||||
if (chmod(path, 0700) < 0)
|
||||
{
|
||||
perror("chmod");
|
||||
return 1;
|
||||
}
|
||||
|
||||
log = fopen(path, "wb");
|
||||
log = fdopen(fd, "wb");
|
||||
if (!log) return 1;
|
||||
|
||||
if (!eina_init()) return 1;
|
||||
|
|
Loading…
Reference in New Issue