* syscalls.cc (seteuid32): Treat ILLEGAL_UID invalid.

(setegid32): Treat ILLEGAL_GID invalid.
This commit is contained in:
Corinna Vinschen 2002-09-13 09:00:28 +00:00
parent a38b141548
commit 8934e4707d
2 changed files with 19 additions and 6 deletions

View File

@ -1,3 +1,8 @@
2002-09-13 Corinna Vinschen <corinna@vinschen.de>
* syscalls.cc (seteuid32): Treat ILLEGAL_UID invalid.
(setegid32): Treat ILLEGAL_GID invalid.
2002-09-10 Pierre Humblet <pierre.humblet@ieee.org> 2002-09-10 Pierre Humblet <pierre.humblet@ieee.org>
* grp.cc (initgroups): Call groups::clear_supp to free the * grp.cc (initgroups): Call groups::clear_supp to free the

View File

@ -1943,14 +1943,18 @@ seteuid32 (__uid32_t uid)
debug_printf ("uid: %d myself->gid: %d", uid, myself->gid); debug_printf ("uid: %d myself->gid: %d", uid, myself->gid);
if (!wincap.has_security () if (!wincap.has_security ()
|| (uid == myself->uid || (uid == myself->uid && !cygheap->user.groups.ischanged))
&& !cygheap->user.groups.ischanged)
|| uid == ILLEGAL_UID)
{ {
debug_printf ("Nothing happens"); debug_printf ("Nothing happens");
return 0; return 0;
} }
if (uid == ILLEGAL_UID)
{
set_errno (EINVAL);
return -1;
}
sigframe thisframe (mainthread); sigframe thisframe (mainthread);
cygsid usersid; cygsid usersid;
user_groups &groups = cygheap->user.groups; user_groups &groups = cygheap->user.groups;
@ -2122,11 +2126,15 @@ setuid (__uid16_t uid)
extern "C" int extern "C" int
setegid32 (__gid32_t gid) setegid32 (__gid32_t gid)
{ {
if ((!wincap.has_security ()) || if (!wincap.has_security () || gid == myself->gid)
(gid == myself->gid) ||
(gid == ILLEGAL_GID))
return 0; return 0;
if (gid == ILLEGAL_GID)
{
set_errno (EINVAL);
return -1;
}
sigframe thisframe (mainthread); sigframe thisframe (mainthread);
user_groups * groups = &cygheap->user.groups; user_groups * groups = &cygheap->user.groups;
cygsid gsid; cygsid gsid;