modules/teamwork: Use eina_file_mkstemp() to avoid problems with umask
authorStefan Schmidt <s.schmidt@samsung.com>
Fri, 19 Sep 2014 09:16:47 +0000 (11:16 +0200)
committerStefan Schmidt <s.schmidt@samsung.com>
Fri, 19 Sep 2014 09:30:28 +0000 (11:30 +0200)
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

index e5ea8ce..09f877b 100644 (file)
@@ -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;