From 9eee1f80fc8fbd852bdf8b42eec663d818ffd5c2 Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Thu, 9 Feb 2017 11:27:48 +0900 Subject: [PATCH] evas wayland shm engine - use vpath for getting xdg runtime dir 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 --- .../evas/engines/wayland_shm/evas_shm.c | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/modules/evas/engines/wayland_shm/evas_shm.c b/src/modules/evas/engines/wayland_shm/evas_shm.c index 9d9535b7be..05c7ec3945 100644 --- a/src/modules/evas/engines/wayland_shm/evas_shm.c +++ b/src/modules/evas/engines/wayland_shm/evas_shm.c @@ -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);