cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=36ff0a012ce227757331a745fbb437b2097f4e45

commit 36ff0a012ce227757331a745fbb437b2097f4e45
Author: Mike Blumenkrantz <[email protected]>
Date:   Mon Jul 29 12:41:59 2019 -0400

    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 <[email protected]>
    Differential Revision: https://phab.enlightenment.org/D9433
---
 src/lib/elementary/elm_config.c | 35 ++++++++++++++++++++++++++++-------
 1 file 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 @@
 #include <Elementary.h>
 #include "elm_priv.h"
 
+#include "../../static_libs/buildsystem/buildsystem.h"
 #include "efl_config_global.eo.h"
 
 EAPI int ELM_EVENT_CONFIG_ALL_CHANGED = 0;
@@ -964,7 +965,8 @@ _elm_config_profile_dir_get(const char *prof,
    if (!is_user)
      goto not_user;
 
-   _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/%s", prof);
+   if ((!_use_build_config) || (!bs_data_path_get(buf, sizeof(buf), 
"elementary/config", prof)))
+     _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/%s", prof);
 
    // See elm_config_profile_dir_free: always use strdup+free
    if (ecore_file_is_dir(buf))
@@ -973,7 +975,8 @@ _elm_config_profile_dir_get(const char *prof,
    return NULL;
 
 not_user:
-   snprintf(buf, sizeof(buf), "%s/config/%s", _elm_data_dir, prof);
+   if ((!_use_build_config) || (!bs_data_path_get(buf, sizeof(buf), 
"elementary/config", prof)))
+     snprintf(buf, sizeof(buf), "%s/config/%s", _elm_data_dir, prof);
 
    // See elm_config_profile_dir_free: always use strdup+free
    if (ecore_file_is_dir(buf))
@@ -1355,9 +1358,15 @@ _elm_config_profiles_list(Eina_Bool hide_profiles)
    Eina_Iterator *file_it;
    char buf[PATH_MAX];
    const char *dir;
-   size_t len;
+   size_t len = 0;
 
-   len = _elm_config_user_dir_snprintf(buf, sizeof(buf), "config");
+   if (_use_build_config)
+     {
+        len = bs_data_path_get(buf, sizeof(buf), "elementary", "config");
+        if (len) len = strlen(buf);
+     }
+   if (!len)
+     len = _elm_config_user_dir_snprintf(buf, sizeof(buf), "config");
 
    file_it = eina_file_stat_ls(buf);
    if (!file_it) goto sys;
@@ -2082,7 +2091,7 @@ _elm_config_profile_save(const char *profile)
    Eet_File *ef;
    size_t len;
 
-   if ((s = getenv("ELM_PROFILE_NOSAVE")) && atoi(s))
+   if (_use_build_config || ((s = getenv("ELM_PROFILE_NOSAVE")) && atoi(s)))
      return EINA_TRUE;
 
    len = _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/profile.cfg");
@@ -3001,6 +3010,11 @@ elm_config_profile_exists(const char *profile)
 
    if (!profile) return EINA_FALSE;
 
+   if (_use_build_config)
+     {
+        if (!bs_data_path_get(buf, sizeof(buf), "elementary/config", profile)) 
return EINA_FALSE;
+        return ecore_file_exists(buf);
+     }
    _elm_config_user_dir_snprintf(buf, sizeof(buf),
                                  "config/%s/base.cfg", profile);
    if (ecore_file_exists(buf)) return EINA_TRUE;
@@ -4093,6 +4107,7 @@ elm_config_all_flush(void)
    int ok = 0;
    size_t len;
 
+   if (_use_build_config) return;
    len = _elm_config_user_dir_snprintf(buf, sizeof(buf), "themes/");
    if (len + 1 >= sizeof(buf))
      return;
@@ -4199,6 +4214,7 @@ _elm_config_sub_shutdown(void)
    ELM_SAFE_FREE(_monitor_file_created_handler, ecore_event_handler_del);
    ELM_SAFE_FREE(_monitor_file_modified_handler, ecore_event_handler_del);
    ELM_SAFE_FREE(_monitor_directory_created_handler, ecore_event_handler_del);
+   _use_build_config = EINA_FALSE;
 }
 
 static Eina_Bool
@@ -4290,8 +4306,13 @@ _elm_config_sub_init(void)
    char buf[PATH_MAX];
    int ok = 0;
 
-   _elm_config_user_dir_snprintf(buf, sizeof(buf), "config");
-   ok = ecore_file_mkpath(buf);
+   if (_use_build_config)
+     ok = bs_data_path_get(buf, sizeof(buf), "elementary", "config");
+   else
+     {
+        _elm_config_user_dir_snprintf(buf, sizeof(buf), "config");
+        ok = ecore_file_mkpath(buf);
+     }
    if (!ok)
      {
         ERR("Problem accessing Elementary's user configuration directory: %s",

-- 


Reply via email to