summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-07-29 12:41:59 -0400
committerCedric BAIL <cedric.bail@free.fr>2019-07-29 11:17:49 -0700
commit36ff0a012ce227757331a745fbb437b2097f4e45 (patch)
tree6db4946cfffd0c9a489108dc36b439a84b18309e /src/lib
parentb561e9632e5d0b1a9feef2d9db54ed872b4568ee (diff)
elm/config: fix config usage with EFL_RUN_IN_TREE set
when running in tree, elm_config should not attempt to access files outside the tree, nor should it attempt to overwrite any existing config files @fix Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D9433
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/elementary/elm_config.c35
1 files changed, 28 insertions, 7 deletions
diff --git a/src/lib/elementary/elm_config.c b/src/lib/elementary/elm_config.c
index 9258939f79..c6da38ed27 100644
--- a/src/lib/elementary/elm_config.c
+++ b/src/lib/elementary/elm_config.c
@@ -5,6 +5,7 @@
5#include <Elementary.h> 5#include <Elementary.h>
6#include "elm_priv.h" 6#include "elm_priv.h"
7 7
8#include "../../static_libs/buildsystem/buildsystem.h"
8#include "efl_config_global.eo.h" 9#include "efl_config_global.eo.h"
9 10
10EAPI int ELM_EVENT_CONFIG_ALL_CHANGED = 0; 11EAPI int ELM_EVENT_CONFIG_ALL_CHANGED = 0;
@@ -964,7 +965,8 @@ _elm_config_profile_dir_get(const char *prof,
964 if (!is_user) 965 if (!is_user)
965 goto not_user; 966 goto not_user;
966 967
967 _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/%s", prof); 968 if ((!_use_build_config) || (!bs_data_path_get(buf, sizeof(buf), "elementary/config", prof)))
969 _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/%s", prof);
968 970
969 // See elm_config_profile_dir_free: always use strdup+free 971 // See elm_config_profile_dir_free: always use strdup+free
970 if (ecore_file_is_dir(buf)) 972 if (ecore_file_is_dir(buf))
@@ -973,7 +975,8 @@ _elm_config_profile_dir_get(const char *prof,
973 return NULL; 975 return NULL;
974 976
975not_user: 977not_user:
976 snprintf(buf, sizeof(buf), "%s/config/%s", _elm_data_dir, prof); 978 if ((!_use_build_config) || (!bs_data_path_get(buf, sizeof(buf), "elementary/config", prof)))
979 snprintf(buf, sizeof(buf), "%s/config/%s", _elm_data_dir, prof);
977 980
978 // See elm_config_profile_dir_free: always use strdup+free 981 // See elm_config_profile_dir_free: always use strdup+free
979 if (ecore_file_is_dir(buf)) 982 if (ecore_file_is_dir(buf))
@@ -1355,9 +1358,15 @@ _elm_config_profiles_list(Eina_Bool hide_profiles)
1355 Eina_Iterator *file_it; 1358 Eina_Iterator *file_it;
1356 char buf[PATH_MAX]; 1359 char buf[PATH_MAX];
1357 const char *dir; 1360 const char *dir;
1358 size_t len; 1361 size_t len = 0;
1359 1362
1360 len = _elm_config_user_dir_snprintf(buf, sizeof(buf), "config"); 1363 if (_use_build_config)
1364 {
1365 len = bs_data_path_get(buf, sizeof(buf), "elementary", "config");
1366 if (len) len = strlen(buf);
1367 }
1368 if (!len)
1369 len = _elm_config_user_dir_snprintf(buf, sizeof(buf), "config");
1361 1370
1362 file_it = eina_file_stat_ls(buf); 1371 file_it = eina_file_stat_ls(buf);
1363 if (!file_it) goto sys; 1372 if (!file_it) goto sys;
@@ -2082,7 +2091,7 @@ _elm_config_profile_save(const char *profile)
2082 Eet_File *ef; 2091 Eet_File *ef;
2083 size_t len; 2092 size_t len;
2084 2093
2085 if ((s = getenv("ELM_PROFILE_NOSAVE")) && atoi(s)) 2094 if (_use_build_config || ((s = getenv("ELM_PROFILE_NOSAVE")) && atoi(s)))
2086 return EINA_TRUE; 2095 return EINA_TRUE;
2087 2096
2088 len = _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/profile.cfg"); 2097 len = _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/profile.cfg");
@@ -3001,6 +3010,11 @@ elm_config_profile_exists(const char *profile)
3001 3010
3002 if (!profile) return EINA_FALSE; 3011 if (!profile) return EINA_FALSE;
3003 3012
3013 if (_use_build_config)
3014 {
3015 if (!bs_data_path_get(buf, sizeof(buf), "elementary/config", profile)) return EINA_FALSE;
3016 return ecore_file_exists(buf);
3017 }
3004 _elm_config_user_dir_snprintf(buf, sizeof(buf), 3018 _elm_config_user_dir_snprintf(buf, sizeof(buf),
3005 "config/%s/base.cfg", profile); 3019 "config/%s/base.cfg", profile);
3006 if (ecore_file_exists(buf)) return EINA_TRUE; 3020 if (ecore_file_exists(buf)) return EINA_TRUE;
@@ -4093,6 +4107,7 @@ elm_config_all_flush(void)
4093 int ok = 0; 4107 int ok = 0;
4094 size_t len; 4108 size_t len;
4095 4109
4110 if (_use_build_config) return;
4096 len = _elm_config_user_dir_snprintf(buf, sizeof(buf), "themes/"); 4111 len = _elm_config_user_dir_snprintf(buf, sizeof(buf), "themes/");
4097 if (len + 1 >= sizeof(buf)) 4112 if (len + 1 >= sizeof(buf))
4098 return; 4113 return;
@@ -4199,6 +4214,7 @@ _elm_config_sub_shutdown(void)
4199 ELM_SAFE_FREE(_monitor_file_created_handler, ecore_event_handler_del); 4214 ELM_SAFE_FREE(_monitor_file_created_handler, ecore_event_handler_del);
4200 ELM_SAFE_FREE(_monitor_file_modified_handler, ecore_event_handler_del); 4215 ELM_SAFE_FREE(_monitor_file_modified_handler, ecore_event_handler_del);
4201 ELM_SAFE_FREE(_monitor_directory_created_handler, ecore_event_handler_del); 4216 ELM_SAFE_FREE(_monitor_directory_created_handler, ecore_event_handler_del);
4217 _use_build_config = EINA_FALSE;
4202} 4218}
4203 4219
4204static Eina_Bool 4220static Eina_Bool
@@ -4290,8 +4306,13 @@ _elm_config_sub_init(void)
4290 char buf[PATH_MAX]; 4306 char buf[PATH_MAX];
4291 int ok = 0; 4307 int ok = 0;
4292 4308
4293 _elm_config_user_dir_snprintf(buf, sizeof(buf), "config"); 4309 if (_use_build_config)
4294 ok = ecore_file_mkpath(buf); 4310 ok = bs_data_path_get(buf, sizeof(buf), "elementary", "config");
4311 else
4312 {
4313 _elm_config_user_dir_snprintf(buf, sizeof(buf), "config");
4314 ok = ecore_file_mkpath(buf);
4315 }
4295 if (!ok) 4316 if (!ok)
4296 { 4317 {
4297 ERR("Problem accessing Elementary's user configuration directory: %s", 4318 ERR("Problem accessing Elementary's user configuration directory: %s",