* sec_helper.cc (cygsid::get_id): If the sid matches a sid stored in
cygheap->user, return the uid or gid from myself. * security.cc (alloc_sd): If gid == myself->gid, return the group sid from cygheap->user. Remove the test for uid == original_uid, which is counter-productive.
This commit is contained in:
parent
1cc651ecaf
commit
329b9ead3e
|
@ -1,3 +1,11 @@
|
||||||
|
2002-10-22 Pierre Humblet <pierre.humblet@ieee.org>
|
||||||
|
|
||||||
|
* sec_helper.cc (cygsid::get_id): If the sid matches a sid stored in
|
||||||
|
cygheap->user, return the uid or gid from myself.
|
||||||
|
* security.cc (alloc_sd): If gid == myself->gid, return the group sid
|
||||||
|
from cygheap->user. Remove the test for uid == original_uid, which is
|
||||||
|
counter-productive.
|
||||||
|
|
||||||
2002-10-22 Christopher Faylor <cgf@redhat.com>
|
2002-10-22 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
* cygheap.cc (cygheap_fixup_in_child): Use user_heap element in
|
* cygheap.cc (cygheap_fixup_in_child): Use user_heap element in
|
||||||
|
|
|
@ -162,14 +162,17 @@ cygsid::get_id (BOOL search_grp, int *type)
|
||||||
if (!search_grp)
|
if (!search_grp)
|
||||||
{
|
{
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
for (int pidx = 0; (pw = internal_getpwent (pidx)); ++pidx)
|
if (EqualSid(psid, cygheap->user.sid ()))
|
||||||
{
|
id = myself->uid;
|
||||||
if (sid.getfrompw (pw) && sid == psid)
|
else
|
||||||
{
|
for (int pidx = 0; (pw = internal_getpwent (pidx)); ++pidx)
|
||||||
id = pw->pw_uid;
|
{
|
||||||
break;
|
if (sid.getfrompw (pw) && sid == psid)
|
||||||
}
|
{
|
||||||
}
|
id = pw->pw_uid;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (id >= 0)
|
if (id >= 0)
|
||||||
{
|
{
|
||||||
if (type)
|
if (type)
|
||||||
|
@ -180,14 +183,17 @@ cygsid::get_id (BOOL search_grp, int *type)
|
||||||
if (search_grp || type)
|
if (search_grp || type)
|
||||||
{
|
{
|
||||||
struct __group32 *gr;
|
struct __group32 *gr;
|
||||||
for (int gidx = 0; (gr = internal_getgrent (gidx)); ++gidx)
|
if (cygheap->user.groups.pgsid == psid)
|
||||||
{
|
id = myself->gid;
|
||||||
if (sid.getfromgr (gr) && sid == psid)
|
else
|
||||||
{
|
for (int gidx = 0; (gr = internal_getgrent (gidx)); ++gidx)
|
||||||
id = gr->gr_gid;
|
{
|
||||||
break;
|
if (sid.getfromgr (gr) && sid == psid)
|
||||||
}
|
{
|
||||||
}
|
id = gr->gr_gid;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (id >= 0)
|
if (id >= 0)
|
||||||
{
|
{
|
||||||
if (type)
|
if (type)
|
||||||
|
|
|
@ -1536,9 +1536,7 @@ alloc_sd (__uid32_t uid, __gid32_t gid, int attribute,
|
||||||
/* Check for current user first */
|
/* Check for current user first */
|
||||||
if (uid == myself->uid)
|
if (uid == myself->uid)
|
||||||
owner_sid = cygheap->user.sid ();
|
owner_sid = cygheap->user.sid ();
|
||||||
else if (uid == cygheap->user.orig_uid)
|
else
|
||||||
owner_sid = cygheap->user.orig_sid ();
|
|
||||||
if (!owner_sid)
|
|
||||||
{
|
{
|
||||||
/* Otherwise retrieve user data from /etc/passwd */
|
/* Otherwise retrieve user data from /etc/passwd */
|
||||||
struct passwd *pw = getpwuid32 (uid);
|
struct passwd *pw = getpwuid32 (uid);
|
||||||
|
@ -1559,12 +1557,17 @@ alloc_sd (__uid32_t uid, __gid32_t gid, int attribute,
|
||||||
|
|
||||||
/* Get SID of new group. */
|
/* Get SID of new group. */
|
||||||
cygsid group_sid (NO_SID);
|
cygsid group_sid (NO_SID);
|
||||||
struct __group32 *grp = getgrgid32 (gid);
|
/* Check for current user first */
|
||||||
if (!grp)
|
if (gid == myself->gid)
|
||||||
debug_printf ("no /etc/group entry for %d", gid);
|
group_sid = cygheap->user.groups.pgsid;
|
||||||
else if (!group_sid.getfromgr (grp))
|
else
|
||||||
debug_printf ("no SID for group %d", gid);
|
{
|
||||||
|
struct __group32 *grp = getgrgid32 (gid);
|
||||||
|
if (!grp)
|
||||||
|
debug_printf ("no /etc/group entry for %d", gid);
|
||||||
|
else if (!group_sid.getfromgr (grp))
|
||||||
|
debug_printf ("no SID for group %d", gid);
|
||||||
|
}
|
||||||
/* Initialize local security descriptor. */
|
/* Initialize local security descriptor. */
|
||||||
SECURITY_DESCRIPTOR sd;
|
SECURITY_DESCRIPTOR sd;
|
||||||
PSECURITY_DESCRIPTOR psd = NULL;
|
PSECURITY_DESCRIPTOR psd = NULL;
|
||||||
|
|
Loading…
Reference in New Issue