summaryrefslogtreecommitdiff
path: root/src/modules/ecore_buffer
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-02-09 11:24:52 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-02-09 18:38:28 +0900
commit3bcd788c7d72b089598c1fc6bb5d6261d9401595 (patch)
tree798560074765edbe916d2ae7a3f887efd0171681 /src/modules/ecore_buffer
parent311ecceeb75a671cea051686a5c04c9633666a66 (diff)
ecore buffer module - use vpath for xdg runtime for setuid safety
this should make ecore buffer module safe to use in setuid processes
Diffstat (limited to 'src/modules/ecore_buffer')
-rw-r--r--src/modules/ecore_buffer/shm/ecore_buffer_shm.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/modules/ecore_buffer/shm/ecore_buffer_shm.c b/src/modules/ecore_buffer/shm/ecore_buffer_shm.c
index 6440071dc5..be270a9cbf 100644
--- a/src/modules/ecore_buffer/shm/ecore_buffer_shm.c
+++ b/src/modules/ecore_buffer/shm/ecore_buffer_shm.c
@@ -11,7 +11,8 @@
11#include <string.h> 11#include <string.h>
12 12
13#include <Eina.h> 13#include <Eina.h>
14#include <Ecore.h> 14#include "Ecore.h"
15#include "ecore_private.h"
15#include <Ecore_Buffer.h> 16#include <Ecore_Buffer.h>
16 17
17#ifndef O_BINARY 18#ifndef O_BINARY
@@ -53,16 +54,10 @@ _ecore_buffer_shm_buffer_alloc(Ecore_Buffer_Module_Data bmdata, int width, int h
53{ 54{
54 Ecore_Buffer_Shm_Data* b; 55 Ecore_Buffer_Shm_Data* b;
55 char *name; 56 char *name;
56 static const char tmp[] = "/ecore-buffer-shared-XXXXXX"; 57 static const char tmp[] = "ecore-buffer-shared-XXXXXX";
57 const char *path; 58 const char *path;
58 int fd, size, page_size; 59 int fd, size, page_size;
59 60 Efl_Vpath_File *file_obj;
60 path = getenv("XDG_RUNTIME_DIR");
61 if (!path)
62 {
63 path = getenv("TMPDIR");
64 if (!path) path = "/tmp";
65 }
66 61
67 page_size = eina_cpu_page_size(); 62 page_size = eina_cpu_page_size();
68 63
@@ -75,11 +70,16 @@ _ecore_buffer_shm_buffer_alloc(Ecore_Buffer_Module_Data bmdata, int width, int h
75 b->size = page_size * (((b->stride * b->h) + (page_size - 1)) / page_size); 70 b->size = page_size * (((b->stride * b->h) + (page_size - 1)) / page_size);
76 b->am_owner = EINA_TRUE; 71 b->am_owner = EINA_TRUE;
77 72
73 file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, "(:run:)/");
74 efl_vpath_file_do(file_obj);
75 efl_vpath_file_wait(file_obj);
76 path = efl_vpath_file_result_get(file_obj);
78 size = strlen(path) + sizeof(tmp); 77 size = strlen(path) + sizeof(tmp);
79 name = malloc(size); 78 name = malloc(size);
80 if (!name) goto err; 79 if (!name) goto err;
81 strcpy(name, path); 80 strcpy(name, path);
82 strcat(name, tmp); 81 strcat(name, tmp);
82 efl_del(file_obj);
83 83
84 fd = mkostemp(name, O_CLOEXEC); 84 fd = mkostemp(name, O_CLOEXEC);
85 if (fd < 0) goto err_fd; 85 if (fd < 0) goto err_fd;