summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-01-08 19:46:23 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-01-08 19:46:23 +0900
commitb95ef3801f9719a8f8ff731e25d66a8d1dd417cd (patch)
tree258548da51b18d5fde17915bdc36cba44effcf40 /src/lib
parent323f293ab538ffc7431f6598736963a834c4f880 (diff)
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.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ecore/ecore.c63
-rw-r--r--src/lib/ecore/ecore_exe.c2
-rw-r--r--src/lib/ecore_con/ecore_con_local.c49
-rw-r--r--src/lib/ecore_con/ecore_con_local_win32.c2
-rw-r--r--src/lib/ecore_con/ecore_con_socks.c17
-rw-r--r--src/lib/ecore_evas/ecore_evas_module.c45
-rw-r--r--src/lib/ecore_fb/ecore_fb.c2
-rw-r--r--src/lib/ecore_fb/ecore_fb_ts.c2
-rw-r--r--src/lib/ecore_imf/ecore_imf_module.c69
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_xdefaults.c16
-rw-r--r--src/lib/edje/edje_edit.c19
-rw-r--r--src/lib/edje/edje_module.c44
-rw-r--r--src/lib/eeze/eeze_sensor.c3
-rw-r--r--src/lib/efreet/efreet_base.c33
-rw-r--r--src/lib/efreet/efreet_menu.c5
-rw-r--r--src/lib/eina/eina_file_common.c8
-rw-r--r--src/lib/eina/eina_mempool.c11
-rw-r--r--src/lib/eina/eina_module.c2
-rw-r--r--src/lib/eina/eina_prefix.c17
-rw-r--r--src/lib/emotion/emotion_modules.c58
-rw-r--r--src/lib/ethumb/ethumb.c88
-rw-r--r--src/lib/evas/cserve2/evas_cs2_client.c32
-rw-r--r--src/lib/evas/file/evas_module.c56
23 files changed, 340 insertions, 303 deletions
diff --git a/src/lib/ecore/ecore.c b/src/lib/ecore/ecore.c
index 3477aca4ad..d81cc6b16f 100644
--- a/src/lib/ecore/ecore.c
+++ b/src/lib/ecore/ecore.c
@@ -130,55 +130,42 @@ static void
130ecore_system_modules_load(void) 130ecore_system_modules_load(void)
131{ 131{
132 char buf[PATH_MAX] = ""; 132 char buf[PATH_MAX] = "";
133 char *path;
134 133
135 if (getenv("EFL_RUN_IN_TREE")) 134 if (getuid() == getuid())
136 { 135 {
137 struct stat st; 136 if (getenv("EFL_RUN_IN_TREE"))
138 snprintf(buf, sizeof(buf), "%s/src/modules/ecore/system",
139 PACKAGE_BUILD_DIR);
140 if (stat(buf, &st) == 0)
141 { 137 {
142 const char *built_modules[] = { 138 struct stat st;
139 snprintf(buf, sizeof(buf), "%s/src/modules/ecore/system",
140 PACKAGE_BUILD_DIR);
141 if (stat(buf, &st) == 0)
142 {
143 const char *built_modules[] = {
143#ifdef HAVE_SYSTEMD 144#ifdef HAVE_SYSTEMD
144 "systemd", 145 "systemd",
145#endif 146#endif
146#ifdef HAVE_TIZEN_CONFIGURATION_MANAGER 147#ifdef HAVE_TIZEN_CONFIGURATION_MANAGER
147 "tizen", 148 "tizen",
148#endif 149#endif
149 NULL 150 NULL
150 }; 151 };
151 const char **itr; 152 const char **itr;
152 for (itr = built_modules; *itr != NULL; itr++) 153 for (itr = built_modules; *itr != NULL; itr++)
153 { 154 {
154 snprintf(buf, sizeof(buf), 155 snprintf(buf, sizeof(buf),
155 "%s/src/modules/ecore/system/%s/.libs", 156 "%s/src/modules/ecore/system/%s/.libs",
156 PACKAGE_BUILD_DIR, *itr); 157 PACKAGE_BUILD_DIR, *itr);
157 module_list = eina_module_list_get(module_list, buf, 158 module_list = eina_module_list_get(module_list, buf,
158 EINA_FALSE, NULL, NULL); 159 EINA_FALSE, NULL, NULL);
160 }
161
162 if (module_list)
163 eina_module_list_load(module_list);
164 return;
159 } 165 }
160
161 if (module_list)
162 eina_module_list_load(module_list);
163 return;
164 } 166 }
165 } 167 }
166 168
167 path = eina_module_environment_path_get("ECORE_MODULES_DIR",
168 "/ecore/system");
169 if (path)
170 {
171 module_list = eina_module_arch_list_get(module_list, path, MODULE_ARCH);
172 free(path);
173 }
174
175 path = eina_module_environment_path_get("HOME", "/.ecore/system");
176 if (path)
177 {
178 module_list = eina_module_arch_list_get(module_list, path, MODULE_ARCH);
179 free(path);
180 }
181
182 snprintf(buf, sizeof(buf), "%s/ecore/system", 169 snprintf(buf, sizeof(buf), "%s/ecore/system",
183 eina_prefix_lib_get(_ecore_pfx)); 170 eina_prefix_lib_get(_ecore_pfx));
184 module_list = eina_module_arch_list_get(module_list, buf, MODULE_ARCH); 171 module_list = eina_module_arch_list_get(module_list, buf, MODULE_ARCH);
diff --git a/src/lib/ecore/ecore_exe.c b/src/lib/ecore/ecore_exe.c
index dc6edefe6c..f13197216c 100644
--- a/src/lib/ecore/ecore_exe.c
+++ b/src/lib/ecore/ecore_exe.c
@@ -1609,7 +1609,7 @@ _ecore_exe_exec_it(const char *exe_cmd,
1609 { 1609 {
1610 if (!shell) /* Find users preferred shell. */ 1610 if (!shell) /* Find users preferred shell. */
1611 { 1611 {
1612 shell = getenv("SHELL"); 1612 if (getuid() == getuid()) shell = getenv("SHELL");
1613 if (!shell) 1613 if (!shell)
1614 shell = "/bin/sh"; 1614 shell = "/bin/sh";
1615 } 1615 }
diff --git a/src/lib/ecore_con/ecore_con_local.c b/src/lib/ecore_con/ecore_con_local.c
index 29863ccb72..6bd60d24df 100644
--- a/src/lib/ecore_con/ecore_con_local.c
+++ b/src/lib/ecore_con/ecore_con_local.c
@@ -12,6 +12,7 @@
12#include <sys/stat.h> 12#include <sys/stat.h>
13#include <sys/socket.h> 13#include <sys/socket.h>
14#include <sys/un.h> 14#include <sys/un.h>
15#include <pwd.h>
15 16
16#ifdef HAVE_SYSTEMD 17#ifdef HAVE_SYSTEMD
17# include <systemd/sd-daemon.h> 18# include <systemd/sd-daemon.h>
@@ -72,19 +73,33 @@ ecore_con_local_connect(Ecore_Con_Server *svr,
72 73
73 if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_USER) 74 if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_USER)
74 { 75 {
75 homedir = getenv("XDG_RUNTIME_DIR"); 76 if (getuid() == getuid())
76 if (!homedir)
77 { 77 {
78 homedir = getenv("HOME"); 78 homedir = getenv("XDG_RUNTIME_DIR");
79 if (!homedir) 79 if (!homedir)
80 { 80 {
81 homedir = getenv("TMP"); 81 homedir = getenv("HOME");
82 if (!homedir) homedir = "/tmp"; 82 if (!homedir)
83 {
84 homedir = getenv("TMP");
85 if (!homedir) homedir = "/tmp";
86 }
83 } 87 }
88 snprintf(buf, sizeof(buf), "%s/.ecore/%s/%i", homedir, svr->name,
89 svr->port);
90 }
91 else
92 {
93 struct passwd *pw = getpwent();
94
95 if ((!pw) || (!pw->pw_dir))
96 snprintf(buf, sizeof(buf), "/tmp/%s/%i", svr->name,
97 svr->port);
98 else
99 snprintf(buf, sizeof(buf), "%s/.ecore/%s/%i", pw->pw_dir, svr->name,
100 svr->port);
84 } 101 }
85 102
86 snprintf(buf, sizeof(buf), "%s/.ecore/%s/%i", homedir, svr->name,
87 svr->port);
88 } 103 }
89 else if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_SYSTEM) 104 else if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_SYSTEM)
90 { 105 {
@@ -203,16 +218,26 @@ ecore_con_local_listen(
203 218
204 if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_USER) 219 if ((svr->type & ECORE_CON_TYPE) == ECORE_CON_LOCAL_USER)
205 { 220 {
206 homedir = getenv("XDG_RUNTIME_DIR"); 221 if (getuid() == getuid())
207 if (!homedir)
208 { 222 {
209 homedir = getenv("HOME"); 223 homedir = getenv("XDG_RUNTIME_DIR");
210 if (!homedir) 224 if (!homedir)
211 { 225 {
212 homedir = getenv("TMP"); 226 homedir = getenv("HOME");
213 if (!homedir) homedir = "/tmp"; 227 if (!homedir)
228 {
229 homedir = getenv("TMP");
230 if (!homedir) homedir = "/tmp";
231 }
214 } 232 }
215 } 233 }
234 else
235 {
236 struct passwd *pw = getpwent();
237
238 if ((!pw) || (!pw->pw_dir)) homedir = "/tmp";
239 else homedir = pw->pw_dir;
240 }
216 241
217 mask = S_IRUSR | S_IWUSR | S_IXUSR; 242 mask = S_IRUSR | S_IWUSR | S_IXUSR;
218 snprintf(buf, sizeof(buf), "%s/.ecore", homedir); 243 snprintf(buf, sizeof(buf), "%s/.ecore", homedir);
diff --git a/src/lib/ecore_con/ecore_con_local_win32.c b/src/lib/ecore_con/ecore_con_local_win32.c
index 0eed03e875..670105ae31 100644
--- a/src/lib/ecore_con/ecore_con_local_win32.c
+++ b/src/lib/ecore_con/ecore_con_local_win32.c
@@ -414,7 +414,7 @@ ecore_con_local_listen(Ecore_Con_Server *svr)
414 { 414 {
415 const char *computername; 415 const char *computername;
416 416
417 computername = getenv("CoMPUTERNAME"); 417 computername = getenv("COMPUTERNAME");
418 snprintf(buf, sizeof(buf), "\\\\%s\\pipe\\%s", computername, svr->name); 418 snprintf(buf, sizeof(buf), "\\\\%s\\pipe\\%s", computername, svr->name);
419 } 419 }
420 420
diff --git a/src/lib/ecore_con/ecore_con_socks.c b/src/lib/ecore_con/ecore_con_socks.c
index 624ec780f5..379079b165 100644
--- a/src/lib/ecore_con/ecore_con_socks.c
+++ b/src/lib/ecore_con/ecore_con_socks.c
@@ -585,7 +585,7 @@ ecore_con_socks_dns_cb(const char *canonname EINA_UNUSED, const char *ip, struct
585void 585void
586ecore_con_socks_init(void) 586ecore_con_socks_init(void)
587{ 587{
588 const char *socks; 588 const char *socks = NULL;
589 char *h, *p, *l, *u = NULL; 589 char *h, *p, *l, *u = NULL;
590 char buf[512]; 590 char buf[512];
591 int port, lookup = 0; 591 int port, lookup = 0;
@@ -596,13 +596,16 @@ ecore_con_socks_init(void)
596 unsigned char addr6[sizeof(struct in6_addr)]; 596 unsigned char addr6[sizeof(struct in6_addr)];
597#endif 597#endif
598 598
599 /* ECORE_CON_SOCKS_V4=[user@]host-port:[1|0] */ 599 if (getuid() == getuid())
600 socks = getenv("ECORE_CON_SOCKS_V4");
601 if (!socks)
602 { 600 {
603 /* ECORE_CON_SOCKS_V5=[user@]host-port:[1|0] */ 601 /* ECORE_CON_SOCKS_V4=[user@]host-port:[1|0] */
604 socks = getenv("ECORE_CON_SOCKS_V5"); 602 socks = getenv("ECORE_CON_SOCKS_V4");
605 v5 = EINA_TRUE; 603 if (!socks)
604 {
605 /* ECORE_CON_SOCKS_V5=[user@]host-port:[1|0] */
606 socks = getenv("ECORE_CON_SOCKS_V5");
607 v5 = EINA_TRUE;
608 }
606 } 609 }
607 if ((!socks) || (!socks[0]) || (strlen(socks) + 1 > 512)) return; 610 if ((!socks) || (!socks[0]) || (strlen(socks) + 1 > 512)) return;
608 memcpy(buf, socks, strlen(socks) + 1); 611 memcpy(buf, socks, strlen(socks) + 1);
diff --git a/src/lib/ecore_evas/ecore_evas_module.c b/src/lib/ecore_evas/ecore_evas_module.c
index 90b12478ab..c98f5ad511 100644
--- a/src/lib/ecore_evas/ecore_evas_module.c
+++ b/src/lib/ecore_evas/ecore_evas_module.c
@@ -7,6 +7,7 @@
7 7
8#include "Ecore_Evas.h" 8#include "Ecore_Evas.h"
9#include "ecore_evas_private.h" 9#include "ecore_evas_private.h"
10#include <unistd.h>
10 11
11static Eina_Hash *_registered_engines = NULL; 12static Eina_Hash *_registered_engines = NULL;
12static Eina_List *_engines_paths = NULL; 13static Eina_List *_engines_paths = NULL;
@@ -38,13 +39,16 @@ _ecore_evas_engine_load(const char *engine)
38 { 39 {
39 char tmp[PATH_MAX] = ""; 40 char tmp[PATH_MAX] = "";
40 41
41 if (run_in_tree) 42 if (getuid() == getuid())
42 { 43 {
43 struct stat st; 44 if (run_in_tree)
44 snprintf(tmp, sizeof(tmp), "%s/%s/.libs/%s", 45 {
45 path, engine, ECORE_EVAS_ENGINE_NAME); 46 struct stat st;
46 if (stat(tmp, &st) != 0) 47 snprintf(tmp, sizeof(tmp), "%s/%s/.libs/%s",
47 tmp[0] = '\0'; 48 path, engine, ECORE_EVAS_ENGINE_NAME);
49 if (stat(tmp, &st) != 0)
50 tmp[0] = '\0';
51 }
48 } 52 }
49 53
50 if (tmp[0] == '\0') 54 if (tmp[0] == '\0')
@@ -69,7 +73,7 @@ _ecore_evas_engine_load(const char *engine)
69void 73void
70_ecore_evas_engine_init(void) 74_ecore_evas_engine_init(void)
71{ 75{
72 char *paths[4] = { NULL, NULL, NULL, NULL }; 76 char *paths[2] = { NULL, NULL };
73 unsigned int i; 77 unsigned int i;
74 unsigned int j; 78 unsigned int j;
75 79
@@ -77,26 +81,25 @@ _ecore_evas_engine_init(void)
77// _registered_engines = eina_hash_string_small_new(EINA_FREE_CB(eina_module_free)); 81// _registered_engines = eina_hash_string_small_new(EINA_FREE_CB(eina_module_free));
78 _registered_engines = eina_hash_string_small_new(NULL); 82 _registered_engines = eina_hash_string_small_new(NULL);
79 83
80 if (getenv("EFL_RUN_IN_TREE")) 84 if (getuid() == getuid())
81 { 85 {
82 struct stat st; 86 if (getenv("EFL_RUN_IN_TREE"))
83 const char mp[] = PACKAGE_BUILD_DIR"/src/modules/ecore_evas/engines/";
84 if (stat(mp, &st) == 0)
85 { 87 {
86 _engines_paths = eina_list_append(_engines_paths, strdup(mp)); 88 struct stat st;
87 return; 89 const char mp[] = PACKAGE_BUILD_DIR"/src/modules/ecore_evas/engines/";
90 if (stat(mp, &st) == 0)
91 {
92 _engines_paths = eina_list_append(_engines_paths, strdup(mp));
93 return;
94 }
88 } 95 }
89 } 96 }
90 97
91 /* 1. ~/.ecore_evas/modules/ */ 98 /* 1. libecore_evas.so/../ecore_evas/engines/ */
92 paths[0] = eina_module_environment_path_get("HOME", "/.ecore_evas/engines"); 99 paths[0] = eina_module_symbol_path_get(_ecore_evas_engine_init, "/ecore_evas/engines");
93 /* 2. $(ECORE_ENGINE_DIR)/ecore_evas/modules/ */ 100 /* 2. PREFIX/ecore_evas/engines/ */
94 paths[1] = eina_module_environment_path_get("ECORE_EVAS_ENGINES_DIR", "/ecore_evas/engines");
95 /* 3. libecore_evas.so/../ecore_evas/engines/ */
96 paths[2] = eina_module_symbol_path_get(_ecore_evas_engine_init, "/ecore_evas/engines");
97 /* 4. PREFIX/ecore_evas/engines/ */
98#ifndef _MSC_VER 101#ifndef _MSC_VER
99 paths[3] = strdup(PACKAGE_LIB_DIR "/ecore_evas/engines"); 102 paths[1] = strdup(PACKAGE_LIB_DIR "/ecore_evas/engines");
100#endif 103#endif
101 104
102 for (j = 0; j < ((sizeof (paths) / sizeof (char*)) - 1); ++j) 105 for (j = 0; j < ((sizeof (paths) / sizeof (char*)) - 1); ++j)
diff --git a/src/lib/ecore_fb/ecore_fb.c b/src/lib/ecore_fb/ecore_fb.c
index 5e16f660c2..3bce09de0b 100644
--- a/src/lib/ecore_fb/ecore_fb.c
+++ b/src/lib/ecore_fb/ecore_fb.c
@@ -108,7 +108,7 @@ _ecore_fb_size_get(int *w, int *h)
108 struct fb_var_screeninfo fb_var; 108 struct fb_var_screeninfo fb_var;
109 int fb; 109 int fb;
110 110
111 if (getenv("EVAS_FB_DEV")) 111 if ((getuid() == getuid()) && (getenv("EVAS_FB_DEV")))
112 fb = open(getenv("EVAS_FB_DEV"), O_RDWR); 112 fb = open(getenv("EVAS_FB_DEV"), O_RDWR);
113 else 113 else
114 { 114 {
diff --git a/src/lib/ecore_fb/ecore_fb_ts.c b/src/lib/ecore_fb/ecore_fb_ts.c
index 93ac04a0f2..3f699c05c9 100644
--- a/src/lib/ecore_fb/ecore_fb_ts.c
+++ b/src/lib/ecore_fb/ecore_fb_ts.c
@@ -81,7 +81,7 @@ ecore_fb_ts_init(void)
81{ 81{
82#ifdef HAVE_TSLIB 82#ifdef HAVE_TSLIB
83 char *tslib_tsdevice = NULL; 83 char *tslib_tsdevice = NULL;
84 if ( (tslib_tsdevice = getenv("TSLIB_TSDEVICE")) ) 84 if ((getuid() == getuid()) && ((tslib_tsdevice = getenv("TSLIB_TSDEVICE"))))
85 { 85 {
86 printf( "ECORE_FB: TSLIB_TSDEVICE = '%s'\n", tslib_tsdevice ); 86 printf( "ECORE_FB: TSLIB_TSDEVICE = '%s'\n", tslib_tsdevice );
87 _ecore_fb_tslib_tsdev = ts_open( tslib_tsdevice, 1 ); /* 1 = nonblocking, 0 = blocking */ 87 _ecore_fb_tslib_tsdev = ts_open( tslib_tsdevice, 1 ); /* 1 = nonblocking, 0 = blocking */
diff --git a/src/lib/ecore_imf/ecore_imf_module.c b/src/lib/ecore_imf/ecore_imf_module.c
index c8e6819898..3005daa611 100644
--- a/src/lib/ecore_imf/ecore_imf_module.c
+++ b/src/lib/ecore_imf/ecore_imf_module.c
@@ -6,6 +6,7 @@
6#include <stdlib.h> 6#include <stdlib.h>
7#include <string.h> 7#include <string.h>
8#include <limits.h> 8#include <limits.h>
9#include <unistd.h>
9 10
10#include <Ecore.h> 11#include <Ecore.h>
11#include <ecore_private.h> 12#include <ecore_private.h>
@@ -30,66 +31,52 @@ void
30ecore_imf_module_init(void) 31ecore_imf_module_init(void)
31{ 32{
32 char buf[PATH_MAX] = ""; 33 char buf[PATH_MAX] = "";
33 char *path;
34 34
35 pfx = eina_prefix_new(NULL, ecore_imf_init, 35 pfx = eina_prefix_new(NULL, ecore_imf_init,
36 "ECORE_IMF", "ecore_imf", "checkme", 36 "ECORE_IMF", "ecore_imf", "checkme",
37 PACKAGE_BIN_DIR, PACKAGE_LIB_DIR, 37 PACKAGE_BIN_DIR, PACKAGE_LIB_DIR,
38 PACKAGE_DATA_DIR, PACKAGE_DATA_DIR); 38 PACKAGE_DATA_DIR, PACKAGE_DATA_DIR);
39 39 if (getuid() == getuid())
40 if (getenv("EFL_RUN_IN_TREE"))
41 { 40 {
42 struct stat st; 41 if (getenv("EFL_RUN_IN_TREE"))
43 snprintf(buf, sizeof(buf), "%s/src/modules/ecore_imf",
44 PACKAGE_BUILD_DIR);
45 if (stat(buf, &st) == 0)
46 { 42 {
47 const char *built_modules[] = { 43 struct stat st;
44 snprintf(buf, sizeof(buf), "%s/src/modules/ecore_imf",
45 PACKAGE_BUILD_DIR);
46 if (stat(buf, &st) == 0)
47 {
48 const char *built_modules[] = {
48#ifdef ENABLE_XIM 49#ifdef ENABLE_XIM
49 "xim", 50 "xim",
50#endif 51#endif
51#ifdef BUILD_ECORE_IMF_IBUS 52#ifdef BUILD_ECORE_IMF_IBUS
52 "ibus", 53 "ibus",
53#endif 54#endif
54#ifdef BUILD_ECORE_IMF_SCIM 55#ifdef BUILD_ECORE_IMF_SCIM
55 "scim", 56 "scim",
56#endif 57#endif
57#ifdef BUILD_ECORE_IMF_WAYLAND 58#ifdef BUILD_ECORE_IMF_WAYLAND
58 "wayland", 59 "wayland",
59#endif 60#endif
60 NULL 61 NULL
61 }; 62 };
62 const char **itr; 63 const char **itr;
63 for (itr = built_modules; *itr != NULL; itr++) 64 for (itr = built_modules; *itr != NULL; itr++)
64 { 65 {
65 snprintf(buf, sizeof(buf), 66 snprintf(buf, sizeof(buf),
66 "%s/src/modules/ecore_imf/%s/.libs", 67 "%s/src/modules/ecore_imf/%s/.libs",
67 PACKAGE_BUILD_DIR, *itr); 68 PACKAGE_BUILD_DIR, *itr);
68 module_list = eina_module_list_get(module_list, buf, 69 module_list = eina_module_list_get(module_list, buf,
69 EINA_FALSE, NULL, NULL); 70 EINA_FALSE, NULL, NULL);
71 }
72
73 if (module_list)
74 eina_module_list_load(module_list);
75 return;
70 } 76 }
71
72 if (module_list)
73 eina_module_list_load(module_list);
74 return;
75 } 77 }
76 } 78 }
77 79
78 path = eina_module_environment_path_get("ECORE_IMF_MODULES_DIR",
79 "/ecore_imf/modules");
80 if (path)
81 {
82 module_list = eina_module_arch_list_get(module_list, path, MODULE_ARCH);
83 free(path);
84 }
85
86 path = eina_module_environment_path_get("HOME", "/.ecore_imf");
87 if (path)
88 {
89 module_list = eina_module_arch_list_get(module_list, path, MODULE_ARCH);
90 free(path);
91 }
92
93 snprintf(buf, sizeof(buf), "%s/ecore_imf/modules", eina_prefix_lib_get(pfx)); 80 snprintf(buf, sizeof(buf), "%s/ecore_imf/modules", eina_prefix_lib_get(pfx));
94 module_list = eina_module_arch_list_get(module_list, buf, MODULE_ARCH); 81 module_list = eina_module_arch_list_get(module_list, buf, MODULE_ARCH);
95 82
diff --git a/src/lib/ecore_x/xcb/ecore_xcb_xdefaults.c b/src/lib/ecore_x/xcb/ecore_xcb_xdefaults.c
index e0e56102e2..2a89c59e07 100644
--- a/src/lib/ecore_x/xcb/ecore_xcb_xdefaults.c
+++ b/src/lib/ecore_x/xcb/ecore_xcb_xdefaults.c
@@ -1,5 +1,7 @@
1#include "ecore_xcb_private.h" 1#include "ecore_xcb_private.h"
2#include <fnmatch.h> 2#include <fnmatch.h>
3#include <sys/types.h>
4#include <pwd.h>
3 5
4/* local function prototypes */ 6/* local function prototypes */
5static Eina_Bool _ecore_xcb_xdefaults_glob_match(const char *str, 7static Eina_Bool _ecore_xcb_xdefaults_glob_match(const char *str,
@@ -16,7 +18,19 @@ _ecore_xcb_xdefaults_init(void)
16 18
17 LOGFN(__FILE__, __LINE__, __FUNCTION__); 19 LOGFN(__FILE__, __LINE__, __FUNCTION__);
18 20
19 snprintf(buff, sizeof(buff), "%s/.Xdefaults", getenv("HOME")); 21 if (getuid() == getuid())
22 {
23 if (getenv("HOME"))
24 snprintf(buff, sizeof(buff), "%s/.Xdefaults", getenv("HOME"));
25 else return;
26 }
27 else
28 {
29 struct passwd *pw = getpwent();
30
31 if ((!pw) || (!pw->pw_dir)) return;
32 snprintf(buff, sizeof(buff), "%s/.Xdefaults", pw->pw_dir);
33 }
20 if ((_ecore_xcb_xdefaults_file = eina_file_open(buff, EINA_FALSE))) 34 if ((_ecore_xcb_xdefaults_file = eina_file_open(buff, EINA_FALSE)))
21 { 35 {
22 eina_mmap_safety_enabled_set(EINA_TRUE); 36 eina_mmap_safety_enabled_set(EINA_TRUE);
diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c
index 9a6b6b0192..5e686cb287 100644
--- a/src/lib/edje/edje_edit.c
+++ b/src/lib/edje/edje_edit.c
@@ -6808,15 +6808,18 @@ _edje_edit_embryo_rebuild(Edje_Edit *eed)
6808#else 6808#else
6809# define BIN_EXT 6809# define BIN_EXT
6810#endif 6810#endif
6811 if (getenv("EFL_RUN_IN_TREE")) 6811 if (getuid() == getuid())
6812 { 6812 {
6813 snprintf(embryo_cc_path, sizeof(embryo_cc_path), 6813 if (getenv("EFL_RUN_IN_TREE"))
6814 "%s/src/bin/embryo/embryo_cc" BIN_EXT, 6814 {
6815 PACKAGE_BUILD_DIR); 6815 snprintf(embryo_cc_path, sizeof(embryo_cc_path),
6816 snprintf(inc_path, sizeof(inc_path), 6816 "%s/src/bin/embryo/embryo_cc" BIN_EXT,
6817 "%s/data/edje/include", PACKAGE_BUILD_DIR); 6817 PACKAGE_BUILD_DIR);
6818 if (!ecore_file_exists(embryo_cc_path)) 6818 snprintf(inc_path, sizeof(inc_path),
6819 embryo_cc_path[0] = '\0'; 6819 "%s/data/edje/include", PACKAGE_BUILD_DIR);
6820 if (!ecore_file_exists(embryo_cc_path))
6821 embryo_cc_path[0] = '\0';
6822 }
6820 } 6823 }
6821 6824
6822 if (embryo_cc_path[0] == '\0') 6825 if (embryo_cc_path[0] == '\0')
diff --git a/src/lib/edje/edje_module.c b/src/lib/edje/edje_module.c
index 115329c611..52bd47dd28 100644
--- a/src/lib/edje/edje_module.c
+++ b/src/lib/edje/edje_module.c
@@ -37,13 +37,16 @@ _edje_module_handle_load(const char *module)
37 { 37 {
38 char tmp[PATH_MAX] = ""; 38 char tmp[PATH_MAX] = "";
39 39
40 if (run_in_tree) 40 if (getuid() == getuid())
41 { 41 {
42 struct stat st; 42 if (run_in_tree)
43 snprintf(tmp, sizeof(tmp), "%s/%s/.libs/%s", 43 {
44 path, module, EDJE_MODULE_NAME); 44 struct stat st;
45 if (stat(tmp, &st) != 0) 45 snprintf(tmp, sizeof(tmp), "%s/%s/.libs/%s",
46 tmp[0] = '\0'; 46 path, module, EDJE_MODULE_NAME);
47 if (stat(tmp, &st) != 0)
48 tmp[0] = '\0';
49 }
47 } 50 }
48 51
49 if (tmp[0] == '\0') 52 if (tmp[0] == '\0')
@@ -68,32 +71,31 @@ _edje_module_handle_load(const char *module)
68void 71void
69_edje_module_init(void) 72_edje_module_init(void)
70{ 73{
71 char *paths[4] = { NULL, NULL, NULL, NULL }; 74 char *paths[2] = { NULL, NULL };
72 unsigned int i; 75 unsigned int i;
73 unsigned int j; 76 unsigned int j;
74 77
75 _registered_modules = eina_hash_string_small_new(EINA_FREE_CB(eina_module_free)); 78 _registered_modules = eina_hash_string_small_new(EINA_FREE_CB(eina_module_free));
76 79
77 if (getenv("EFL_RUN_IN_TREE")) 80 if (getuid() == getuid())
78 { 81 {
79 struct stat st; 82 if (getenv("EFL_RUN_IN_TREE"))
80 const char mp[] = PACKAGE_BUILD_DIR"/src/modules/edje";
81 if (stat(mp, &st) == 0)
82 { 83 {
83 _modules_paths = eina_list_append(_modules_paths, strdup(mp)); 84 struct stat st;
84 return; 85 const char mp[] = PACKAGE_BUILD_DIR"/src/modules/edje";
86 if (stat(mp, &st) == 0)
87 {
88 _modules_paths = eina_list_append(_modules_paths, strdup(mp));
89 return;
90 }
85 } 91 }
86 } 92 }
87 93
88 /* 1. ~/.edje/modules/ */ 94 /* 1. libedje.so/../edje/modules/ */
89 paths[0] = eina_module_environment_path_get("HOME", "/.edje/modules"); 95 paths[0] = eina_module_symbol_path_get(_edje_module_init, "/edje/modules");
90 /* 2. $(EDJE_MODULE_DIR)/edje/modules/ */ 96 /* 2. PREFIX/edje/modules/ */
91 paths[1] = eina_module_environment_path_get("EDJE_MODULES_DIR", "/edje/modules");
92 /* 3. libedje.so/../edje/modules/ */
93 paths[2] = eina_module_symbol_path_get(_edje_module_init, "/edje/modules");
94 /* 4. PREFIX/edje/modules/ */
95#ifndef _MSC_VER 97#ifndef _MSC_VER
96 paths[3] = strdup(PACKAGE_LIB_DIR "/edje/modules"); 98 paths[1] = strdup(PACKAGE_LIB_DIR "/edje/modules");
97#endif 99#endif
98 100
99 for (j = 0; j < ((sizeof (paths) / sizeof (char*)) - 1); ++j) 101 for (j = 0; j < ((sizeof (paths) / sizeof (char*)) - 1); ++j)
diff --git a/src/lib/eeze/eeze_sensor.c b/src/lib/eeze/eeze_sensor.c
index 30c5d3c8e2..831fb12df2 100644
--- a/src/lib/eeze/eeze_sensor.c
+++ b/src/lib/eeze/eeze_sensor.c
@@ -4,6 +4,7 @@
4 4
5#include <stdio.h> 5#include <stdio.h>
6#include <stdlib.h> 6#include <stdlib.h>
7#include <unistd.h>
7#include <Eina.h> 8#include <Eina.h>
8#include <Ecore.h> 9#include <Ecore.h>
9#include <Eeze_Sensor.h> 10#include <Eeze_Sensor.h>
@@ -81,7 +82,7 @@ eeze_sensor_modules_load(void)
81 * is one of these items. We do load the modules from the builddir if the 82 * is one of these items. We do load the modules from the builddir if the
82 * environment is set. Normal case is to use installed modules from system 83 * environment is set. Normal case is to use installed modules from system
83 */ 84 */
84 if (getenv("EFL_RUN_IN_TREE")) 85 if ((getuid() == getuid()) && (getenv("EFL_RUN_IN_TREE")))
85 { 86 {
86 const char **itr; 87 const char **itr;
87 88
diff --git a/src/lib/efreet/efreet_base.c b/src/lib/efreet/efreet_base.c
index 1c467d27b3..5836d95a5d 100644
--- a/src/lib/efreet/efreet_base.c
+++ b/src/lib/efreet/efreet_base.c
@@ -4,6 +4,8 @@
4 4
5#include <unistd.h> 5#include <unistd.h>
6#include <ctype.h> 6#include <ctype.h>
7#include <sys/types.h>
8#include <pwd.h>
7 9
8#ifdef _WIN32 10#ifdef _WIN32
9# include <winsock2.h> 11# include <winsock2.h>
@@ -276,10 +278,20 @@ efreet_dirs_init(void)
276 struct stat st; 278 struct stat st;
277 279
278 /* efreet_home_dir */ 280 /* efreet_home_dir */
279 efreet_home_dir = getenv("HOME"); 281 if (getuid() == getuid())
282 efreet_home_dir = getenv("HOME");
283 else
284 {
285 struct passwd *pw = getpwent();
286
287 if ((pw) && (pw->pw_dir)) efreet_home_dir = pw->pw_dir;
288 }
280#ifdef _WIN32 289#ifdef _WIN32
281 if (!efreet_home_dir || efreet_home_dir[0] == '\0') 290 if (!efreet_home_dir || efreet_home_dir[0] == '\0')
282 efreet_home_dir = getenv("USERPROFILE"); 291 {
292 if (getuid() == getuid())
293 efreet_home_dir = getenv("USERPROFILE");
294 }
283#endif 295#endif
284 if (!efreet_home_dir || efreet_home_dir[0] == '\0') 296 if (!efreet_home_dir || efreet_home_dir[0] == '\0')
285 efreet_home_dir = "/tmp"; 297 efreet_home_dir = "/tmp";
@@ -303,7 +315,7 @@ efreet_dirs_init(void)
303 xdg_config_dirs = efreet_dirs_get("XDG_CONFIG_DIRS", "/etc/xdg"); 315 xdg_config_dirs = efreet_dirs_get("XDG_CONFIG_DIRS", "/etc/xdg");
304 316
305 /* xdg_runtime_dir */ 317 /* xdg_runtime_dir */
306 xdg_runtime_dir = getenv("XDG_RUNTIME_DIR"); 318 if (getuid() == getuid()) xdg_runtime_dir = getenv("XDG_RUNTIME_DIR");
307 if (!xdg_runtime_dir) 319 if (!xdg_runtime_dir)
308 { 320 {
309 snprintf(buf, sizeof(buf), "/tmp/xdg-XXXXXX"); 321 snprintf(buf, sizeof(buf), "/tmp/xdg-XXXXXX");
@@ -375,10 +387,10 @@ efreet_dirs_init(void)
375static const char * 387static const char *
376efreet_dir_get(const char *key, const char *fallback) 388efreet_dir_get(const char *key, const char *fallback)
377{ 389{
378 char *dir; 390 char *dir = NULL;
379 const char *t; 391 const char *t;
380 392
381 dir = getenv(key); 393 if (getuid() == getuid()) dir = getenv(key);
382 if (!dir || dir[0] == '\0') 394 if (!dir || dir[0] == '\0')
383 { 395 {
384 int len; 396 int len;
@@ -409,11 +421,11 @@ static Eina_List *
409efreet_dirs_get(const char *key, const char *fallback) 421efreet_dirs_get(const char *key, const char *fallback)
410{ 422{
411 Eina_List *dirs = NULL; 423 Eina_List *dirs = NULL;
412 const char *path; 424 const char *path = NULL;
413 char *s, *p; 425 char *s, *p;
414 size_t len; 426 size_t len;
415 427
416 path = getenv(key); 428 if (getuid() == getuid()) path = getenv(key);
417 if (!path || (path[0] == '\0')) path = fallback; 429 if (!path || (path[0] == '\0')) path = fallback;
418 430
419 if (!path) return dirs; 431 if (!path) return dirs;
@@ -484,8 +496,11 @@ efreet_env_expand(const char *in)
484 { 496 {
485 memcpy(env, e1, len); 497 memcpy(env, e1, len);
486 env[len] = 0; 498 env[len] = 0;
487 val = getenv(env); 499 if (getuid() == getuid())
488 if (val) eina_strbuf_append(sb, val); 500 {
501 val = getenv(env);
502 if (val) eina_strbuf_append(sb, val);
503 }
489 } 504 }
490 e1 = NULL; 505 e1 = NULL;
491 eina_strbuf_append_char(sb, *p); 506 eina_strbuf_append_char(sb, *p);
diff --git a/src/lib/efreet/efreet_menu.c b/src/lib/efreet/efreet_menu.c
index dd56ad6033..1af99f1b0a 100644
--- a/src/lib/efreet/efreet_menu.c
+++ b/src/lib/efreet/efreet_menu.c
@@ -399,8 +399,9 @@ efreet_menu_init(void)
399 return 0; 399 return 0;
400 } 400 }
401 401
402 efreet_menu_prefix = getenv("XDG_MENU_PREFIX"); 402 if (getuid() == getuid())
403 if (!efreet_menu_prefix) efreet_menu_prefix = ""; 403 efreet_menu_prefix = getenv("XDG_MENU_PREFIX");
404 if (!efreet_menu_prefix) efreet_menu_prefix = "";
404 405
405 efreet_menu_handle_cbs = eina_hash_string_superfast_new(NULL); 406 efreet_menu_handle_cbs = eina_hash_string_superfast_new(NULL);
406 efreet_menu_filter_cbs = eina_hash_string_superfast_new(NULL); 407 efreet_menu_filter_cbs = eina_hash_string_superfast_new(NULL);
diff --git a/src/lib/eina/eina_file_common.c b/src/lib/eina/eina_file_common.c
index 47215079cd..a0389943a9 100644
--- a/src/lib/eina/eina_file_common.c
+++ b/src/lib/eina/eina_file_common.c
@@ -897,12 +897,12 @@ EAPI int
897eina_file_mkstemp(const char *templatename, Eina_Tmpstr **path) 897eina_file_mkstemp(const char *templatename, Eina_Tmpstr **path)
898{ 898{
899 char buffer[PATH_MAX]; 899 char buffer[PATH_MAX];
900 const char *tmpdir; 900 const char *tmpdir = NULL;
901 int fd; 901 int fd;
902 mode_t old_umask; 902 mode_t old_umask;
903 903
904#ifndef HAVE_EVIL 904#ifndef HAVE_EVIL
905 tmpdir = getenv("TMPDIR"); 905 if (getuid() == getuid()) tmpdir = getenv("TMPDIR");
906 if (!tmpdir) tmpdir = "/tmp"; 906 if (!tmpdir) tmpdir = "/tmp";
907#else 907#else
908 tmpdir = (char *)evil_tmpdir_get(); 908 tmpdir = (char *)evil_tmpdir_get();
@@ -929,11 +929,11 @@ EAPI Eina_Bool
929eina_file_mkdtemp(const char *templatename, Eina_Tmpstr **path) 929eina_file_mkdtemp(const char *templatename, Eina_Tmpstr **path)
930{ 930{
931 char buffer[PATH_MAX]; 931 char buffer[PATH_MAX];
932 const char *tmpdir; 932 const char *tmpdir = NULL;
933 char *tmpdirname; 933 char *tmpdirname;
934 934
935#ifndef HAVE_EVIL 935#ifndef HAVE_EVIL
936 tmpdir = getenv("TMPDIR"); 936 if (getuid() == getuid()) tmpdir = getenv("TMPDIR");
937 if (!tmpdir) tmpdir = "/tmp"; 937 if (!tmpdir) tmpdir = "/tmp";
938#else 938#else
939 tmpdir = (char *)evil_tmpdir_get(); 939 tmpdir = (char *)evil_tmpdir_get();
diff --git a/src/lib/eina/eina_mempool.c b/src/lib/eina/eina_mempool.c
index 29fc829492..536e6c822b 100644
--- a/src/lib/eina/eina_mempool.c
+++ b/src/lib/eina/eina_mempool.c
@@ -176,17 +176,6 @@ eina_mempool_init(void)
176 PACKAGE_LIB_DIR "/eina/modules/mp", 176 PACKAGE_LIB_DIR "/eina/modules/mp",
177 MODULE_ARCH); 177 MODULE_ARCH);
178 178
179 path = eina_module_environment_path_get("HOME", "/.eina/mp/modules/mp");
180 _modules = eina_module_arch_list_get(_modules, path, MODULE_ARCH);
181 if (path)
182 free(path);
183
184 path = eina_module_environment_path_get("EINA_MODULES_MEMPOOL_DIR",
185 "/eina/modules/mp");
186 _modules = eina_module_arch_list_get(_modules, path, MODULE_ARCH);
187 if (path)
188 free(path);
189
190 path = eina_module_symbol_path_get((const void *)eina_init, 179 path = eina_module_symbol_path_get((const void *)eina_init,
191 "/eina/modules/mp"); 180 "/eina/modules/mp");
192 _modules = eina_module_arch_list_get(_modules, path, MODULE_ARCH); 181 _modules = eina_module_arch_list_get(_modules, path, MODULE_ARCH);
diff --git a/src/lib/eina/eina_module.c b/src/lib/eina/eina_module.c
index 5a30e26452..8c81873dc6 100644
--- a/src/lib/eina/eina_module.c
+++ b/src/lib/eina/eina_module.c
@@ -25,6 +25,7 @@
25#include <sys/types.h> 25#include <sys/types.h>
26#include <string.h> 26#include <string.h>
27#include <libgen.h> 27#include <libgen.h>
28#include <unistd.h>
28 29
29#ifdef HAVE_DLOPEN 30#ifdef HAVE_DLOPEN
30# include <dlfcn.h> 31# include <dlfcn.h>
@@ -430,6 +431,7 @@ EAPI char *eina_module_environment_path_get(const char *env,
430 const char *env_dir; 431 const char *env_dir;
431 432
432 EINA_SAFETY_ON_NULL_RETURN_VAL(env, NULL); 433 EINA_SAFETY_ON_NULL_RETURN_VAL(env, NULL);
434 if (getuid() != getuid()) return NULL; // if setuid dont use dangerous env
433 435
434 env_dir = getenv(env); 436 env_dir = getenv(env);
435 if (env_dir) 437 if (env_dir)
diff --git a/src/lib/eina/eina_prefix.c b/src/lib/eina/eina_prefix.c
index 712fa0e26b..3e8709f335 100644
--- a/src/lib/eina/eina_prefix.c
+++ b/src/lib/eina/eina_prefix.c
@@ -335,6 +335,7 @@ _try_argv(Eina_Prefix *pfx, const char *argv0)
335 } 335 }
336 336
337 /* 3. argv0 no path - look in PATH */ 337 /* 3. argv0 no path - look in PATH */
338 if (getuid() != getuid()) return 0;
338 path = getenv("PATH"); 339 path = getenv("PATH");
339 if (!path) 340 if (!path)
340 { 341 {
@@ -383,6 +384,7 @@ _get_env_var(char **var, const char *envprefix, const char *envsuffix, const cha
383 char env[1024]; 384 char env[1024];
384 const char *s; 385 const char *s;
385 386
387 if (getuid() != getuid()) return 0;
386 snprintf(env, sizeof(env), "%s_%s_DIR", envprefix, envsuffix); 388 snprintf(env, sizeof(env), "%s_%s_DIR", envprefix, envsuffix);
387 s = getenv(env); 389 s = getenv(env);
388 if (s) 390 if (s)
@@ -418,13 +420,16 @@ _get_env_vars(Eina_Prefix *pfx,
418 const char *prefix; 420 const char *prefix;
419 int ret = 0; 421 int ret = 0;
420 422
421 snprintf(env, sizeof(env), "%s_PREFIX", envprefix); 423 if (getuid() == getuid())
422 if ((prefix = getenv(env))) STRDUP_REP(pfx->prefix_path, prefix); 424 {
425 snprintf(env, sizeof(env), "%s_PREFIX", envprefix);
426 if ((prefix = getenv(env))) STRDUP_REP(pfx->prefix_path, prefix);
423 427
424 ret += _get_env_var(&pfx->prefix_path_bin, envprefix, "BIN", prefix, bindir); 428 ret += _get_env_var(&pfx->prefix_path_bin, envprefix, "BIN", prefix, bindir);
425 ret += _get_env_var(&pfx->prefix_path_lib, envprefix, "LIB", prefix, libdir); 429 ret += _get_env_var(&pfx->prefix_path_lib, envprefix, "LIB", prefix, libdir);
426 ret += _get_env_var(&pfx->prefix_path_data, envprefix, "DATA", prefix, datadir); 430 ret += _get_env_var(&pfx->prefix_path_data, envprefix, "DATA", prefix, datadir);
427 ret += _get_env_var(&pfx->prefix_path_locale, envprefix, "LOCALE", prefix, localedir); 431 ret += _get_env_var(&pfx->prefix_path_locale, envprefix, "LOCALE", prefix, localedir);
432 }
428 return ret; 433 return ret;
429} 434}
430 435
diff --git a/src/lib/emotion/emotion_modules.c b/src/lib/emotion/emotion_modules.c
index e6c5640a55..d39c575ceb 100644
--- a/src/lib/emotion/emotion_modules.c
+++ b/src/lib/emotion/emotion_modules.c
@@ -3,6 +3,7 @@
3#endif 3#endif
4 4
5#include "emotion_private.h" 5#include "emotion_private.h"
6#include <unistd.h>
6 7
7#ifdef EMOTION_STATIC_BUILD_XINE 8#ifdef EMOTION_STATIC_BUILD_XINE
8Eina_Bool xine_module_init(void); 9Eina_Bool xine_module_init(void);
@@ -53,55 +54,42 @@ static void
53_emotion_modules_load(void) 54_emotion_modules_load(void)
54{ 55{
55 char buf[PATH_MAX]; 56 char buf[PATH_MAX];
56 char *path;
57 57
58 if (_emotion_modules_loaded) return; 58 if (_emotion_modules_loaded) return;
59 _emotion_modules_loaded = EINA_TRUE; 59 _emotion_modules_loaded = EINA_TRUE;
60 60
61 if (getenv("EFL_RUN_IN_TREE")) 61 if (getuid() == getuid())
62 { 62 {
63 struct stat st; 63 if (getenv("EFL_RUN_IN_TREE"))
64 snprintf(buf, sizeof(buf), "%s/src/modules/emotion",
65 PACKAGE_BUILD_DIR);
66 if (stat(buf, &st) == 0)
67 { 64 {
68 const char *built_modules[] = { 65 struct stat st;
66 snprintf(buf, sizeof(buf), "%s/src/modules/emotion",
67 PACKAGE_BUILD_DIR);
68 if (stat(buf, &st) == 0)
69 {
70 const char *built_modules[] = {
69#ifdef EMOTION_BUILD_GSTREAMER 71#ifdef EMOTION_BUILD_GSTREAMER
70 "gstreamer", 72 "gstreamer",
71#endif 73#endif
72#ifdef EMOTION_BUILD_XINE 74#ifdef EMOTION_BUILD_XINE
73 "xine", 75 "xine",
74#endif 76#endif
75 NULL 77 NULL
76 }; 78 };
77 const char **itr; 79 const char **itr;
78 for (itr = built_modules; *itr != NULL; itr++) 80 for (itr = built_modules; *itr != NULL; itr++)
79 { 81 {
80 snprintf(buf, sizeof(buf), 82 snprintf(buf, sizeof(buf),
81 "%s/src/modules/emotion/%s/.libs", 83 "%s/src/modules/emotion/%s/.libs",
82 PACKAGE_BUILD_DIR, *itr); 84 PACKAGE_BUILD_DIR, *itr);
83 _emotion_modules = eina_module_list_get(_emotion_modules, buf, 85 _emotion_modules = eina_module_list_get(_emotion_modules, buf,
84 EINA_FALSE, NULL, NULL); 86 EINA_FALSE, NULL, NULL);
87 }
88 return;
85 } 89 }
86 return;
87 } 90 }
88 } 91 }
89 92
90 path = eina_module_environment_path_get("EMOTION_MODULES_DIR",
91 "/emotion/modules");
92 if (path)
93 {
94 _emotion_modules = eina_module_arch_list_get(_emotion_modules, path, MODULE_ARCH);
95 free(path);
96 }
97
98 path = eina_module_environment_path_get("HOME", "/.emotion");
99 if (path)
100 {
101 _emotion_modules = eina_module_arch_list_get(_emotion_modules, path, MODULE_ARCH);
102 free(path);
103 }
104
105 snprintf(buf, sizeof(buf), "%s/emotion/modules", eina_prefix_lib_get(_emotion_pfx)); 93 snprintf(buf, sizeof(buf), "%s/emotion/modules", eina_prefix_lib_get(_emotion_pfx));
106 _emotion_modules = eina_module_arch_list_get(_emotion_modules, buf, MODULE_ARCH); 94 _emotion_modules = eina_module_arch_list_get(_emotion_modules, buf, MODULE_ARCH);
107// no - this is dumb. load ALL modules we find - force ALL the code pages of 95// no - this is dumb. load ALL modules we find - force ALL the code pages of
diff --git a/src/lib/ethumb/ethumb.c b/src/lib/ethumb/ethumb.c
index 2a97e39bca..c408be516d 100644
--- a/src/lib/ethumb/ethumb.c
+++ b/src/lib/ethumb/ethumb.c
@@ -43,6 +43,7 @@
43#include <dirent.h> 43#include <dirent.h>
44#include <dlfcn.h> 44#include <dlfcn.h>
45#include <ctype.h> 45#include <ctype.h>
46#include <pwd.h>
46 47
47#ifdef HAVE_XATTR 48#ifdef HAVE_XATTR
48# include <sys/xattr.h> 49# include <sys/xattr.h>
@@ -154,50 +155,37 @@ static void
154_ethumb_plugins_load(void) 155_ethumb_plugins_load(void)
155{ 156{
156 char buf[PATH_MAX]; 157 char buf[PATH_MAX];
157 char *path;
158 158
159 if (_plugins_loaded) return; 159 if (_plugins_loaded) return;
160 _plugins_loaded = EINA_TRUE; 160 _plugins_loaded = EINA_TRUE;
161 161
162 if (getenv("EFL_RUN_IN_TREE")) 162 if (getuid() == getuid())
163 { 163 {
164 struct stat st; 164 if (getenv("EFL_RUN_IN_TREE"))
165 snprintf(buf, sizeof(buf), "%s/src/modules/ethumb",
166 PACKAGE_BUILD_DIR);
167 if (stat(buf, &st) == 0)
168 { 165 {
169 const char *built_modules[] = { 166 struct stat st;
170 "emotion", 167 snprintf(buf, sizeof(buf), "%s/src/modules/ethumb",
171 NULL 168 PACKAGE_BUILD_DIR);
172 }; 169 if (stat(buf, &st) == 0)
173 const char **itr;
174 for (itr = built_modules; *itr != NULL; itr++)
175 { 170 {
176 snprintf(buf, sizeof(buf), 171 const char *built_modules[] = {
177 "%s/src/modules/ethumb/%s/.libs", 172 "emotion",
178 PACKAGE_BUILD_DIR, *itr); 173 NULL
179 _plugins = eina_module_list_get(_plugins, buf, 174 };
180 EINA_FALSE, NULL, NULL); 175 const char **itr;
176 for (itr = built_modules; *itr != NULL; itr++)
177 {
178 snprintf(buf, sizeof(buf),
179 "%s/src/modules/ethumb/%s/.libs",
180 PACKAGE_BUILD_DIR, *itr);
181 _plugins = eina_module_list_get(_plugins, buf,
182 EINA_FALSE, NULL, NULL);
183 }
184 goto load;
181 } 185 }
182 goto load;
183 } 186 }
184 } 187 }
185 188
186 path = eina_module_environment_path_get("ETHUMB_MODULES_DIR",
187 "/ethumb/modules");
188 if (path)
189 {
190 _plugins = eina_module_arch_list_get(_plugins, path, MODULE_ARCH);
191 free(path);
192 }
193
194 path = eina_module_environment_path_get("HOME", "/.ethumb");
195 if (path)
196 {
197 _plugins = eina_module_arch_list_get(_plugins, path, MODULE_ARCH);
198 free(path);
199 }
200
201 snprintf(buf, sizeof(buf), "%s/ethumb/modules", eina_prefix_lib_get(_pfx)); 189 snprintf(buf, sizeof(buf), "%s/ethumb/modules", eina_prefix_lib_get(_pfx));
202 _plugins = eina_module_arch_list_get(_plugins, buf, MODULE_ARCH); 190 _plugins = eina_module_arch_list_get(_plugins, buf, MODULE_ARCH);
203 191
@@ -269,8 +257,18 @@ ethumb_init(void)
269 ecore_evas_init(); 257 ecore_evas_init();
270 edje_init(); 258 edje_init();
271 259
272 home = getenv("HOME"); 260 if (getuid() == getuid())
273 snprintf(buf, sizeof(buf), "%s/.thumbnails", home); 261 {
262 home = getenv("HOME");
263 snprintf(buf, sizeof(buf), "%s/.thumbnails", home);
264 }
265 else
266 {
267 struct passwd *pw = getpwent();
268
269 if ((!pw) || (!pw->pw_dir)) goto error_plugins_ext;
270 snprintf(buf, sizeof(buf), "%s/.thumbnails", pw->pw_dir);
271 }
274 272
275 _home_thumb_dir = eina_stringshare_add(buf); 273 _home_thumb_dir = eina_stringshare_add(buf);
276 _thumb_category_normal = eina_stringshare_add("normal"); 274 _thumb_category_normal = eina_stringshare_add("normal");
@@ -709,11 +707,21 @@ _ethumb_build_absolute_path(const char *path, char buf[PATH_MAX])
709 } 707 }
710 else if (path[0] == '~') 708 else if (path[0] == '~')
711 { 709 {
712 const char *home = getenv("HOME"); 710 if (getuid() == getuid())
713 if (!home) 711 {
714 return NULL; 712 const char *home = getenv("HOME");
715 strncpy(p, home, PATH_MAX - 1); 713 if (!home) return NULL;
716 p[PATH_MAX - 1] = 0; 714 strncpy(p, home, PATH_MAX - 1);
715 p[PATH_MAX - 1] = 0;
716 }
717 else
718 {
719 struct passwd *pw = getpwent();
720
721 if ((!pw) || (!pw->pw_dir)) return NULL;
722 strncpy(p, pw->pw_dir, PATH_MAX - 1);
723 p[PATH_MAX - 1] = 0;
724 }
717 len = strlen(p); 725 len = strlen(p);
718 p += len; 726 p += len;
719 p[0] = '/'; 727 p[0] = '/';
diff --git a/src/lib/evas/cserve2/evas_cs2_client.c b/src/lib/evas/cserve2/evas_cs2_client.c
index a1224e4746..0afd91f3fa 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -128,32 +128,38 @@ _socket_path_set(char *path)
128 char *env; 128 char *env;
129 char buf[UNIX_PATH_MAX]; 129 char buf[UNIX_PATH_MAX];
130 130
131 env = getenv("EVAS_CSERVE2_SOCKET"); 131 if (getuid() == getuid())
132 if (env && env[0])
133 { 132 {
134 eina_strlcpy(path, env, UNIX_PATH_MAX); 133 env = getenv("EVAS_CSERVE2_SOCKET");
135 return; 134 if (env && env[0])
135 {
136 eina_strlcpy(path, env, UNIX_PATH_MAX);
137 return;
138 }
136 } 139 }
137 140
138 snprintf(buf, sizeof(buf), "/tmp/.evas-cserve2-%x.socket", (int)getuid()); 141 snprintf(buf, sizeof(buf), "/tmp/.evas-cserve2-%x.socket", (int)getuid());
139 /* FIXME: check we can actually create this socket */ 142 /* FIXME: check we can actually create this socket */
140 strcpy(path, buf); 143 strcpy(path, buf);
141#if 0 144#if 0
142 env = getenv("XDG_RUNTIME_DIR"); 145 if (getuid() == getuid())
143 if (!env || !env[0])
144 { 146 {
145 env = getenv("HOME"); 147 env = getenv("XDG_RUNTIME_DIR");
146 if (!env || !env[0]) 148 if (!env || !env[0])
147 { 149 {
148 env = getenv("TMPDIR"); 150 env = getenv("HOME");
149 if (!env || !env[0]) 151 if (!env || !env[0])
150 env = "/tmp"; 152 {
153 env = getenv("TMPDIR");
154 if (!env || !env[0])
155 env = "/tmp";
156 }
151 } 157 }
152 }
153 158
154 snprintf(buf, sizeof(buf), "%s/evas-cserve2-%x.socket", env, getuid()); 159 snprintf(buf, sizeof(buf), "%s/evas-cserve2-%x.socket", env, getuid());
155 /* FIXME: check we can actually create this socket */ 160 /* FIXME: check we can actually create this socket */
156 strcpy(path, buf); 161 strcpy(path, buf);
162 }
157#endif 163#endif
158} 164}
159 165
diff --git a/src/lib/evas/file/evas_module.c b/src/lib/evas/file/evas_module.c
index b3d0a87c92..01bf0b0f1d 100644
--- a/src/lib/evas/file/evas_module.c
+++ b/src/lib/evas/file/evas_module.c
@@ -56,29 +56,21 @@ evas_module_paths_init(void)
56{ 56{
57 char *libdir, *path; 57 char *libdir, *path;
58 58
59 if (getenv("EFL_RUN_IN_TREE")) 59 if (getuid() == getuid())
60 { 60 {
61 struct stat st; 61 if (getenv("EFL_RUN_IN_TREE"))
62 const char mp[] = PACKAGE_BUILD_DIR"/src/modules/evas";
63 if (stat(mp, &st) == 0)
64 { 62 {
65 evas_module_paths = _evas_module_append(evas_module_paths, strdup(mp)); 63 struct stat st;
66 return; 64 const char mp[] = PACKAGE_BUILD_DIR"/src/modules/evas";
65 if (stat(mp, &st) == 0)
66 {
67 evas_module_paths = _evas_module_append(evas_module_paths, strdup(mp));
68 return;
69 }
67 } 70 }
68 } 71 }
69 72
70 /* 1. ~/.evas/modules/ */ 73 /* 1. libevas.so/../evas/modules/ */
71 path = eina_module_environment_path_get("HOME", "/.evas/modules");
72 evas_module_paths = _evas_module_append(evas_module_paths, path);
73
74 /* 2. $(EVAS_MODULE_DIR)/evas/modules/ */
75 path = eina_module_environment_path_get("EVAS_MODULES_DIR", "/evas/modules");
76 if (eina_list_search_unsorted(evas_module_paths, (Eina_Compare_Cb) strcmp, path))
77 free(path);
78 else
79 evas_module_paths = _evas_module_append(evas_module_paths, path);
80
81 /* 3. libevas.so/../evas/modules/ */
82 libdir = (char *)_evas_module_libdir_get(); 74 libdir = (char *)_evas_module_libdir_get();
83 if (!libdir) 75 if (!libdir)
84 path = eina_module_symbol_path_get(evas_module_paths_init, "/evas/modules"); 76 path = eina_module_symbol_path_get(evas_module_paths_init, "/evas/modules");
@@ -96,7 +88,7 @@ evas_module_paths_init(void)
96 else 88 else
97 evas_module_paths = _evas_module_append(evas_module_paths, path); 89 evas_module_paths = _evas_module_append(evas_module_paths, path);
98 90
99 /* 4. PREFIX/lib/evas/modules/ */ 91 /* 2. PREFIX/lib/evas/modules/ */
100#ifndef _MSC_VER 92#ifndef _MSC_VER
101 path = PACKAGE_LIB_DIR "/evas/modules"; 93 path = PACKAGE_LIB_DIR "/evas/modules";
102 if (!eina_list_search_unsorted(evas_module_paths, (Eina_Compare_Cb) strcmp, path)) 94 if (!eina_list_search_unsorted(evas_module_paths, (Eina_Compare_Cb) strcmp, path))
@@ -334,12 +326,15 @@ evas_module_engine_list(void)
334 const char *fname = fi->path + fi->name_start; 326 const char *fname = fi->path + fi->name_start;
335 327
336 buf[0] = '\0'; 328 buf[0] = '\0';
337 if (run_in_tree) 329 if (getuid() == getuid())
338 { 330 {
339 snprintf(buf, sizeof(buf), "%s/engines/%s/.libs", 331 if (run_in_tree)
340 s, fname); 332 {
341 if (!evas_file_path_exists(buf)) 333 snprintf(buf, sizeof(buf), "%s/engines/%s/.libs",
342 buf[0] = '\0'; 334 s, fname);
335 if (!evas_file_path_exists(buf))
336 buf[0] = '\0';
337 }
343 } 338 }
344 339
345 if (buf[0] == '\0') 340 if (buf[0] == '\0')
@@ -430,12 +425,15 @@ evas_module_find_type(Evas_Module_Type type, const char *name)
430 } 425 }
431 426
432 buffer[0] = '\0'; 427 buffer[0] = '\0';
433 if (run_in_tree) 428 if (getuid() == getuid())
434 { 429 {
435 snprintf(buffer, sizeof(buffer), "%s/%s/%s/.libs/%s", 430 if (run_in_tree)
436 path, type_str, name, EVAS_MODULE_NAME); 431 {
437 if (!evas_file_path_exists(buffer)) 432 snprintf(buffer, sizeof(buffer), "%s/%s/%s/.libs/%s",
438 buffer[0] = '\0'; 433 path, type_str, name, EVAS_MODULE_NAME);
434 if (!evas_file_path_exists(buffer))
435 buffer[0] = '\0';
436 }
439 } 437 }
440 438
441 if (buffer[0] == '\0') 439 if (buffer[0] == '\0')