eina utils and vpath - use euid not uid if setuid for correct user

was using uid not euid for "if setuid use safe way to get location" -
ie the user that effectively owns the process, not nominally.

@fix
This commit is contained in:
Carsten Haitzler 2017-02-09 18:50:15 +09:00
parent d345b899b2
commit 1a481cfe4d
2 changed files with 5 additions and 5 deletions

View File

@ -43,8 +43,8 @@ _efl_vpath_core_efl_object_constructor(Eo *obj, Efl_Vpath_Core_Data *pd)
if (!home)
{
/* Windows does not have getuid(), but home can't be NULL */
#ifdef HAVE_GETUID
uid_t uid = getuid();
#ifdef HAVE_GETEUID
uid_t uid = geteuid();
struct stat st;
snprintf(bufhome, sizeof(bufhome), "/tmp/%i", (int)uid);
@ -109,7 +109,7 @@ _efl_vpath_core_efl_object_constructor(Eo *obj, Efl_Vpath_Core_Data *pd)
if ((getuid() != geteuid()) || (!(s = getenv("XDG_RUNTIME_DIR"))))
#endif
{
#ifdef HAVE_GETUID
#ifdef HAVE_GETEUID
struct stat st;
// fallback - make ~/.run
@ -123,7 +123,7 @@ _efl_vpath_core_efl_object_constructor(Eo *obj, Efl_Vpath_Core_Data *pd)
// use /tmp/.run-UID if ~/ dir cant be made
s = (char *)efl_vpath_core_meta_get(obj, "tmp");
uid = getuid();
uid = geteuid();
snprintf(buf, sizeof(buf), "%s/.run-%i", s, (int)uid);
mkdir(buf, S_IRUSR | S_IWUSR | S_IXUSR);
// if ok - use it or fall back to /tmp

View File

@ -81,7 +81,7 @@ eina_environment_home_get(void)
struct passwd pwent, *pwent2 = NULL;
char pwbuf[8129];
if (!getpwuid_r(getuid(), &pwent, pwbuf, sizeof(pwbuf), &pwent2))
if (!getpwuid_r(geteuid(), &pwent, pwbuf, sizeof(pwbuf), &pwent2))
{
if ((pwent2) && (pwent.pw_dir))
home = strdup(pwent.pw_dir);