Any ideas with xterm/xfree problem?

Pierre A. Humblet Pierre.Humblet@ieee.org
Mon Jul 1 19:57:00 GMT 2002


Chris,

Here is a better patch taking care of both uid and gid.
It was tested against the situations created by Harold
for xterm. AFAIK proper passwd/group are needed for ssh.

The goal is to allow seteuid/gid to itself even when passwd
and/or group are not properly setup.
Please revert the previous one.

Pierre


2002-07-01  Pierre Humblet <pierre.humblet@ieee.org>

	* syscalls.c (seteuid32): Return immediately if the program is
	not impersonated and both uid and gid are original.
	(setegid32): Return immediately if the new gid is the current egid.

--- syscalls.cc.orig    2002-07-01 22:00:30.000000000 -0400
+++ syscalls.cc 2002-07-01 22:11:12.000000000 -0400
@@ -1955,11 +1955,16 @@
 extern "C" int
 seteuid32 (__uid32_t uid)
 {
-  if (!wincap.has_security ()) return 0;
 
-  if (uid == ILLEGAL_UID)
+  debug_printf ("uid: %d myself->gid: %d", uid, myself->gid);
+
+  if (!wincap.has_security () ||
+      (!cygheap->user.issetuid () && 
+       uid == myself->uid &&
+       myself->gid == cygheap->user.orig_gid) ||
+      uid == ILLEGAL_UID)
     {
-      debug_printf ("new euid == illegal euid, nothing happens");
+      debug_printf ("Nothing happens");
       return 0;
     }
 
@@ -1971,8 +1976,6 @@
   struct passwd * pw_new;
   PSID origpsid, psid2 = NO_SID;
 
-  debug_printf ("uid: %d myself->gid: %d", uid, myself->gid);
-
   pw_new = getpwuid32 (uid);
   if (!usersid.getfrompw (pw_new) ||
       (!pgrpsid.getfromgr (getgrgid32 (myself->gid))))
@@ -2134,6 +2137,7 @@
 setegid32 (__gid32_t gid)
 {
   if ((!wincap.has_security ()) ||
+      (gid == myself->gid) ||
       (gid == ILLEGAL_GID))
     return 0;



More information about the Cygwin-patches mailing list