diff options
author | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2014-01-08 19:46:23 +0900 |
---|---|---|
committer | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2014-01-08 19:46:23 +0900 |
commit | b95ef3801f9719a8f8ff731e25d66a8d1dd417cd (patch) | |
tree | 258548da51b18d5fde17915bdc36cba44effcf40 /src/lib/evas/file/evas_module.c | |
parent | 323f293ab538ffc7431f6598736963a834c4f880 (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 '')
-rw-r--r-- | src/lib/evas/file/evas_module.c | 56 |
1 files changed, 27 insertions, 29 deletions
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') |