more portable Gnome uid workaround

- incorporate a more portable way of calling the real getres*id() functions
on Linux platforms that uses the glibc interface rather than calling
the system call directly.  The previous version didn't work on ia64 linux.
This commit is contained in:
cohrs
2002-04-21 23:59:52 +00:00
parent 8260da268e
commit 310e466162
2 changed files with 18 additions and 22 deletions

View File

@@ -110,6 +110,7 @@ Gnome: destroy main game windows correctly
Gnome: Dylan Alex Simon's port of KDE-style worn window
Gnome: Dylan Alex Simon's port of KDE-style hero cursor color
tty: support terms where turning off inverse video turns off color too
Gnome/Linux: more portable getres*id workaround
General New Features

View File

@@ -19,40 +19,35 @@
#ifdef GETRES_SUPPORT
# if defined(LINUX)
#ifdef __GNUC__
#define _GNU_SOURCE
#endif
static _syscall3(int, getresuid, unsigned short *, ruid, \
unsigned short *, euid, unsigned short *, suid)
static _syscall3(int, getresgid, unsigned short *, rgid, \
unsigned short *, egid, unsigned short *, sgid)
/* requires dynamic linking with libc */
#include <dlfcn.h>
static int
real_getresuid(ruid, euid, suid)
uid_t *ruid, *euid, *suid;
{
int retval;
unsigned short r, e, s;
retval = getresuid(&r, &e, &s);
if (!retval) {
*ruid = r;
*euid = e;
*suid = s;
}
return retval;
int (*f)(uid_t *, uid_t *, uid_t *); /* getresuid signature */
f = dlsym(RTLD_NEXT, "getresuid");
if (!f) return -1;
return f(ruid, euid, suid);
}
static int
real_getresgid(rgid, egid, sgid)
gid_t *rgid, *egid, *sgid;
{
int retval;
unsigned short r, e, s;
retval = getresgid(&r, &e, &s);
if (!retval) {
*rgid = r;
*egid = e;
*sgid = s;
}
return retval;
int (*f)(gid_t *, gid_t *, gid_t *); /* getresgid signature */
f = dlsym(RTLD_NEXT, "getresgid");
if (!f) return -1;
return f(rgid, egid, sgid);
}
# else