Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2002-07-02 07:06:32 +0400
committerChristopher Faylor <me@cgf.cx>2002-07-02 07:06:32 +0400
commite968058feddd4428598e3d9f17369eb5b7335039 (patch)
treed5b72d90adcf4754295c00a1f463b6516c85b7f4
parent3434e0c857d36be3b74495672db2aa4b6d806d97 (diff)
* 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.
-rw-r--r--winsup/cygwin/ChangeLog6
-rw-r--r--winsup/cygwin/syscalls.cc21
2 files changed, 16 insertions, 11 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index f2ab6b6ff..dadcec0e3 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,9 @@
+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
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 438cb7708..a66b69e8d 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -617,7 +617,7 @@ _link (const char *a, const char *b)
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);
@@ -1955,11 +1955,16 @@ mkfifo (const char *_path, mode_t mode)
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 @@ seteuid32 (__uid32_t uid)
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))))
@@ -2104,11 +2107,6 @@ seteuid32 (__uid32_t uid)
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;
}
@@ -2140,6 +2138,7 @@ extern "C" int
setegid32 (__gid32_t gid)
{
if ((!wincap.has_security ()) ||
+ (gid == myself->gid) ||
(gid == ILLEGAL_GID))
return 0;