aboutsummaryrefslogtreecommitdiffstats
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
parentUpdate po files (diff)
downloadefl-7eebd55ebe32883cd59638fba3b76b21701615ca.tar.gz
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[])
{
char path[PATH_MAX];
FILE *log;
+ int fd;
mode_t um;
strcpy(path, "/tmp/efreetd_XXXXXX");
- um = umask(0077);
- if (mkstemp(path) < 0)
- {
- perror("mkstemp");
- umask(um);
- return 1;
- }
+ um = umask(S_IRWXG|S_IRWXO);
+ fd = mkstemp(path);
umask(um);
- if (chmod(path, 0700) < 0)
+ if (fd < 0)
{
- perror("chmod");
+ perror("mkstemp");
return 1;
}
- log = fopen(path, "wb");
+ log = fdopen(fd, "wb");
if (!log) return 1;
if (!eina_init()) return 1;