summaryrefslogtreecommitdiff
path: root/src/bin/efreet
diff options
context:
space:
mode:
authorSebastian Dransfeld <sebastian.dransfeld@sintef.no>2013-10-22 12:54:22 +0200
committerSebastian Dransfeld <sebastian.dransfeld@sintef.no>2013-10-22 12:54:22 +0200
commit7eebd55ebe32883cd59638fba3b76b21701615ca (patch)
tree81715135a21ed44045dda238b9909a65fa9c1048 /src/bin/efreet
parent1cd3449e23900663119f7a5ae3a69c7828faf55f (diff)
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
Diffstat (limited to 'src/bin/efreet')
-rw-r--r--src/bin/efreet/efreetd.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/bin/efreet/efreetd.c b/src/bin/efreet/efreetd.c
index 18fc500db1..2a61affab6 100644
--- a/src/bin/efreet/efreetd.c
+++ b/src/bin/efreet/efreetd.c
@@ -28,24 +28,20 @@ main(int argc, char *argv[])
28{ 28{
29 char path[PATH_MAX]; 29 char path[PATH_MAX];
30 FILE *log; 30 FILE *log;
31 int fd;
31 mode_t um; 32 mode_t um;
32 33
33 strcpy(path, "/tmp/efreetd_XXXXXX"); 34 strcpy(path, "/tmp/efreetd_XXXXXX");
34 um = umask(0077); 35 um = umask(S_IRWXG|S_IRWXO);
35 if (mkstemp(path) < 0) 36 fd = mkstemp(path);
36 {
37 perror("mkstemp");
38 umask(um);
39 return 1;
40 }
41 umask(um); 37 umask(um);
42 if (chmod(path, 0700) < 0) 38 if (fd < 0)
43 { 39 {
44 perror("chmod"); 40 perror("mkstemp");
45 return 1; 41 return 1;
46 } 42 }
47 43
48 log = fopen(path, "wb"); 44 log = fdopen(fd, "wb");
49 if (!log) return 1; 45 if (!log) return 1;
50 46
51 if (!eina_init()) return 1; 47 if (!eina_init()) return 1;