]> granicus.if.org Git - nethack/commitdiff
more portable Gnome uid workaround
authorcohrs <cohrs>
Sun, 21 Apr 2002 23:59:52 +0000 (23:59 +0000)
committercohrs <cohrs>
Sun, 21 Apr 2002 23:59:52 +0000 (23:59 +0000)
- 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.

doc/fixes34.1
sys/unix/unixres.c

index 68c9f11e61089b2b3aef6433953a21a9b3654c1e..5c05daaf2a7111ed73802766c7ee40ab360b4720 100644 (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
index 390cc85d3c4be4ffe14f5eef8b9a420ff02e7432..bf352ba6266aa143359b52d7513058e30298aa00 100644 (file)
 #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