summaryrefslogtreecommitdiff
path: root/src/lib/efreet
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-02-09 15:38:34 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-02-09 18:38:28 +0900
commit75e1033682b2ecf9feed3eae938c9ee0c43fe795 (patch)
tree6e94d5255f5a536a1ec35180cdf603d71ca3b1c3 /src/lib/efreet
parent9eee1f80fc8fbd852bdf8b42eec663d818ffd5c2 (diff)
efreet - use vpath to get XDG_RUNTIME_DIR so we have a single impl
having too many places that get XDG_RUNTIME_DIR makes it harder to keep secure etc, so make it a single location for efreet too.
Diffstat (limited to 'src/lib/efreet')
-rw-r--r--src/lib/efreet/efreet_base.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/lib/efreet/efreet_base.c b/src/lib/efreet/efreet_base.c
index d6685d7d15..506d2e89a4 100644
--- a/src/lib/efreet/efreet_base.c
+++ b/src/lib/efreet/efreet_base.c
@@ -15,6 +15,7 @@
15#endif 15#endif
16 16
17#include <Ecore_File.h> 17#include <Ecore_File.h>
18#include <Efl.h>
18 19
19/* define macros and variable for using the eina logging system */ 20/* define macros and variable for using the eina logging system */
20#define EFREET_MODULE_LOG_DOM _efreet_base_log_dom 21#define EFREET_MODULE_LOG_DOM _efreet_base_log_dom
@@ -96,6 +97,8 @@ efreet_base_shutdown(void)
96 IF_RELEASE(xdg_config_home); 97 IF_RELEASE(xdg_config_home);
97 IF_RELEASE(xdg_cache_home); 98 IF_RELEASE(xdg_cache_home);
98 99
100 IF_RELEASE(xdg_runtime_dir);
101
99 IF_FREE_LIST(xdg_data_dirs, eina_stringshare_del); 102 IF_FREE_LIST(xdg_data_dirs, eina_stringshare_del);
100 IF_FREE_LIST(xdg_config_dirs, eina_stringshare_del); 103 IF_FREE_LIST(xdg_config_dirs, eina_stringshare_del);
101 104
@@ -278,23 +281,13 @@ efreet_dirs_reset(void)
278static void 281static void
279efreet_dirs_init(void) 282efreet_dirs_init(void)
280{ 283{
281 char buf[4096]; 284 Efl_Vpath_File *file_obj;
285 char buf[PATH_MAX];
282 286
283 /* efreet_home_dir */ 287 /* efreet_home_dir */
284#if defined(HAVE_GETUID) && defined(HAVE_GETEUID) 288 efreet_home_dir = eina_environment_home_get();
285 if (getuid() != geteuid())
286 {
287 struct passwd *pw = getpwent();
288
289 if ((pw) && (pw->pw_dir)) efreet_home_dir = pw->pw_dir;
290 }
291 else
292#endif
293 efreet_home_dir = eina_environment_home_get();
294
295 if (!efreet_home_dir || efreet_home_dir[0] == '\0') 289 if (!efreet_home_dir || efreet_home_dir[0] == '\0')
296 efreet_home_dir = "/tmp"; 290 efreet_home_dir = "/tmp";
297
298 efreet_home_dir = eina_stringshare_add(efreet_home_dir); 291 efreet_home_dir = eina_stringshare_add(efreet_home_dir);
299 292
300 /* xdg_<dir>_home */ 293 /* xdg_<dir>_home */
@@ -318,10 +311,11 @@ efreet_dirs_init(void)
318#endif 311#endif
319 312
320 /* xdg_runtime_dir */ 313 /* xdg_runtime_dir */
321#if defined(HAVE_GETUID) && defined(HAVE_GETEUID) 314 file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, "(:run:)/");
322 if (getuid() == geteuid()) 315 efl_vpath_file_do(file_obj);
323#endif 316 efl_vpath_file_wait(file_obj);
324 xdg_runtime_dir = getenv("XDG_RUNTIME_DIR"); 317 xdg_runtime_dir = eina_stringshare_add(efl_vpath_file_result_get(file_obj));
318 efl_del(file_obj);
325 319
326 /* hostname */ 320 /* hostname */
327 if (gethostname(buf, sizeof(buf)) < 0) 321 if (gethostname(buf, sizeof(buf)) < 0)