summaryrefslogtreecommitdiff
path: root/src/bin/efreet/efreet_desktop_cache_create.c
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/efreet_desktop_cache_create.c
parent0d4942f4e563859c4e97b73f03585e9ef96f5ddc (diff)
efreet: use eina_file_mkstemp() instead of mkstemp() for portability
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to '')
-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)
280 int i; 280 int i;
281 char file[PATH_MAX] = { '\0' }; 281 char file[PATH_MAX] = { '\0' };
282 char util_file[PATH_MAX] = { '\0' }; 282 char util_file[PATH_MAX] = { '\0' };
283 mode_t um; 283 Eina_Tmpstr *tmpstr = NULL;
284 284
285 if (!eina_init()) goto eina_error; 285 if (!eina_init()) goto eina_error;
286 _efreet_desktop_cache_log_dom = 286 _efreet_desktop_cache_log_dom =
@@ -351,24 +351,22 @@ main(int argc, char **argv)
351 } 351 }
352 352
353 /* create cache */ 353 /* create cache */
354 snprintf(file, sizeof(file), "%s.XXXXXX", efreet_desktop_cache_file()); 354 snprintf(file, sizeof(file), "%s.XXXXXX.cache", efreet_desktop_cache_file());
355 /* set secure umask for temporary files */ 355 tmpfd = eina_file_mkstemp(file, &tmpstr);
356 um = umask(0077);
357 tmpfd = mkstemp(file);
358 umask(um);
359 if (tmpfd < 0) goto error; 356 if (tmpfd < 0) goto error;
360 close(tmpfd); 357 close(tmpfd);
361 ef = eet_open(file, EET_FILE_MODE_READ_WRITE); 358 ef = eet_open(tmpstr, EET_FILE_MODE_READ_WRITE);
359 eina_tmpstr_del(tmpstr);
360 tmpstr = NULL;
362 if (!ef) goto error; 361 if (!ef) goto error;
363 362
364 snprintf(util_file, sizeof(util_file), "%s.XXXXXX", efreet_desktop_util_cache_file()); 363 snprintf(util_file, sizeof(util_file), "%s.XXXXXX.cache", efreet_desktop_util_cache_file());
365 /* set secure umask for temporary files */ 364 tmpfd = eina_file_mkstemp(util_file, &tmpstr);
366 um = umask(0077);
367 tmpfd = mkstemp(util_file);
368 umask(um);
369 if (tmpfd < 0) goto error; 365 if (tmpfd < 0) goto error;
370 close(tmpfd); 366 close(tmpfd);
371 util_ef = eet_open(util_file, EET_FILE_MODE_READ_WRITE); 367 util_ef = eet_open(util_file, EET_FILE_MODE_READ_WRITE);
368 eina_tmpstr_del(tmpstr);
369 tmpstr = NULL;
372 if (!util_ef) goto error; 370 if (!util_ef) goto error;
373 371
374 /* write cache version */ 372 /* write cache version */
@@ -524,6 +522,7 @@ main(int argc, char **argv)
524 close(lockfd); 522 close(lockfd);
525 return 0; 523 return 0;
526error: 524error:
525 eina_tmpstr_del(tmpstr);
527 if (stack) eina_inarray_free(stack); 526 if (stack) eina_inarray_free(stack);
528 IF_FREE(dir); 527 IF_FREE(dir);
529edd_error: 528edd_error: