kernel/team: Remove team_get_team_struct, add team_geteuid.

Thanks to Axel for the review.
This commit is contained in:
Augustin Cavalier
2019-07-07 22:51:09 -04:00
parent 05901d8963
commit 5c97129ce3
2 changed files with 14 additions and 15 deletions
+2 -7
View File
@@ -2859,13 +2859,8 @@ _user_install_default_debugger(port_id debuggerPort)
port_id
_user_install_team_debugger(team_id teamID, port_id debuggerPort)
{
if (geteuid() != 0) {
Team* team = team_get_team_struct(teamID);
if (team == NULL)
return B_BAD_VALUE;
if (team->effective_uid != geteuid())
return B_PERMISSION_DENIED;
}
if (geteuid() != 0 && team_geteuid(teamID) != geteuid())
return B_PERMISSION_DENIED;
return install_team_debugger(teamID, debuggerPort, -1, false, false);
}
+12 -8
View File
@@ -2918,15 +2918,8 @@ team_is_valid(team_id id)
if (id <= 0)
return false;
return team_get_team_struct(id) != NULL;
}
Team*
team_get_team_struct(team_id id)
{
InterruptsReadSpinLocker teamsLocker(sTeamHashLock);
return team_get_team_struct_locked(id);
return team_get_team_struct_locked(id) != NULL;
}
@@ -3021,6 +3014,17 @@ team_set_foreground_process_group(int32 ttyIndex, pid_t processGroupID)
}
uid_t
team_geteuid(team_id id)
{
InterruptsReadSpinLocker teamsLocker(sTeamHashLock);
Team* team = team_get_team_struct_locked(id);
if (team == NULL)
return (uid_t)-1;
return team->effective_uid;
}
/*! Removes the specified team from the global team hash, from its process
group, and from its parent.
It also moves all of its children to the kernel team.