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
This commit is contained in:
Stefan Schmidt 2014-09-19 11:16:47 +02:00
parent 4e98f7cb18
commit bbd35e82c3
1 changed files with 5 additions and 6 deletions

View File

@ -1005,7 +1005,7 @@ tw_show(Media *i)
if (i->video) if (i->video)
{ {
char buf[PATH_MAX]; char buf[PATH_MAX];
const char *tmp; Eina_Tmpstr *tmpfile;
if (tw_config->disable_video) return; if (tw_config->disable_video) return;
while (i->tmpfile) while (i->tmpfile)
@ -1032,9 +1032,7 @@ tw_show(Media *i)
tw_show_video(prev, tw_tmpfile); tw_show_video(prev, tw_tmpfile);
return; return;
} }
tmp = getenv("XDG_RUNTIME_DIR"); snprintf(buf, sizeof(buf), "teamwork-%s-XXXXXX", ecore_file_file_get(i->addr));
if (!tmp) tmp = "/tmp";
snprintf(buf, sizeof(buf), "%s/teamwork-%s-XXXXXX", tmp, ecore_file_file_get(i->addr));
if (tw_tmpfile) if (tw_tmpfile)
{ {
if (tw_tmpthread) if (tw_tmpthread)
@ -1045,14 +1043,15 @@ tw_show(Media *i)
} }
close(tw_tmpfd); close(tw_tmpfd);
} }
tw_tmpfd = mkstemp(buf); tw_tmpfd = eina_file_mkstemp(buf, &tmpfile);
eina_stringshare_replace(&tw_tmpfile, buf); eina_stringshare_replace(&tw_tmpfile, tmpfile);
if (tw_tmpfd < 0) if (tw_tmpfd < 0)
{ {
ERR("ERROR: %s", strerror(errno)); ERR("ERROR: %s", strerror(errno));
download_media_cleanup(); download_media_cleanup();
eina_stringshare_replace(&tw_tmpfile, NULL); eina_stringshare_replace(&tw_tmpfile, NULL);
tw_tmpthread_media = NULL; tw_tmpthread_media = NULL;
eina_tmpstr_del(tmpfile);
return; return;
} }
tw_tmpthread_media = i; tw_tmpthread_media = i;