2003-07-18 Pierre Humblet <pierre.humblet@ieee.org>
* security.cc (verify_token): Fix white space and style. Use type bool instead of BOOL and char. Use alloca instead of malloc and free for my_grps.
This commit is contained in:
parent
19c6e1624b
commit
b4ece40c0f
|
@ -1,3 +1,9 @@
|
||||||
|
2003-07-18 Pierre Humblet <pierre.humblet@ieee.org>
|
||||||
|
|
||||||
|
* security.cc (verify_token): Fix white space and style.
|
||||||
|
Use type bool instead of BOOL and char. Use alloca
|
||||||
|
instead of malloc and free for my_grps.
|
||||||
|
|
||||||
2003-07-17 Corinna Vinschen <corinna@vinschen.de>
|
2003-07-17 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* sysconf.cc (sysconf): Fix OPEN_MAX patch. Return page size on
|
* sysconf.cc (sysconf): Fix OPEN_MAX patch. Return page size on
|
||||||
|
|
|
@ -744,30 +744,26 @@ verify_token (HANDLE token, cygsid &usersid, user_groups &groups, BOOL *pintern)
|
||||||
return gsid == groups.pgsid;
|
return gsid == groups.pgsid;
|
||||||
}
|
}
|
||||||
|
|
||||||
PTOKEN_GROUPS my_grps = NULL;
|
PTOKEN_GROUPS my_grps;
|
||||||
BOOL ret = FALSE;
|
bool saw_buf[NGROUPS_MAX] = {};
|
||||||
char saw_buf[NGROUPS_MAX] = {};
|
bool *saw = saw_buf, sawpg = false, ret = false;
|
||||||
char *saw = saw_buf, sawpg = FALSE;
|
|
||||||
|
|
||||||
if (!GetTokenInformation (token, TokenGroups, NULL, 0, &size) &&
|
if (!GetTokenInformation (token, TokenGroups, NULL, 0, &size) &&
|
||||||
GetLastError () != ERROR_INSUFFICIENT_BUFFER)
|
GetLastError () != ERROR_INSUFFICIENT_BUFFER)
|
||||||
debug_printf ("GetTokenInformation(token, TokenGroups): %E");
|
debug_printf ("GetTokenInformation(token, TokenGroups): %E");
|
||||||
else if (!(my_grps = (PTOKEN_GROUPS) malloc (size)))
|
else if (!(my_grps = (PTOKEN_GROUPS) alloca (size)))
|
||||||
debug_printf ("malloc (my_grps) failed.");
|
debug_printf ("alloca (my_grps) failed.");
|
||||||
else if (!GetTokenInformation (token, TokenGroups, my_grps, size, &size))
|
else if (!GetTokenInformation (token, TokenGroups, my_grps, size, &size))
|
||||||
debug_printf ("GetTokenInformation(my_token, TokenGroups): %E");
|
debug_printf ("GetTokenInformation(my_token, TokenGroups): %E");
|
||||||
else if (!groups.issetgroups ()) /* setgroups was never called */
|
else if (!groups.issetgroups ()) /* setgroups was never called */
|
||||||
{
|
ret = sid_in_token_groups (my_grps, groups.pgsid)
|
||||||
ret = sid_in_token_groups (my_grps, groups.pgsid);
|
|| groups.pgsid == usersid;
|
||||||
if (ret == FALSE)
|
|
||||||
ret = (groups.pgsid == tok_usersid);
|
|
||||||
}
|
|
||||||
else /* setgroups was called */
|
else /* setgroups was called */
|
||||||
{
|
{
|
||||||
struct __group32 *gr;
|
struct __group32 *gr;
|
||||||
cygsid gsid;
|
cygsid gsid;
|
||||||
if (groups.sgsids.count > (int) sizeof (saw_buf) &&
|
if (groups.sgsids.count > (int) (sizeof (saw_buf) / sizeof (*saw_buf))
|
||||||
!(saw = (char *) calloc (groups.sgsids.count, sizeof (char))))
|
&& !(saw = (bool *) calloc (groups.sgsids.count, sizeof (bool))))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
/* token groups found in /etc/group match the user.gsids ? */
|
/* token groups found in /etc/group match the user.gsids ? */
|
||||||
|
@ -776,24 +772,21 @@ verify_token (HANDLE token, cygsid &usersid, user_groups &groups, BOOL *pintern)
|
||||||
{
|
{
|
||||||
int pos = groups.sgsids.position (gsid);
|
int pos = groups.sgsids.position (gsid);
|
||||||
if (pos >= 0)
|
if (pos >= 0)
|
||||||
saw[pos] = TRUE;
|
saw[pos] = true;
|
||||||
else if (groups.pgsid == gsid)
|
else if (groups.pgsid == gsid)
|
||||||
sawpg = TRUE;
|
sawpg = true;
|
||||||
else if (gsid != well_known_world_sid &&
|
else if (gsid != well_known_world_sid
|
||||||
gsid != usersid)
|
&& gsid != usersid)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
for (int gidx = 0; gidx < groups.sgsids.count; gidx++)
|
for (int gidx = 0; gidx < groups.sgsids.count; gidx++)
|
||||||
if (!saw[gidx])
|
if (!saw[gidx])
|
||||||
goto done;
|
goto done;
|
||||||
if (sawpg ||
|
ret = sawpg
|
||||||
groups.sgsids.contains (groups.pgsid) ||
|
|| groups.sgsids.contains (groups.pgsid)
|
||||||
groups.pgsid == usersid)
|
|| groups.pgsid == usersid;
|
||||||
ret = TRUE;
|
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
if (my_grps)
|
|
||||||
free (my_grps);
|
|
||||||
if (saw != saw_buf)
|
if (saw != saw_buf)
|
||||||
free (saw);
|
free (saw);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue