int lockfd = -1, tmpfd;
int changed = 0;
int i;
- char file[PATH_MAX] = { '\0' };
- char util_file[PATH_MAX] = { '\0' };
- mode_t um;
+ char path_name[PATH_MAX] = { '\0' };
+ Eina_Tmpstr *file = NULL;
+ Eina_Tmpstr *util_file = NULL;
if (!eina_init()) goto eina_error;
_efreet_desktop_cache_log_dom =
if (!efreet_init()) goto efreet_error;
/* create homedir */
- snprintf(file, sizeof(file), "%s/efreet", efreet_cache_home_get());
- if (!ecore_file_exists(file))
+ snprintf(path_name, sizeof(path_name), "%s/efreet", efreet_cache_home_get());
+ if (!ecore_file_exists(path_name))
{
- if (!ecore_file_mkpath(file)) goto efreet_error;
- efreet_setowner(file);
+ if (!ecore_file_mkpath(path_name)) goto efreet_error;
+ efreet_setowner(path_name);
}
/* lock process, so that we only run one copy of this program */
}
/* 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);
+ tmpfd = eina_file_mkstemp("efreet_desktop_cache_XXXXXX", &file);
if (tmpfd < 0) goto error;
close(tmpfd);
ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
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);
+ tmpfd = eina_file_mkstemp("efreet_desktop_util_cache_XXXXXX", &util_file);
if (tmpfd < 0) goto error;
close(tmpfd);
util_ef = eet_open(util_file, EET_FILE_MODE_READ_WRITE);
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);
close(lockfd);
return 0;
error:
+ eina_tmpstr_del(file);
+ eina_tmpstr_del(util_file);
IF_FREE(dir);
edd_error:
if (old_file_ids)
int
main(int argc, char *argv[])
{
- char path[PATH_MAX];
FILE *log;
- mode_t um;
+ int fd;
- strcpy(path, "/tmp/efreetd_XXXXXX");
- um = umask(0077);
- if (mkstemp(path) < 0)
- {
- perror("mkstemp");
- umask(um);
- return 1;
- }
- umask(um);
- if (chmod(path, 0700) < 0)
+ if (!eina_init()) return 1;
+
+ fd = eina_file_mkstemp("efreetd_XXXXXX", NULL);
+ if (fd < 0)
{
- perror("chmod");
- return 1;
+ EINA_LOG_ERR("mkstemp");
+ goto eina_error;
}
- log = fopen(path, "wb");
- if (!log) return 1;
+ log = fdopen(fd, "wb");
+ if (!log)
+ goto eina_error;
- 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);
if (efreetd_log_dom >= 0)
eina_log_domain_unregister(efreetd_log_dom);
efreetd_log_dom = -1;
+eina_error:
eina_shutdown();
return 1;
}