forked from enlightenment/efl
elm config - handle setuid apps correctly and dont create junk dirs in .
this fixes a bug where elm_cofnig would firstly use ~/.config/elementary which isnt what we have used before and so would break older config. also it'd create junk if it was setuid. fix this. @fix
This commit is contained in:
parent
5c431b14de
commit
d345b899b2
|
@ -611,75 +611,47 @@ _elm_config_user_dir_snprintf(char *dst,
|
||||||
const char *fmt,
|
const char *fmt,
|
||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
const char *home = NULL;
|
|
||||||
size_t user_dir_len = 0, off = 0;
|
size_t user_dir_len = 0, off = 0;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
Efl_Vpath_File *file_obj;
|
||||||
|
static int use_xdg_config = -1;
|
||||||
|
const char elmdir[] = "elementary";
|
||||||
|
const char elmdotdir[] = ".elementary";
|
||||||
|
const char *path = NULL;
|
||||||
|
|
||||||
#if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
|
if (use_xdg_config == -1)
|
||||||
if (getuid() == geteuid())
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#ifdef DOXDG
|
if (getenv("ELM_CONFIG_DIR_XDG")) use_xdg_config = 1;
|
||||||
home = getenv("XDG_CONFIG_HOME");
|
else use_xdg_config = 0;
|
||||||
if (home)
|
}
|
||||||
{
|
if (use_xdg_config)
|
||||||
user_dir_len = eina_str_join_len
|
{
|
||||||
(dst, size, '/', home, strlen(home),
|
file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, "(:config:)/");
|
||||||
"elementary", sizeof("elementary") - 1);
|
efl_vpath_file_do(file_obj);
|
||||||
}
|
efl_vpath_file_wait(file_obj);
|
||||||
else
|
path = efl_vpath_file_result_get(file_obj);
|
||||||
#endif
|
user_dir_len = eina_str_join_len
|
||||||
{
|
(dst, size, '/', path, strlen(path) - 1, elmdir, sizeof(elmdir) - 1);
|
||||||
home = eina_environment_home_get();
|
efl_del(file_obj);
|
||||||
if (!home) home = "/";
|
|
||||||
#ifdef DOXDG
|
|
||||||
user_dir_len = eina_str_join_len
|
|
||||||
(dst, size, '/', home, strlen(home),
|
|
||||||
".config", sizeof(".config") - 1,
|
|
||||||
"elementary", sizeof("elementary") - 1);
|
|
||||||
#else
|
|
||||||
user_dir_len = eina_str_join_len
|
|
||||||
(dst, size, '/', home, strlen(home),
|
|
||||||
ELEMENTARY_BASE_DIR, sizeof(ELEMENTARY_BASE_DIR) - 1);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
off = user_dir_len + 1;
|
|
||||||
if (off >= size) return off;
|
|
||||||
dst[user_dir_len] = '/';
|
|
||||||
va_start(ap, fmt);
|
|
||||||
off = off + vsnprintf(dst + off, size - off, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
return off;
|
|
||||||
}
|
}
|
||||||
#if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
|
|
||||||
else
|
else
|
||||||
#else
|
|
||||||
{
|
{
|
||||||
# if HAVE_GETPWENT
|
file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, "(:home:)/");
|
||||||
struct passwd *pw = getpwent();
|
efl_vpath_file_do(file_obj);
|
||||||
|
efl_vpath_file_wait(file_obj);
|
||||||
if ((!pw) || (!pw->pw_dir)) goto end;
|
path = efl_vpath_file_result_get(file_obj);
|
||||||
# ifdef DOXDG
|
|
||||||
user_dir_len = eina_str_join_len
|
user_dir_len = eina_str_join_len
|
||||||
(dst, size, '/', pw->pw_dir, strlen(pw->pw_dir),
|
(dst, size, '/', path, strlen(path) - 1, elmdotdir, sizeof(elmdotdir) - 1);
|
||||||
".config", sizeof(".config") - 1,
|
efl_del(file_obj);
|
||||||
"elementary", sizeof("elementary") - 1);
|
|
||||||
# else
|
|
||||||
user_dir_len = eina_str_join_len
|
|
||||||
(dst, size, '/', pw->pw_dir, strlen(pw->pw_dir),
|
|
||||||
ELEMENTARY_BASE_DIR, sizeof(ELEMENTARY_BASE_DIR) - 1);
|
|
||||||
# endif
|
|
||||||
# endif /* HAVE_GETPWENT */
|
|
||||||
off = user_dir_len + 1;
|
|
||||||
if (off >= size) return off;
|
|
||||||
dst[user_dir_len] = '/';
|
|
||||||
va_start(ap, fmt);
|
|
||||||
off = off + vsnprintf(dst + off, size - off, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
return off;
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return 0;
|
off = user_dir_len + 1;
|
||||||
|
if (off >= size) return off;
|
||||||
|
dst[user_dir_len] = '/';
|
||||||
|
va_start(ap, fmt);
|
||||||
|
off = off + vsnprintf(dst + off, size - off, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
return off;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct _Elm_Config_Derived Elm_Config_Derived;
|
typedef struct _Elm_Config_Derived Elm_Config_Derived;
|
||||||
|
|
Loading…
Reference in New Issue