+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.
+
2002-07-01 Christopher Faylor <cgf@redhat.com>
* syscalls.cc (seteuid32): Fix incorrect placement of Pierre's patch
sigframe thisframe (mainthread);
path_conv real_b (b, PC_SYM_NOFOLLOW | PC_FULL);
path_conv real_a (a, PC_SYM_NOFOLLOW | PC_FULL);
-
+
if (real_a.error)
{
set_errno (real_a.error);
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;
}
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))))
if (cygheap->user.issetuid ()
&& !ImpersonateLoggedOnUser (cygheap->user.token))
system_printf ("Impersonating in seteuid failed: %E");
- if (uid == myself->uid)
- {
- syscall_printf ("special case, returning 0");
- return 0;
- }
return -1;
}
setegid32 (__gid32_t gid)
{
if ((!wincap.has_security ()) ||
+ (gid == myself->gid) ||
(gid == ILLEGAL_GID))
return 0;