forked from enlightenment/efl
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:
parent
d345b899b2
commit
1a481cfe4d
|
@ -43,8 +43,8 @@ _efl_vpath_core_efl_object_constructor(Eo *obj, Efl_Vpath_Core_Data *pd)
|
||||||
if (!home)
|
if (!home)
|
||||||
{
|
{
|
||||||
/* Windows does not have getuid(), but home can't be NULL */
|
/* Windows does not have getuid(), but home can't be NULL */
|
||||||
#ifdef HAVE_GETUID
|
#ifdef HAVE_GETEUID
|
||||||
uid_t uid = getuid();
|
uid_t uid = geteuid();
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
snprintf(bufhome, sizeof(bufhome), "/tmp/%i", (int)uid);
|
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"))))
|
if ((getuid() != geteuid()) || (!(s = getenv("XDG_RUNTIME_DIR"))))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef HAVE_GETUID
|
#ifdef HAVE_GETEUID
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
// fallback - make ~/.run
|
// 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
|
// use /tmp/.run-UID if ~/ dir cant be made
|
||||||
s = (char *)efl_vpath_core_meta_get(obj, "tmp");
|
s = (char *)efl_vpath_core_meta_get(obj, "tmp");
|
||||||
uid = getuid();
|
uid = geteuid();
|
||||||
snprintf(buf, sizeof(buf), "%s/.run-%i", s, (int)uid);
|
snprintf(buf, sizeof(buf), "%s/.run-%i", s, (int)uid);
|
||||||
mkdir(buf, S_IRUSR | S_IWUSR | S_IXUSR);
|
mkdir(buf, S_IRUSR | S_IWUSR | S_IXUSR);
|
||||||
// if ok - use it or fall back to /tmp
|
// if ok - use it or fall back to /tmp
|
||||||
|
|
|
@ -81,7 +81,7 @@ eina_environment_home_get(void)
|
||||||
struct passwd pwent, *pwent2 = NULL;
|
struct passwd pwent, *pwent2 = NULL;
|
||||||
char pwbuf[8129];
|
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))
|
if ((pwent2) && (pwent.pw_dir))
|
||||||
home = strdup(pwent.pw_dir);
|
home = strdup(pwent.pw_dir);
|
||||||
|
|
Loading…
Reference in New Issue