evas wayland shm engine - use vpath for getting xdg runtime dir
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>
Thu, 9 Feb 2017 02:27:48 +0000 (11:27 +0900)
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>
Thu, 9 Feb 2017 09:38:28 +0000 (18:38 +0900)
this should make the wayland shm engine safe to use from setuid
processes. it shouldnt depend on getenv of specific file paths if
setuid. vpatrh takes care of this in one central place

src/modules/evas/engines/wayland_shm/evas_shm.c

index 9d9535b..05c7ec3 100644 (file)
@@ -82,11 +82,12 @@ static struct wl_shm_pool *
 _shm_pool_make(struct wl_shm *shm, int size, void **data)
 {
    struct wl_shm_pool *pool;
-   static const char tmp[] = "/evas-wayland_shm-XXXXXX";
+   static const char tmp[] = "evas-wayland_shm-XXXXXX";
    const char *path;
    char *name;
    int fd = 0;
    Eina_Tmpstr *fullname;
+   Efl_Vpath_File *file_obj;
 
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
@@ -94,19 +95,12 @@ _shm_pool_make(struct wl_shm *shm, int size, void **data)
    if (!shm) return NULL;
 
    /* create tmp file name */
-   if ((path = getenv("XDG_RUNTIME_DIR")))
-     {
-        if ((name = malloc(strlen(path) + sizeof(tmp))))
-          strcpy(name, path);
-     }
-   else
-     {
-        if ((name = malloc(strlen("/tmp") + sizeof(tmp))))
-          strcpy(name, "/tmp");
-     }
-
+   file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, "(:run:)/");
+   efl_vpath_file_do(file_obj);
+   efl_vpath_file_wait(file_obj);
+   path = efl_vpath_file_result_get(file_obj);
+   if ((name = malloc(strlen(path) + sizeof(tmp)))) strcpy(name, path);
    if (!name) return NULL;
-
    strcat(name, tmp);
 
    fd = eina_file_mkstemp(name, &fullname);