From: Carsten Haitzler (Rasterman) Date: Wed, 16 Oct 2013 04:38:40 +0000 (+0900) Subject: Revert "efreet: Use eina_file_mkstemp" X-Git-Tag: submit/devel/efl/20131029.075644~45 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ed0e8b8df1b751e0c9f46e5f2a3fdfa1364a8659;p=platform%2Fupstream%2Fefl.git 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. :) --- diff --git a/src/bin/efreet/efreet_desktop_cache_create.c b/src/bin/efreet/efreet_desktop_cache_create.c index fe67da1..2fc6e91 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) int lockfd = -1, tmpfd; int changed = 0; int i; - char path_name[PATH_MAX] = { '\0' }; - Eina_Tmpstr *file = NULL; - Eina_Tmpstr *util_file = NULL; + char file[PATH_MAX] = { '\0' }; + char util_file[PATH_MAX] = { '\0' }; + mode_t um; if (!eina_init()) goto eina_error; _efreet_desktop_cache_log_dom = @@ -273,11 +273,11 @@ main(int argc, char **argv) if (!efreet_init()) goto efreet_error; /* create homedir */ - snprintf(path_name, sizeof(path_name), "%s/efreet", efreet_cache_home_get()); - if (!ecore_file_exists(path_name)) + snprintf(file, sizeof(file), "%s/efreet", efreet_cache_home_get()); + if (!ecore_file_exists(file)) { - if (!ecore_file_mkpath(path_name)) goto efreet_error; - efreet_setowner(path_name); + if (!ecore_file_mkpath(file)) goto efreet_error; + efreet_setowner(file); } /* lock process, so that we only run one copy of this program */ @@ -296,13 +296,21 @@ main(int argc, char **argv) } /* create cache */ - tmpfd = eina_file_mkstemp("efreet_desktop_cache_XXXXXX", &file); + snprintf(file, sizeof(file), "%s.XXXXXX", efreet_desktop_cache_file()); + /* set secure umask for temporary files */ + um = umask(0077); + tmpfd = mkstemp(file); + umask(um); if (tmpfd < 0) goto error; close(tmpfd); ef = eet_open(file, EET_FILE_MODE_READ_WRITE); if (!ef) goto error; - tmpfd = eina_file_mkstemp("efreet_desktop_util_cache_XXXXXX", &util_file); + snprintf(util_file, sizeof(util_file), "%s.XXXXXX", efreet_desktop_util_cache_file()); + /* set secure umask for temporary files */ + um = umask(0077); + tmpfd = mkstemp(util_file); + umask(um); if (tmpfd < 0) goto error; close(tmpfd); util_ef = eet_open(util_file, EET_FILE_MODE_READ_WRITE); @@ -442,8 +450,6 @@ main(int argc, char **argv) printf("%c\n", c); } - eina_tmpstr_del(file); - eina_tmpstr_del(util_file); EINA_LIST_FREE(systemdirs, dir) eina_stringshare_del(dir); eina_list_free(extra_dirs); @@ -455,8 +461,6 @@ main(int argc, char **argv) close(lockfd); return 0; error: - eina_tmpstr_del(file); - eina_tmpstr_del(util_file); IF_FREE(dir); edd_error: if (old_file_ids) diff --git a/src/bin/efreet/efreetd.c b/src/bin/efreet/efreetd.c index 414bb2c..18fc500 100644 --- a/src/bin/efreet/efreetd.c +++ b/src/bin/efreet/efreetd.c @@ -26,22 +26,29 @@ quit(void) int main(int argc, char *argv[]) { + char path[PATH_MAX]; FILE *log; - int fd; + mode_t um; - if (!eina_init()) return 1; - - fd = eina_file_mkstemp("efreetd_XXXXXX", NULL); - if (fd < 0) + strcpy(path, "/tmp/efreetd_XXXXXX"); + um = umask(0077); + if (mkstemp(path) < 0) { - EINA_LOG_ERR("mkstemp"); - goto eina_error; + perror("mkstemp"); + umask(um); + return 1; + } + umask(um); + if (chmod(path, 0700) < 0) + { + perror("chmod"); + return 1; } - log = fdopen(fd, "wb"); - if (!log) - goto eina_error; + log = fopen(path, "wb"); + if (!log) return 1; + if (!eina_init()) return 1; eina_log_print_cb_set(eina_log_print_cb_file, log); efreetd_log_dom = eina_log_domain_register("efreetd", EFREETD_DEFAULT_LOG_COLOR); @@ -84,7 +91,6 @@ ecore_error: if (efreetd_log_dom >= 0) eina_log_domain_unregister(efreetd_log_dom); efreetd_log_dom = -1; -eina_error: eina_shutdown(); return 1; }