forked from enlightenment/efl
setuid safeness - ensure if an app that is setuid doesn't do bad things
this makes efl ignore certain env vars for thnigs and entirely removes user modules (that no one ever used) etc. etc. to ensure that *IF* an app is setuid, there isn't a priv escalation path that is easy.
This commit is contained in:
parent
323f293ab5
commit
b95ef3801f
|
@ -130,8 +130,9 @@ static void
|
|||
ecore_system_modules_load(void)
|
||||
{
|
||||
char buf[PATH_MAX] = "";
|
||||
char *path;
|
||||
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
if (getenv("EFL_RUN_IN_TREE"))
|
||||
{
|
||||
struct stat st;
|
||||
|
@ -163,20 +164,6 @@ ecore_system_modules_load(void)
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
path = eina_module_environment_path_get("ECORE_MODULES_DIR",
|
||||
"/ecore/system");
|
||||
if (path)
|
||||
{
|
||||
module_list = eina_module_arch_list_get(module_list, path, MODULE_ARCH);
|
||||
free(path);
|
||||
}
|
||||
|
||||
path = eina_module_environment_path_get("HOME", "/.ecore/system");
|
||||
if (path)
|
||||
{
|
||||
module_list = eina_module_arch_list_get(module_list, path, MODULE_ARCH);
|
||||
free(path);
|
||||
}
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/ecore/system",
|
||||
|
|
|
@ -1609,7 +1609,7 @@ _ecore_exe_exec_it(const char *exe_cmd,
|
|||
{
|
||||
if (!shell) /* Find users preferred shell. */
|
||||
{
|
||||
shell = getenv("SHELL");
|
||||
if (getuid() == getuid()) shell = getenv("SHELL");
|
||||
if (!shell)
|
||||
shell = "/bin/sh";
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <pwd.h>
|
||||
|
||||
#ifdef HAVE_SYSTEMD
|
||||
# include <systemd/sd-daemon.h>
|
||||
|
@ -71,6 +72,8 @@ ecore_con_local_connect(Ecore_Con_Server *svr,
|
|||
buf[0] = '\0';
|
||||
|
||||
if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_USER)
|
||||
{
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
homedir = getenv("XDG_RUNTIME_DIR");
|
||||
if (!homedir)
|
||||
|
@ -82,10 +85,22 @@ ecore_con_local_connect(Ecore_Con_Server *svr,
|
|||
if (!homedir) homedir = "/tmp";
|
||||
}
|
||||
}
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/.ecore/%s/%i", homedir, svr->name,
|
||||
svr->port);
|
||||
}
|
||||
else
|
||||
{
|
||||
struct passwd *pw = getpwent();
|
||||
|
||||
if ((!pw) || (!pw->pw_dir))
|
||||
snprintf(buf, sizeof(buf), "/tmp/%s/%i", svr->name,
|
||||
svr->port);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "%s/.ecore/%s/%i", pw->pw_dir, svr->name,
|
||||
svr->port);
|
||||
}
|
||||
|
||||
}
|
||||
else if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_SYSTEM)
|
||||
{
|
||||
if (svr->port < 0)
|
||||
|
@ -202,6 +217,8 @@ ecore_con_local_listen(
|
|||
mask = S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH;
|
||||
|
||||
if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_USER)
|
||||
{
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
homedir = getenv("XDG_RUNTIME_DIR");
|
||||
if (!homedir)
|
||||
|
@ -213,6 +230,14 @@ ecore_con_local_listen(
|
|||
if (!homedir) homedir = "/tmp";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
struct passwd *pw = getpwent();
|
||||
|
||||
if ((!pw) || (!pw->pw_dir)) homedir = "/tmp";
|
||||
else homedir = pw->pw_dir;
|
||||
}
|
||||
|
||||
mask = S_IRUSR | S_IWUSR | S_IXUSR;
|
||||
snprintf(buf, sizeof(buf), "%s/.ecore", homedir);
|
||||
|
|
|
@ -414,7 +414,7 @@ ecore_con_local_listen(Ecore_Con_Server *svr)
|
|||
{
|
||||
const char *computername;
|
||||
|
||||
computername = getenv("CoMPUTERNAME");
|
||||
computername = getenv("COMPUTERNAME");
|
||||
snprintf(buf, sizeof(buf), "\\\\%s\\pipe\\%s", computername, svr->name);
|
||||
}
|
||||
|
||||
|
|
|
@ -585,7 +585,7 @@ ecore_con_socks_dns_cb(const char *canonname EINA_UNUSED, const char *ip, struct
|
|||
void
|
||||
ecore_con_socks_init(void)
|
||||
{
|
||||
const char *socks;
|
||||
const char *socks = NULL;
|
||||
char *h, *p, *l, *u = NULL;
|
||||
char buf[512];
|
||||
int port, lookup = 0;
|
||||
|
@ -596,6 +596,8 @@ ecore_con_socks_init(void)
|
|||
unsigned char addr6[sizeof(struct in6_addr)];
|
||||
#endif
|
||||
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
/* ECORE_CON_SOCKS_V4=[user@]host-port:[1|0] */
|
||||
socks = getenv("ECORE_CON_SOCKS_V4");
|
||||
if (!socks)
|
||||
|
@ -604,6 +606,7 @@ ecore_con_socks_init(void)
|
|||
socks = getenv("ECORE_CON_SOCKS_V5");
|
||||
v5 = EINA_TRUE;
|
||||
}
|
||||
}
|
||||
if ((!socks) || (!socks[0]) || (strlen(socks) + 1 > 512)) return;
|
||||
memcpy(buf, socks, strlen(socks) + 1);
|
||||
h = strchr(buf, '@');
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "Ecore_Evas.h"
|
||||
#include "ecore_evas_private.h"
|
||||
#include <unistd.h>
|
||||
|
||||
static Eina_Hash *_registered_engines = NULL;
|
||||
static Eina_List *_engines_paths = NULL;
|
||||
|
@ -38,6 +39,8 @@ _ecore_evas_engine_load(const char *engine)
|
|||
{
|
||||
char tmp[PATH_MAX] = "";
|
||||
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
if (run_in_tree)
|
||||
{
|
||||
struct stat st;
|
||||
|
@ -46,6 +49,7 @@ _ecore_evas_engine_load(const char *engine)
|
|||
if (stat(tmp, &st) != 0)
|
||||
tmp[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (tmp[0] == '\0')
|
||||
snprintf(tmp, sizeof(tmp), "%s/%s/%s/%s",
|
||||
|
@ -69,7 +73,7 @@ _ecore_evas_engine_load(const char *engine)
|
|||
void
|
||||
_ecore_evas_engine_init(void)
|
||||
{
|
||||
char *paths[4] = { NULL, NULL, NULL, NULL };
|
||||
char *paths[2] = { NULL, NULL };
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
|
||||
|
@ -77,6 +81,8 @@ _ecore_evas_engine_init(void)
|
|||
// _registered_engines = eina_hash_string_small_new(EINA_FREE_CB(eina_module_free));
|
||||
_registered_engines = eina_hash_string_small_new(NULL);
|
||||
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
if (getenv("EFL_RUN_IN_TREE"))
|
||||
{
|
||||
struct stat st;
|
||||
|
@ -87,16 +93,13 @@ _ecore_evas_engine_init(void)
|
|||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 1. ~/.ecore_evas/modules/ */
|
||||
paths[0] = eina_module_environment_path_get("HOME", "/.ecore_evas/engines");
|
||||
/* 2. $(ECORE_ENGINE_DIR)/ecore_evas/modules/ */
|
||||
paths[1] = eina_module_environment_path_get("ECORE_EVAS_ENGINES_DIR", "/ecore_evas/engines");
|
||||
/* 3. libecore_evas.so/../ecore_evas/engines/ */
|
||||
paths[2] = eina_module_symbol_path_get(_ecore_evas_engine_init, "/ecore_evas/engines");
|
||||
/* 4. PREFIX/ecore_evas/engines/ */
|
||||
/* 1. libecore_evas.so/../ecore_evas/engines/ */
|
||||
paths[0] = eina_module_symbol_path_get(_ecore_evas_engine_init, "/ecore_evas/engines");
|
||||
/* 2. PREFIX/ecore_evas/engines/ */
|
||||
#ifndef _MSC_VER
|
||||
paths[3] = strdup(PACKAGE_LIB_DIR "/ecore_evas/engines");
|
||||
paths[1] = strdup(PACKAGE_LIB_DIR "/ecore_evas/engines");
|
||||
#endif
|
||||
|
||||
for (j = 0; j < ((sizeof (paths) / sizeof (char*)) - 1); ++j)
|
||||
|
|
|
@ -108,7 +108,7 @@ _ecore_fb_size_get(int *w, int *h)
|
|||
struct fb_var_screeninfo fb_var;
|
||||
int fb;
|
||||
|
||||
if (getenv("EVAS_FB_DEV"))
|
||||
if ((getuid() == getuid()) && (getenv("EVAS_FB_DEV")))
|
||||
fb = open(getenv("EVAS_FB_DEV"), O_RDWR);
|
||||
else
|
||||
{
|
||||
|
|
|
@ -81,7 +81,7 @@ ecore_fb_ts_init(void)
|
|||
{
|
||||
#ifdef HAVE_TSLIB
|
||||
char *tslib_tsdevice = NULL;
|
||||
if ( (tslib_tsdevice = getenv("TSLIB_TSDEVICE")) )
|
||||
if ((getuid() == getuid()) && ((tslib_tsdevice = getenv("TSLIB_TSDEVICE"))))
|
||||
{
|
||||
printf( "ECORE_FB: TSLIB_TSDEVICE = '%s'\n", tslib_tsdevice );
|
||||
_ecore_fb_tslib_tsdev = ts_open( tslib_tsdevice, 1 ); /* 1 = nonblocking, 0 = blocking */
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <Ecore.h>
|
||||
#include <ecore_private.h>
|
||||
|
@ -30,13 +31,13 @@ void
|
|||
ecore_imf_module_init(void)
|
||||
{
|
||||
char buf[PATH_MAX] = "";
|
||||
char *path;
|
||||
|
||||
pfx = eina_prefix_new(NULL, ecore_imf_init,
|
||||
"ECORE_IMF", "ecore_imf", "checkme",
|
||||
PACKAGE_BIN_DIR, PACKAGE_LIB_DIR,
|
||||
PACKAGE_DATA_DIR, PACKAGE_DATA_DIR);
|
||||
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
if (getenv("EFL_RUN_IN_TREE"))
|
||||
{
|
||||
struct stat st;
|
||||
|
@ -74,20 +75,6 @@ ecore_imf_module_init(void)
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
path = eina_module_environment_path_get("ECORE_IMF_MODULES_DIR",
|
||||
"/ecore_imf/modules");
|
||||
if (path)
|
||||
{
|
||||
module_list = eina_module_arch_list_get(module_list, path, MODULE_ARCH);
|
||||
free(path);
|
||||
}
|
||||
|
||||
path = eina_module_environment_path_get("HOME", "/.ecore_imf");
|
||||
if (path)
|
||||
{
|
||||
module_list = eina_module_arch_list_get(module_list, path, MODULE_ARCH);
|
||||
free(path);
|
||||
}
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/ecore_imf/modules", eina_prefix_lib_get(pfx));
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "ecore_xcb_private.h"
|
||||
#include <fnmatch.h>
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
|
||||
/* local function prototypes */
|
||||
static Eina_Bool _ecore_xcb_xdefaults_glob_match(const char *str,
|
||||
|
@ -16,7 +18,19 @@ _ecore_xcb_xdefaults_init(void)
|
|||
|
||||
LOGFN(__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
if (getenv("HOME"))
|
||||
snprintf(buff, sizeof(buff), "%s/.Xdefaults", getenv("HOME"));
|
||||
else return;
|
||||
}
|
||||
else
|
||||
{
|
||||
struct passwd *pw = getpwent();
|
||||
|
||||
if ((!pw) || (!pw->pw_dir)) return;
|
||||
snprintf(buff, sizeof(buff), "%s/.Xdefaults", pw->pw_dir);
|
||||
}
|
||||
if ((_ecore_xcb_xdefaults_file = eina_file_open(buff, EINA_FALSE)))
|
||||
{
|
||||
eina_mmap_safety_enabled_set(EINA_TRUE);
|
||||
|
|
|
@ -6808,6 +6808,8 @@ _edje_edit_embryo_rebuild(Edje_Edit *eed)
|
|||
#else
|
||||
# define BIN_EXT
|
||||
#endif
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
if (getenv("EFL_RUN_IN_TREE"))
|
||||
{
|
||||
snprintf(embryo_cc_path, sizeof(embryo_cc_path),
|
||||
|
@ -6818,6 +6820,7 @@ _edje_edit_embryo_rebuild(Edje_Edit *eed)
|
|||
if (!ecore_file_exists(embryo_cc_path))
|
||||
embryo_cc_path[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (embryo_cc_path[0] == '\0')
|
||||
{
|
||||
|
|
|
@ -37,6 +37,8 @@ _edje_module_handle_load(const char *module)
|
|||
{
|
||||
char tmp[PATH_MAX] = "";
|
||||
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
if (run_in_tree)
|
||||
{
|
||||
struct stat st;
|
||||
|
@ -45,6 +47,7 @@ _edje_module_handle_load(const char *module)
|
|||
if (stat(tmp, &st) != 0)
|
||||
tmp[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (tmp[0] == '\0')
|
||||
snprintf(tmp, sizeof(tmp), "%s/%s/%s/%s",
|
||||
|
@ -68,12 +71,14 @@ _edje_module_handle_load(const char *module)
|
|||
void
|
||||
_edje_module_init(void)
|
||||
{
|
||||
char *paths[4] = { NULL, NULL, NULL, NULL };
|
||||
char *paths[2] = { NULL, NULL };
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
|
||||
_registered_modules = eina_hash_string_small_new(EINA_FREE_CB(eina_module_free));
|
||||
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
if (getenv("EFL_RUN_IN_TREE"))
|
||||
{
|
||||
struct stat st;
|
||||
|
@ -84,16 +89,13 @@ _edje_module_init(void)
|
|||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 1. ~/.edje/modules/ */
|
||||
paths[0] = eina_module_environment_path_get("HOME", "/.edje/modules");
|
||||
/* 2. $(EDJE_MODULE_DIR)/edje/modules/ */
|
||||
paths[1] = eina_module_environment_path_get("EDJE_MODULES_DIR", "/edje/modules");
|
||||
/* 3. libedje.so/../edje/modules/ */
|
||||
paths[2] = eina_module_symbol_path_get(_edje_module_init, "/edje/modules");
|
||||
/* 4. PREFIX/edje/modules/ */
|
||||
/* 1. libedje.so/../edje/modules/ */
|
||||
paths[0] = eina_module_symbol_path_get(_edje_module_init, "/edje/modules");
|
||||
/* 2. PREFIX/edje/modules/ */
|
||||
#ifndef _MSC_VER
|
||||
paths[3] = strdup(PACKAGE_LIB_DIR "/edje/modules");
|
||||
paths[1] = strdup(PACKAGE_LIB_DIR "/edje/modules");
|
||||
#endif
|
||||
|
||||
for (j = 0; j < ((sizeof (paths) / sizeof (char*)) - 1); ++j)
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <Eina.h>
|
||||
#include <Ecore.h>
|
||||
#include <Eeze_Sensor.h>
|
||||
|
@ -81,7 +82,7 @@ eeze_sensor_modules_load(void)
|
|||
* is one of these items. We do load the modules from the builddir if the
|
||||
* environment is set. Normal case is to use installed modules from system
|
||||
*/
|
||||
if (getenv("EFL_RUN_IN_TREE"))
|
||||
if ((getuid() == getuid()) && (getenv("EFL_RUN_IN_TREE")))
|
||||
{
|
||||
const char **itr;
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <winsock2.h>
|
||||
|
@ -276,10 +278,20 @@ efreet_dirs_init(void)
|
|||
struct stat st;
|
||||
|
||||
/* efreet_home_dir */
|
||||
if (getuid() == getuid())
|
||||
efreet_home_dir = getenv("HOME");
|
||||
else
|
||||
{
|
||||
struct passwd *pw = getpwent();
|
||||
|
||||
if ((pw) && (pw->pw_dir)) efreet_home_dir = pw->pw_dir;
|
||||
}
|
||||
#ifdef _WIN32
|
||||
if (!efreet_home_dir || efreet_home_dir[0] == '\0')
|
||||
{
|
||||
if (getuid() == getuid())
|
||||
efreet_home_dir = getenv("USERPROFILE");
|
||||
}
|
||||
#endif
|
||||
if (!efreet_home_dir || efreet_home_dir[0] == '\0')
|
||||
efreet_home_dir = "/tmp";
|
||||
|
@ -303,7 +315,7 @@ efreet_dirs_init(void)
|
|||
xdg_config_dirs = efreet_dirs_get("XDG_CONFIG_DIRS", "/etc/xdg");
|
||||
|
||||
/* xdg_runtime_dir */
|
||||
xdg_runtime_dir = getenv("XDG_RUNTIME_DIR");
|
||||
if (getuid() == getuid()) xdg_runtime_dir = getenv("XDG_RUNTIME_DIR");
|
||||
if (!xdg_runtime_dir)
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "/tmp/xdg-XXXXXX");
|
||||
|
@ -375,10 +387,10 @@ efreet_dirs_init(void)
|
|||
static const char *
|
||||
efreet_dir_get(const char *key, const char *fallback)
|
||||
{
|
||||
char *dir;
|
||||
char *dir = NULL;
|
||||
const char *t;
|
||||
|
||||
dir = getenv(key);
|
||||
if (getuid() == getuid()) dir = getenv(key);
|
||||
if (!dir || dir[0] == '\0')
|
||||
{
|
||||
int len;
|
||||
|
@ -409,11 +421,11 @@ static Eina_List *
|
|||
efreet_dirs_get(const char *key, const char *fallback)
|
||||
{
|
||||
Eina_List *dirs = NULL;
|
||||
const char *path;
|
||||
const char *path = NULL;
|
||||
char *s, *p;
|
||||
size_t len;
|
||||
|
||||
path = getenv(key);
|
||||
if (getuid() == getuid()) path = getenv(key);
|
||||
if (!path || (path[0] == '\0')) path = fallback;
|
||||
|
||||
if (!path) return dirs;
|
||||
|
@ -484,9 +496,12 @@ efreet_env_expand(const char *in)
|
|||
{
|
||||
memcpy(env, e1, len);
|
||||
env[len] = 0;
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
val = getenv(env);
|
||||
if (val) eina_strbuf_append(sb, val);
|
||||
}
|
||||
}
|
||||
e1 = NULL;
|
||||
eina_strbuf_append_char(sb, *p);
|
||||
}
|
||||
|
|
|
@ -399,6 +399,7 @@ efreet_menu_init(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (getuid() == getuid())
|
||||
efreet_menu_prefix = getenv("XDG_MENU_PREFIX");
|
||||
if (!efreet_menu_prefix) efreet_menu_prefix = "";
|
||||
|
||||
|
|
|
@ -897,12 +897,12 @@ EAPI int
|
|||
eina_file_mkstemp(const char *templatename, Eina_Tmpstr **path)
|
||||
{
|
||||
char buffer[PATH_MAX];
|
||||
const char *tmpdir;
|
||||
const char *tmpdir = NULL;
|
||||
int fd;
|
||||
mode_t old_umask;
|
||||
|
||||
#ifndef HAVE_EVIL
|
||||
tmpdir = getenv("TMPDIR");
|
||||
if (getuid() == getuid()) tmpdir = getenv("TMPDIR");
|
||||
if (!tmpdir) tmpdir = "/tmp";
|
||||
#else
|
||||
tmpdir = (char *)evil_tmpdir_get();
|
||||
|
@ -929,11 +929,11 @@ EAPI Eina_Bool
|
|||
eina_file_mkdtemp(const char *templatename, Eina_Tmpstr **path)
|
||||
{
|
||||
char buffer[PATH_MAX];
|
||||
const char *tmpdir;
|
||||
const char *tmpdir = NULL;
|
||||
char *tmpdirname;
|
||||
|
||||
#ifndef HAVE_EVIL
|
||||
tmpdir = getenv("TMPDIR");
|
||||
if (getuid() == getuid()) tmpdir = getenv("TMPDIR");
|
||||
if (!tmpdir) tmpdir = "/tmp";
|
||||
#else
|
||||
tmpdir = (char *)evil_tmpdir_get();
|
||||
|
|
|
@ -176,17 +176,6 @@ eina_mempool_init(void)
|
|||
PACKAGE_LIB_DIR "/eina/modules/mp",
|
||||
MODULE_ARCH);
|
||||
|
||||
path = eina_module_environment_path_get("HOME", "/.eina/mp/modules/mp");
|
||||
_modules = eina_module_arch_list_get(_modules, path, MODULE_ARCH);
|
||||
if (path)
|
||||
free(path);
|
||||
|
||||
path = eina_module_environment_path_get("EINA_MODULES_MEMPOOL_DIR",
|
||||
"/eina/modules/mp");
|
||||
_modules = eina_module_arch_list_get(_modules, path, MODULE_ARCH);
|
||||
if (path)
|
||||
free(path);
|
||||
|
||||
path = eina_module_symbol_path_get((const void *)eina_init,
|
||||
"/eina/modules/mp");
|
||||
_modules = eina_module_arch_list_get(_modules, path, MODULE_ARCH);
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <libgen.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef HAVE_DLOPEN
|
||||
# include <dlfcn.h>
|
||||
|
@ -430,6 +431,7 @@ EAPI char *eina_module_environment_path_get(const char *env,
|
|||
const char *env_dir;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(env, NULL);
|
||||
if (getuid() != getuid()) return NULL; // if setuid dont use dangerous env
|
||||
|
||||
env_dir = getenv(env);
|
||||
if (env_dir)
|
||||
|
|
|
@ -335,6 +335,7 @@ _try_argv(Eina_Prefix *pfx, const char *argv0)
|
|||
}
|
||||
|
||||
/* 3. argv0 no path - look in PATH */
|
||||
if (getuid() != getuid()) return 0;
|
||||
path = getenv("PATH");
|
||||
if (!path)
|
||||
{
|
||||
|
@ -383,6 +384,7 @@ _get_env_var(char **var, const char *envprefix, const char *envsuffix, const cha
|
|||
char env[1024];
|
||||
const char *s;
|
||||
|
||||
if (getuid() != getuid()) return 0;
|
||||
snprintf(env, sizeof(env), "%s_%s_DIR", envprefix, envsuffix);
|
||||
s = getenv(env);
|
||||
if (s)
|
||||
|
@ -418,6 +420,8 @@ _get_env_vars(Eina_Prefix *pfx,
|
|||
const char *prefix;
|
||||
int ret = 0;
|
||||
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
snprintf(env, sizeof(env), "%s_PREFIX", envprefix);
|
||||
if ((prefix = getenv(env))) STRDUP_REP(pfx->prefix_path, prefix);
|
||||
|
||||
|
@ -425,6 +429,7 @@ _get_env_vars(Eina_Prefix *pfx,
|
|||
ret += _get_env_var(&pfx->prefix_path_lib, envprefix, "LIB", prefix, libdir);
|
||||
ret += _get_env_var(&pfx->prefix_path_data, envprefix, "DATA", prefix, datadir);
|
||||
ret += _get_env_var(&pfx->prefix_path_locale, envprefix, "LOCALE", prefix, localedir);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#endif
|
||||
|
||||
#include "emotion_private.h"
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef EMOTION_STATIC_BUILD_XINE
|
||||
Eina_Bool xine_module_init(void);
|
||||
|
@ -53,11 +54,12 @@ static void
|
|||
_emotion_modules_load(void)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
char *path;
|
||||
|
||||
if (_emotion_modules_loaded) return;
|
||||
_emotion_modules_loaded = EINA_TRUE;
|
||||
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
if (getenv("EFL_RUN_IN_TREE"))
|
||||
{
|
||||
struct stat st;
|
||||
|
@ -86,20 +88,6 @@ _emotion_modules_load(void)
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
path = eina_module_environment_path_get("EMOTION_MODULES_DIR",
|
||||
"/emotion/modules");
|
||||
if (path)
|
||||
{
|
||||
_emotion_modules = eina_module_arch_list_get(_emotion_modules, path, MODULE_ARCH);
|
||||
free(path);
|
||||
}
|
||||
|
||||
path = eina_module_environment_path_get("HOME", "/.emotion");
|
||||
if (path)
|
||||
{
|
||||
_emotion_modules = eina_module_arch_list_get(_emotion_modules, path, MODULE_ARCH);
|
||||
free(path);
|
||||
}
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/emotion/modules", eina_prefix_lib_get(_emotion_pfx));
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include <dirent.h>
|
||||
#include <dlfcn.h>
|
||||
#include <ctype.h>
|
||||
#include <pwd.h>
|
||||
|
||||
#ifdef HAVE_XATTR
|
||||
# include <sys/xattr.h>
|
||||
|
@ -154,11 +155,12 @@ static void
|
|||
_ethumb_plugins_load(void)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
char *path;
|
||||
|
||||
if (_plugins_loaded) return;
|
||||
_plugins_loaded = EINA_TRUE;
|
||||
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
if (getenv("EFL_RUN_IN_TREE"))
|
||||
{
|
||||
struct stat st;
|
||||
|
@ -182,20 +184,6 @@ _ethumb_plugins_load(void)
|
|||
goto load;
|
||||
}
|
||||
}
|
||||
|
||||
path = eina_module_environment_path_get("ETHUMB_MODULES_DIR",
|
||||
"/ethumb/modules");
|
||||
if (path)
|
||||
{
|
||||
_plugins = eina_module_arch_list_get(_plugins, path, MODULE_ARCH);
|
||||
free(path);
|
||||
}
|
||||
|
||||
path = eina_module_environment_path_get("HOME", "/.ethumb");
|
||||
if (path)
|
||||
{
|
||||
_plugins = eina_module_arch_list_get(_plugins, path, MODULE_ARCH);
|
||||
free(path);
|
||||
}
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/ethumb/modules", eina_prefix_lib_get(_pfx));
|
||||
|
@ -269,8 +257,18 @@ ethumb_init(void)
|
|||
ecore_evas_init();
|
||||
edje_init();
|
||||
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
home = getenv("HOME");
|
||||
snprintf(buf, sizeof(buf), "%s/.thumbnails", home);
|
||||
}
|
||||
else
|
||||
{
|
||||
struct passwd *pw = getpwent();
|
||||
|
||||
if ((!pw) || (!pw->pw_dir)) goto error_plugins_ext;
|
||||
snprintf(buf, sizeof(buf), "%s/.thumbnails", pw->pw_dir);
|
||||
}
|
||||
|
||||
_home_thumb_dir = eina_stringshare_add(buf);
|
||||
_thumb_category_normal = eina_stringshare_add("normal");
|
||||
|
@ -708,12 +706,22 @@ _ethumb_build_absolute_path(const char *path, char buf[PATH_MAX])
|
|||
p[PATH_MAX - 1] = 0;
|
||||
}
|
||||
else if (path[0] == '~')
|
||||
{
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
const char *home = getenv("HOME");
|
||||
if (!home)
|
||||
return NULL;
|
||||
if (!home) return NULL;
|
||||
strncpy(p, home, PATH_MAX - 1);
|
||||
p[PATH_MAX - 1] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
struct passwd *pw = getpwent();
|
||||
|
||||
if ((!pw) || (!pw->pw_dir)) return NULL;
|
||||
strncpy(p, pw->pw_dir, PATH_MAX - 1);
|
||||
p[PATH_MAX - 1] = 0;
|
||||
}
|
||||
len = strlen(p);
|
||||
p += len;
|
||||
p[0] = '/';
|
||||
|
|
|
@ -128,17 +128,22 @@ _socket_path_set(char *path)
|
|||
char *env;
|
||||
char buf[UNIX_PATH_MAX];
|
||||
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
env = getenv("EVAS_CSERVE2_SOCKET");
|
||||
if (env && env[0])
|
||||
{
|
||||
eina_strlcpy(path, env, UNIX_PATH_MAX);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
snprintf(buf, sizeof(buf), "/tmp/.evas-cserve2-%x.socket", (int)getuid());
|
||||
/* FIXME: check we can actually create this socket */
|
||||
strcpy(path, buf);
|
||||
#if 0
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
env = getenv("XDG_RUNTIME_DIR");
|
||||
if (!env || !env[0])
|
||||
{
|
||||
|
@ -154,6 +159,7 @@ _socket_path_set(char *path)
|
|||
snprintf(buf, sizeof(buf), "%s/evas-cserve2-%x.socket", env, getuid());
|
||||
/* FIXME: check we can actually create this socket */
|
||||
strcpy(path, buf);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -56,6 +56,8 @@ evas_module_paths_init(void)
|
|||
{
|
||||
char *libdir, *path;
|
||||
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
if (getenv("EFL_RUN_IN_TREE"))
|
||||
{
|
||||
struct stat st;
|
||||
|
@ -66,19 +68,9 @@ evas_module_paths_init(void)
|
|||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 1. ~/.evas/modules/ */
|
||||
path = eina_module_environment_path_get("HOME", "/.evas/modules");
|
||||
evas_module_paths = _evas_module_append(evas_module_paths, path);
|
||||
|
||||
/* 2. $(EVAS_MODULE_DIR)/evas/modules/ */
|
||||
path = eina_module_environment_path_get("EVAS_MODULES_DIR", "/evas/modules");
|
||||
if (eina_list_search_unsorted(evas_module_paths, (Eina_Compare_Cb) strcmp, path))
|
||||
free(path);
|
||||
else
|
||||
evas_module_paths = _evas_module_append(evas_module_paths, path);
|
||||
|
||||
/* 3. libevas.so/../evas/modules/ */
|
||||
/* 1. libevas.so/../evas/modules/ */
|
||||
libdir = (char *)_evas_module_libdir_get();
|
||||
if (!libdir)
|
||||
path = eina_module_symbol_path_get(evas_module_paths_init, "/evas/modules");
|
||||
|
@ -96,7 +88,7 @@ evas_module_paths_init(void)
|
|||
else
|
||||
evas_module_paths = _evas_module_append(evas_module_paths, path);
|
||||
|
||||
/* 4. PREFIX/lib/evas/modules/ */
|
||||
/* 2. PREFIX/lib/evas/modules/ */
|
||||
#ifndef _MSC_VER
|
||||
path = PACKAGE_LIB_DIR "/evas/modules";
|
||||
if (!eina_list_search_unsorted(evas_module_paths, (Eina_Compare_Cb) strcmp, path))
|
||||
|
@ -334,6 +326,8 @@ evas_module_engine_list(void)
|
|||
const char *fname = fi->path + fi->name_start;
|
||||
|
||||
buf[0] = '\0';
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
if (run_in_tree)
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "%s/engines/%s/.libs",
|
||||
|
@ -341,6 +335,7 @@ evas_module_engine_list(void)
|
|||
if (!evas_file_path_exists(buf))
|
||||
buf[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (buf[0] == '\0')
|
||||
snprintf(buf, sizeof(buf), "%s/engines/%s/%s",
|
||||
|
@ -430,6 +425,8 @@ evas_module_find_type(Evas_Module_Type type, const char *name)
|
|||
}
|
||||
|
||||
buffer[0] = '\0';
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
if (run_in_tree)
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "%s/%s/%s/.libs/%s",
|
||||
|
@ -437,6 +434,7 @@ evas_module_find_type(Evas_Module_Type type, const char *name)
|
|||
if (!evas_file_path_exists(buffer))
|
||||
buffer[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (buffer[0] == '\0')
|
||||
snprintf(buffer, sizeof(buffer), "%s/%s/%s/%s/%s",
|
||||
|
|
|
@ -40,10 +40,13 @@ _extnbuf_new(const char *base, int id, Eina_Bool sys, int num,
|
|||
|
||||
if (b->am_owner)
|
||||
{
|
||||
const char *s;
|
||||
const char *s = NULL;
|
||||
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
s = getenv("XDG_RUNTIME_DIR");
|
||||
if (!s) s = getenv("TMPDIR");
|
||||
}
|
||||
if (!s) s = "/tmp";
|
||||
snprintf(file, sizeof(file), "%s/ee-lock-XXXXXX", s);
|
||||
b->lockfd = mkstemp(file);
|
||||
|
|
|
@ -1817,15 +1817,6 @@ static void
|
|||
_players_load(void)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
const char *homedir = getenv("HOME");
|
||||
|
||||
if (homedir)
|
||||
{
|
||||
eina_str_join(buf, sizeof(buf), '/',
|
||||
homedir,
|
||||
".emotion/generic_players/" MODULE_ARCH);
|
||||
_players_all_from(buf);
|
||||
}
|
||||
|
||||
eina_str_join(buf, sizeof(buf), '/',
|
||||
eina_prefix_lib_get(pfx),
|
||||
|
|
|
@ -1749,10 +1749,13 @@ _emotion_gstreamer_video_pipeline_parse(Emotion_Gstreamer_Video *ev,
|
|||
|
||||
/** NOTE: you need to set: GST_DEBUG_DUMP_DOT_DIR=/tmp EMOTION_ENGINE=gstreamer to save the $EMOTION_GSTREAMER_DOT file in '/tmp' */
|
||||
/** then call dot -Tpng -oemotion_pipeline.png /tmp/$TIMESTAMP-$EMOTION_GSTREAMER_DOT.dot */
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
if (getenv("EMOTION_GSTREAMER_DOT"))
|
||||
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(ev->pipeline),
|
||||
GST_DEBUG_GRAPH_SHOW_ALL,
|
||||
getenv("EMOTION_GSTREAMER_DOT"));
|
||||
}
|
||||
|
||||
if (!(res == GST_STATE_CHANGE_SUCCESS
|
||||
|| res == GST_STATE_CHANGE_NO_PREROLL))
|
||||
|
|
|
@ -866,7 +866,10 @@ _emotion_gstreamer_cancel(void *data, Ecore_Thread *thread)
|
|||
|
||||
ev->threads = eina_list_remove(ev->threads, thread);
|
||||
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
if (getenv("EMOTION_GSTREAMER_DOT")) GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(ev->pipeline), GST_DEBUG_GRAPH_SHOW_ALL, getenv("EMOTION_GSTREAMER_DOT"));
|
||||
}
|
||||
|
||||
if (ev->in == ev->out && ev->delete_me)
|
||||
ev->api->del(ev);
|
||||
|
@ -885,7 +888,10 @@ _emotion_gstreamer_end(void *data, Ecore_Thread *thread)
|
|||
ev->play_started = 1;
|
||||
}
|
||||
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
if (getenv("EMOTION_GSTREAMER_DOT")) GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(ev->pipeline), GST_DEBUG_GRAPH_SHOW_ALL, getenv("EMOTION_GSTREAMER_DOT"));
|
||||
}
|
||||
|
||||
if (ev->in == ev->out && ev->delete_me)
|
||||
ev->api->del(ev);
|
||||
|
@ -1427,7 +1433,10 @@ gstreamer_video_sink_new(Emotion_Gstreamer_Video *ev,
|
|||
|
||||
/** NOTE: you need to set: GST_DEBUG_DUMP_DOT_DIR=/tmp EMOTION_ENGINE=gstreamer to save the $EMOTION_GSTREAMER_DOT file in '/tmp' */
|
||||
/** then call dot -Tpng -oemotion_pipeline.png /tmp/$TIMESTAMP-$EMOTION_GSTREAMER_DOT.dot */
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
if (getenv("EMOTION_GSTREAMER_DOT")) GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(playbin), GST_DEBUG_GRAPH_SHOW_ALL, getenv("EMOTION_GSTREAMER_DOT"));
|
||||
}
|
||||
|
||||
return playbin;
|
||||
|
||||
|
|
|
@ -1542,10 +1542,13 @@ _emotion_gstreamer_video_pipeline_parse(Emotion_Gstreamer_Video *ev,
|
|||
|
||||
/** NOTE: you need to set: GST_DEBUG_DUMP_DOT_DIR=/tmp EMOTION_ENGINE=gstreamer to save the $EMOTION_GSTREAMER_DOT file in '/tmp' */
|
||||
/** then call dot -Tpng -oemotion_pipeline.png /tmp/$TIMESTAMP-$EMOTION_GSTREAMER_DOT.dot */
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
if (getenv("EMOTION_GSTREAMER_DOT"))
|
||||
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(ev->pipeline),
|
||||
GST_DEBUG_GRAPH_SHOW_ALL,
|
||||
getenv("EMOTION_GSTREAMER_DOT"));
|
||||
}
|
||||
|
||||
if (!(res == GST_STATE_CHANGE_SUCCESS
|
||||
|| res == GST_STATE_CHANGE_NO_PREROLL))
|
||||
|
@ -1626,7 +1629,10 @@ _emotion_gstreamer_cancel(void *data, Ecore_Thread *thread)
|
|||
|
||||
ev->threads = eina_list_remove(ev->threads, thread);
|
||||
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
if (getenv("EMOTION_GSTREAMER_DOT")) GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(ev->pipeline), GST_DEBUG_GRAPH_SHOW_ALL, getenv("EMOTION_GSTREAMER_DOT"));
|
||||
}
|
||||
|
||||
if (ev->in == ev->out && ev->delete_me)
|
||||
ev->api->del(ev);
|
||||
|
@ -1644,7 +1650,10 @@ _emotion_gstreamer_end(void *data, Ecore_Thread *thread)
|
|||
gst_element_set_state(ev->pipeline, GST_STATE_PLAYING);
|
||||
}
|
||||
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
if (getenv("EMOTION_GSTREAMER_DOT")) GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(ev->pipeline), GST_DEBUG_GRAPH_SHOW_ALL, getenv("EMOTION_GSTREAMER_DOT"));
|
||||
}
|
||||
|
||||
if (ev->in == ev->out && ev->delete_me)
|
||||
ev->api->del(ev);
|
||||
|
@ -1754,7 +1763,10 @@ _create_pipeline (Emotion_Gstreamer_Video *ev,
|
|||
|
||||
/** NOTE: you need to set: GST_DEBUG_DUMP_DOT_DIR=/tmp EMOTION_ENGINE=gstreamer to save the $EMOTION_GSTREAMER_DOT file in '/tmp' */
|
||||
/** then call dot -Tpng -oemotion_pipeline.png /tmp/$TIMESTAMP-$EMOTION_GSTREAMER_DOT.dot */
|
||||
if (getuid() == getuid())
|
||||
{
|
||||
if (getenv("EMOTION_GSTREAMER_DOT")) GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(playbin), GST_DEBUG_GRAPH_SHOW_ALL, getenv("EMOTION_GSTREAMER_DOT"));
|
||||
}
|
||||
|
||||
return playbin;
|
||||
|
||||
|
|
|
@ -456,10 +456,8 @@ fb_init(int vt EINA_UNUSED, int device)
|
|||
if (vt != 0) fb_setvt(vt);
|
||||
#endif
|
||||
|
||||
if ( getenv("EVAS_FB_DEV") )
|
||||
{
|
||||
if ((getuid() == getuid()) && (getenv("EVAS_FB_DEV")))
|
||||
fb = open(getenv("EVAS_FB_DEV"), O_RDWR);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(dev, "/dev/fb/%i", device);
|
||||
|
|
|
@ -48,6 +48,7 @@ evas_gl_common_file_cache_mkpath(const char *path)
|
|||
char ss[PATH_MAX];
|
||||
unsigned int i;
|
||||
|
||||
if (getuid() != getuid()) return EINA_FALSE;
|
||||
if (evas_gl_common_file_cache_is_dir(path)) return EINA_TRUE;
|
||||
|
||||
for (i = 0; path[i]; ss[i] = path[i], i++)
|
||||
|
@ -70,6 +71,7 @@ evas_gl_common_file_cache_dir_check(char *cache_dir, int num)
|
|||
char *home = NULL;
|
||||
char *subdir = ".cache/evas_gl_common_caches";
|
||||
|
||||
if (getuid() != getuid()) return 0;
|
||||
home = getenv("HOME");
|
||||
if ((!home) || (!home[0])) return 0;
|
||||
|
||||
|
|
|
@ -1527,7 +1527,8 @@ eng_output_flush(void *data, Evas_Render_Mode render_mode)
|
|||
// Save contents of the framebuffer to a file
|
||||
if (swap_buffer_debug_mode == -1)
|
||||
{
|
||||
if ((dname = getenv("EVAS_GL_SWAP_BUFFER_DEBUG_DIR")))
|
||||
if ((getuid() == getuid()) &&
|
||||
((dname = getenv("EVAS_GL_SWAP_BUFFER_DEBUG_DIR"))))
|
||||
{
|
||||
int stat;
|
||||
// Create a directory with 0775 permission
|
||||
|
|
Loading…
Reference in New Issue