aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/efreet
diff options
context:
space:
mode:
authorVincent Torri <vincent dot torri at gmail dot com>2015-09-29 23:34:23 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-10-12 17:21:59 -0700
commitc0be7c1a4359040f71390236370ab6c24a459550 (patch)
tree3a517602d08486ea9fa86a0f7a6c06427042cdd8 /src/bin/efreet
parentedje: use eina_environment_tmp_get() instead of the TMPDIR env variable (diff)
downloadefl-c0be7c1a4359040f71390236370ab6c24a459550.tar.gz
efreet: use eina_file_mkstemp() instead of mkstemp() for portability
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/bin/efreet')
-rw-r--r--src/bin/efreet/efreet_desktop_cache_create.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/bin/efreet/efreet_desktop_cache_create.c b/src/bin/efreet/efreet_desktop_cache_create.c
index 498daa41e5..4ab9fc6488 100644
--- a/src/bin/efreet/efreet_desktop_cache_create.c
+++ b/src/bin/efreet/efreet_desktop_cache_create.c
@@ -280,7 +280,7 @@ main(int argc, char **argv)
int i;
char file[PATH_MAX] = { '\0' };
char util_file[PATH_MAX] = { '\0' };
- mode_t um;
+ Eina_Tmpstr *tmpstr = NULL;
if (!eina_init()) goto eina_error;
_efreet_desktop_cache_log_dom =
@@ -351,24 +351,22 @@ main(int argc, char **argv)
}
/* create cache */
- snprintf(file, sizeof(file), "%s.XXXXXX", efreet_desktop_cache_file());
- /* set secure umask for temporary files */
- um = umask(0077);
- tmpfd = mkstemp(file);
- umask(um);
+ snprintf(file, sizeof(file), "%s.XXXXXX.cache", efreet_desktop_cache_file());
+ tmpfd = eina_file_mkstemp(file, &tmpstr);
if (tmpfd < 0) goto error;
close(tmpfd);
- ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
+ ef = eet_open(tmpstr, EET_FILE_MODE_READ_WRITE);
+ eina_tmpstr_del(tmpstr);
+ tmpstr = NULL;
if (!ef) goto error;
- 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);
+ snprintf(util_file, sizeof(util_file), "%s.XXXXXX.cache", efreet_desktop_util_cache_file());
+ tmpfd = eina_file_mkstemp(util_file, &tmpstr);
if (tmpfd < 0) goto error;
close(tmpfd);
util_ef = eet_open(util_file, EET_FILE_MODE_READ_WRITE);
+ eina_tmpstr_del(tmpstr);
+ tmpstr = NULL;
if (!util_ef) goto error;
/* write cache version */
@@ -524,6 +522,7 @@ main(int argc, char **argv)
close(lockfd);
return 0;
error:
+ eina_tmpstr_del(tmpstr);
if (stack) eina_inarray_free(stack);
IF_FREE(dir);
edd_error: