summaryrefslogtreecommitdiff
path: root/src/bin/efreet
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-10-16 13:38:40 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-10-16 22:56:38 +0900
commited0e8b8df1b751e0c9f46e5f2a3fdfa1364a8659 (patch)
tree224cdf61ee97c6010e3f9e1426a9f1bf685e2123 /src/bin/efreet
parent6be9cc74dea4b9f377ce070128becfe6f30e04ce (diff)
Revert "efreet: Use eina_file_mkstemp"
This reverts commit bd5a5e7fce3931476bbc68a156be28e58f5d7ef8. sorry about this... all fine eina mkstemp use and all... but this *BREAKS EFREET*! ibar icons stop working (vanish). efreet no longer issues a desktop file update event to e etc. etc. etc. ... so let's keep code that works for now even if it uses mkstemp and not eina... :) working is better. :)
Diffstat (limited to 'src/bin/efreet')
-rw-r--r--src/bin/efreet/efreet_desktop_cache_create.c30
-rw-r--r--src/bin/efreet/efreetd.c28
2 files changed, 34 insertions, 24 deletions
diff --git a/src/bin/efreet/efreet_desktop_cache_create.c b/src/bin/efreet/efreet_desktop_cache_create.c
index fe67da1fb4..2fc6e917d7 100644
--- a/src/bin/efreet/efreet_desktop_cache_create.c
+++ b/src/bin/efreet/efreet_desktop_cache_create.c
@@ -223,9 +223,9 @@ main(int argc, char **argv)
223 int lockfd = -1, tmpfd; 223 int lockfd = -1, tmpfd;
224 int changed = 0; 224 int changed = 0;
225 int i; 225 int i;
226 char path_name[PATH_MAX] = { '\0' }; 226 char file[PATH_MAX] = { '\0' };
227 Eina_Tmpstr *file = NULL; 227 char util_file[PATH_MAX] = { '\0' };
228 Eina_Tmpstr *util_file = NULL; 228 mode_t um;
229 229
230 if (!eina_init()) goto eina_error; 230 if (!eina_init()) goto eina_error;
231 _efreet_desktop_cache_log_dom = 231 _efreet_desktop_cache_log_dom =
@@ -273,11 +273,11 @@ main(int argc, char **argv)
273 if (!efreet_init()) goto efreet_error; 273 if (!efreet_init()) goto efreet_error;
274 274
275 /* create homedir */ 275 /* create homedir */
276 snprintf(path_name, sizeof(path_name), "%s/efreet", efreet_cache_home_get()); 276 snprintf(file, sizeof(file), "%s/efreet", efreet_cache_home_get());
277 if (!ecore_file_exists(path_name)) 277 if (!ecore_file_exists(file))
278 { 278 {
279 if (!ecore_file_mkpath(path_name)) goto efreet_error; 279 if (!ecore_file_mkpath(file)) goto efreet_error;
280 efreet_setowner(path_name); 280 efreet_setowner(file);
281 } 281 }
282 282
283 /* lock process, so that we only run one copy of this program */ 283 /* lock process, so that we only run one copy of this program */
@@ -296,13 +296,21 @@ main(int argc, char **argv)
296 } 296 }
297 297
298 /* create cache */ 298 /* create cache */
299 tmpfd = eina_file_mkstemp("efreet_desktop_cache_XXXXXX", &file); 299 snprintf(file, sizeof(file), "%s.XXXXXX", efreet_desktop_cache_file());
300 /* set secure umask for temporary files */
301 um = umask(0077);
302 tmpfd = mkstemp(file);
303 umask(um);
300 if (tmpfd < 0) goto error; 304 if (tmpfd < 0) goto error;
301 close(tmpfd); 305 close(tmpfd);
302 ef = eet_open(file, EET_FILE_MODE_READ_WRITE); 306 ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
303 if (!ef) goto error; 307 if (!ef) goto error;
304 308
305 tmpfd = eina_file_mkstemp("efreet_desktop_util_cache_XXXXXX", &util_file); 309 snprintf(util_file, sizeof(util_file), "%s.XXXXXX", efreet_desktop_util_cache_file());
310 /* set secure umask for temporary files */
311 um = umask(0077);
312 tmpfd = mkstemp(util_file);
313 umask(um);
306 if (tmpfd < 0) goto error; 314 if (tmpfd < 0) goto error;
307 close(tmpfd); 315 close(tmpfd);
308 util_ef = eet_open(util_file, EET_FILE_MODE_READ_WRITE); 316 util_ef = eet_open(util_file, EET_FILE_MODE_READ_WRITE);
@@ -442,8 +450,6 @@ main(int argc, char **argv)
442 printf("%c\n", c); 450 printf("%c\n", c);
443 } 451 }
444 452
445 eina_tmpstr_del(file);
446 eina_tmpstr_del(util_file);
447 EINA_LIST_FREE(systemdirs, dir) 453 EINA_LIST_FREE(systemdirs, dir)
448 eina_stringshare_del(dir); 454 eina_stringshare_del(dir);
449 eina_list_free(extra_dirs); 455 eina_list_free(extra_dirs);
@@ -455,8 +461,6 @@ main(int argc, char **argv)
455 close(lockfd); 461 close(lockfd);
456 return 0; 462 return 0;
457error: 463error:
458 eina_tmpstr_del(file);
459 eina_tmpstr_del(util_file);
460 IF_FREE(dir); 464 IF_FREE(dir);
461edd_error: 465edd_error:
462 if (old_file_ids) 466 if (old_file_ids)
diff --git a/src/bin/efreet/efreetd.c b/src/bin/efreet/efreetd.c
index 414bb2cbf4..18fc500db1 100644
--- a/src/bin/efreet/efreetd.c
+++ b/src/bin/efreet/efreetd.c
@@ -26,22 +26,29 @@ quit(void)
26int 26int
27main(int argc, char *argv[]) 27main(int argc, char *argv[])
28{ 28{
29 char path[PATH_MAX];
29 FILE *log; 30 FILE *log;
30 int fd; 31 mode_t um;
31 32
32 if (!eina_init()) return 1; 33 strcpy(path, "/tmp/efreetd_XXXXXX");
33 34 um = umask(0077);
34 fd = eina_file_mkstemp("efreetd_XXXXXX", NULL); 35 if (mkstemp(path) < 0)
35 if (fd < 0)
36 { 36 {
37 EINA_LOG_ERR("mkstemp"); 37 perror("mkstemp");
38 goto eina_error; 38 umask(um);
39 return 1;
40 }
41 umask(um);
42 if (chmod(path, 0700) < 0)
43 {
44 perror("chmod");
45 return 1;
39 } 46 }
40 47
41 log = fdopen(fd, "wb"); 48 log = fopen(path, "wb");
42 if (!log) 49 if (!log) return 1;
43 goto eina_error;
44 50
51 if (!eina_init()) return 1;
45 eina_log_print_cb_set(eina_log_print_cb_file, log); 52 eina_log_print_cb_set(eina_log_print_cb_file, log);
46 53
47 efreetd_log_dom = eina_log_domain_register("efreetd", EFREETD_DEFAULT_LOG_COLOR); 54 efreetd_log_dom = eina_log_domain_register("efreetd", EFREETD_DEFAULT_LOG_COLOR);
@@ -84,7 +91,6 @@ ecore_error:
84 if (efreetd_log_dom >= 0) 91 if (efreetd_log_dom >= 0)
85 eina_log_domain_unregister(efreetd_log_dom); 92 eina_log_domain_unregister(efreetd_log_dom);
86 efreetd_log_dom = -1; 93 efreetd_log_dom = -1;
87eina_error:
88 eina_shutdown(); 94 eina_shutdown();
89 return 1; 95 return 1;
90} 96}