From bbd35e82c3819304297cd8edcd74d3620eda141c Mon Sep 17 00:00:00 2001 From: Stefan Schmidt Date: Fri, 19 Sep 2014 11:16:47 +0200 Subject: [PATCH] modules/teamwork: Use eina_file_mkstemp() to avoid problems with umask Keeping the snprintf to arrange for the tmp file name including the i->addr in the filename. CID: 1039805 --- src/modules/teamwork/e_mod_tw.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/modules/teamwork/e_mod_tw.c b/src/modules/teamwork/e_mod_tw.c index e5ea8cec5..09f877b44 100644 --- a/src/modules/teamwork/e_mod_tw.c +++ b/src/modules/teamwork/e_mod_tw.c @@ -1005,7 +1005,7 @@ tw_show(Media *i) if (i->video) { char buf[PATH_MAX]; - const char *tmp; + Eina_Tmpstr *tmpfile; if (tw_config->disable_video) return; while (i->tmpfile) @@ -1032,9 +1032,7 @@ tw_show(Media *i) tw_show_video(prev, tw_tmpfile); return; } - tmp = getenv("XDG_RUNTIME_DIR"); - if (!tmp) tmp = "/tmp"; - snprintf(buf, sizeof(buf), "%s/teamwork-%s-XXXXXX", tmp, ecore_file_file_get(i->addr)); + snprintf(buf, sizeof(buf), "teamwork-%s-XXXXXX", ecore_file_file_get(i->addr)); if (tw_tmpfile) { if (tw_tmpthread) @@ -1045,14 +1043,15 @@ tw_show(Media *i) } close(tw_tmpfd); } - tw_tmpfd = mkstemp(buf); - eina_stringshare_replace(&tw_tmpfile, buf); + tw_tmpfd = eina_file_mkstemp(buf, &tmpfile); + eina_stringshare_replace(&tw_tmpfile, tmpfile); if (tw_tmpfd < 0) { ERR("ERROR: %s", strerror(errno)); download_media_cleanup(); eina_stringshare_replace(&tw_tmpfile, NULL); tw_tmpthread_media = NULL; + eina_tmpstr_del(tmpfile); return; } tw_tmpthread_media = i;