mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Half-implemented process security
This commit is contained in:
parent
81469f51bd
commit
7abfd16ace
@ -1,18 +1,44 @@
|
||||
#include <task.hpp>
|
||||
|
||||
#include <vector.hpp>
|
||||
#include <rand.hpp>
|
||||
#include <debug.h>
|
||||
|
||||
namespace Tasking
|
||||
{
|
||||
struct TokenData
|
||||
{
|
||||
Token token;
|
||||
enum TokenTrustLevel TrustLevel;
|
||||
uint64_t OwnerID;
|
||||
bool Process;
|
||||
};
|
||||
|
||||
Vector<TokenData> Tokens;
|
||||
|
||||
Token Security::CreateToken()
|
||||
{
|
||||
fixme("CreateToken->0");
|
||||
return 0;
|
||||
uint64_t ret = Random::rand64();
|
||||
Tokens.push_back({ret, UnknownTrustLevel, 0, false});
|
||||
debug("Created token %#lx", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool Security::TrustToken(Token token,
|
||||
TokenTrustLevel TrustLevel)
|
||||
{
|
||||
fixme("TrustToken->false");
|
||||
enum TokenTrustLevel Level = static_cast<enum TokenTrustLevel>(TrustLevel);
|
||||
|
||||
foreach (auto var in Tokens)
|
||||
{
|
||||
if (var.token == token)
|
||||
{
|
||||
var.TrustLevel = Level;
|
||||
debug("Trusted token %#lx", token);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
debug("Failed to trust token %#lx", token);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -35,5 +61,8 @@ namespace Tasking
|
||||
|
||||
Security::~Security()
|
||||
{
|
||||
trace("Destroying Tasking Security");
|
||||
for (uint64_t i = 0; i < Tokens.size(); i++)
|
||||
Tokens.remove(i);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user