summaryrefslogtreecommitdiff
path: root/src/lib/ecore_imf/ecore_imf_module.c
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/ecore_imf/ecore_imf_module.c
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/ecore_imf/ecore_imf_module.c')
-rw-r--r--src/lib/ecore_imf/ecore_imf_module.c69
1 files changed, 28 insertions, 41 deletions
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