* security.cc (alloc_sd): Remove unnecessary retrieval of owner name.

Check uid for current user first and use SIDs from cygheap if so.
	Set errno to EINVAL if user SID isn't retrievable.  Just print user SID
	as debug output.
	Don't bail out if group SID isn't retrievable.  Change debug output
	appropriately.
This commit is contained in:
Corinna Vinschen 2002-06-21 12:37:51 +00:00
parent f42d18eaeb
commit dd0208eb34
2 changed files with 38 additions and 17 deletions

View File

@ -1,3 +1,12 @@
2002-06-21 Corinna Vinschen <corinna@vinschen.de>
* security.cc (alloc_sd): Remove unnecessary retrieval of owner name.
Check uid for current user first and use SIDs from cygheap if so.
Set errno to EINVAL if user SID isn't retrievable. Just print user SID
as debug output.
Don't bail out if group SID isn't retrievable. Change debug output
appropriately.
2002-06-21 Christopher Faylor <cgf@redhat.com> 2002-06-21 Christopher Faylor <cgf@redhat.com>
* errno.cc: Change text description for EBADF throughout. * errno.cc: Change text description for EBADF throughout.

View File

@ -1367,27 +1367,39 @@ alloc_sd (__uid32_t uid, __gid32_t gid, int attribute,
return NULL; return NULL;
} }
/* Get SID and name of new owner. */ /* Get SID of owner. */
char owner[UNLEN + 1];
cygsid owner_sid; cygsid owner_sid;
struct passwd *pw = getpwuid32 (uid); /* Check for current user first */
strcpy (owner, pw ? pw->pw_name : getlogin ()); if (uid == myself->uid)
if (!pw || !owner_sid.getfrompw (pw)) owner_sid = cygheap->user.sid ();
return NULL; else if (uid == cygheap->user.orig_uid)
debug_printf ("owner: %s [%d]", owner, owner_sid = cygheap->user.orig_sid ();
*GetSidSubAuthority (owner_sid, else
*GetSidSubAuthorityCount (owner_sid) - 1));
/* Get SID and name of new group. */
cygsid group_sid (NO_SID);
struct __group32 *grp = getgrgid32 (gid);
if (grp)
{ {
if (!grp || !group_sid.getfromgr (grp)) /* Otherwise retrieve user data from /etc/passwd */
struct passwd *pw = getpwuid32 (uid);
if (!pw)
{
debug_printf ("no /etc/passwd entry for %d", uid);
set_errno (EINVAL);
return NULL; return NULL;
} }
else else if (!owner_sid.getfrompw (pw))
debug_printf ("no group"); {
debug_printf ("no SID for user %d", uid);
set_errno (EINVAL);
return NULL;
}
}
owner_sid.debug_print ("alloc_sd: owner SID =");
/* Get SID of new group. */
cygsid group_sid (NO_SID);
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;