forked from enlightenment/efl
ecore buffer module - use vpath for xdg runtime for setuid safety
this should make ecore buffer module safe to use in setuid processes
This commit is contained in:
parent
311ecceeb7
commit
3bcd788c7d
|
@ -11,7 +11,8 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <Eina.h>
|
#include <Eina.h>
|
||||||
#include <Ecore.h>
|
#include "Ecore.h"
|
||||||
|
#include "ecore_private.h"
|
||||||
#include <Ecore_Buffer.h>
|
#include <Ecore_Buffer.h>
|
||||||
|
|
||||||
#ifndef O_BINARY
|
#ifndef O_BINARY
|
||||||
|
@ -53,16 +54,10 @@ _ecore_buffer_shm_buffer_alloc(Ecore_Buffer_Module_Data bmdata, int width, int h
|
||||||
{
|
{
|
||||||
Ecore_Buffer_Shm_Data* b;
|
Ecore_Buffer_Shm_Data* b;
|
||||||
char *name;
|
char *name;
|
||||||
static const char tmp[] = "/ecore-buffer-shared-XXXXXX";
|
static const char tmp[] = "ecore-buffer-shared-XXXXXX";
|
||||||
const char *path;
|
const char *path;
|
||||||
int fd, size, page_size;
|
int fd, size, page_size;
|
||||||
|
Efl_Vpath_File *file_obj;
|
||||||
path = getenv("XDG_RUNTIME_DIR");
|
|
||||||
if (!path)
|
|
||||||
{
|
|
||||||
path = getenv("TMPDIR");
|
|
||||||
if (!path) path = "/tmp";
|
|
||||||
}
|
|
||||||
|
|
||||||
page_size = eina_cpu_page_size();
|
page_size = eina_cpu_page_size();
|
||||||
|
|
||||||
|
@ -75,11 +70,16 @@ _ecore_buffer_shm_buffer_alloc(Ecore_Buffer_Module_Data bmdata, int width, int h
|
||||||
b->size = page_size * (((b->stride * b->h) + (page_size - 1)) / page_size);
|
b->size = page_size * (((b->stride * b->h) + (page_size - 1)) / page_size);
|
||||||
b->am_owner = EINA_TRUE;
|
b->am_owner = EINA_TRUE;
|
||||||
|
|
||||||
|
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);
|
||||||
size = strlen(path) + sizeof(tmp);
|
size = strlen(path) + sizeof(tmp);
|
||||||
name = malloc(size);
|
name = malloc(size);
|
||||||
if (!name) goto err;
|
if (!name) goto err;
|
||||||
strcpy(name, path);
|
strcpy(name, path);
|
||||||
strcat(name, tmp);
|
strcat(name, tmp);
|
||||||
|
efl_del(file_obj);
|
||||||
|
|
||||||
fd = mkostemp(name, O_CLOEXEC);
|
fd = mkostemp(name, O_CLOEXEC);
|
||||||
if (fd < 0) goto err_fd;
|
if (fd < 0) goto err_fd;
|
||||||
|
|
Loading…
Reference in New Issue