From: cohrs Date: Sun, 21 Apr 2002 23:59:52 +0000 (+0000) Subject: more portable Gnome uid workaround X-Git-Tag: MOVE2GIT~2760 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=310e4661624bb751a7083a88bb557b2acb2a1e4e;p=nethack 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. --- diff --git a/doc/fixes34.1 b/doc/fixes34.1 index 68c9f11e6..5c05daaf2 100644 --- a/doc/fixes34.1 +++ b/doc/fixes34.1 @@ -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 diff --git a/sys/unix/unixres.c b/sys/unix/unixres.c index 390cc85d3..bf352ba62 100644 --- a/sys/unix/unixres.c +++ b/sys/unix/unixres.c @@ -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 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