Kernel: Add UID and GID fields to Task
This commit is contained in:
parent
3effe8b004
commit
16dc227a05
@ -36,6 +36,11 @@ struct Task
|
||||
|
||||
int64_t task_time = 0;
|
||||
|
||||
int uid;
|
||||
int euid;
|
||||
int gid;
|
||||
int egid;
|
||||
|
||||
Task* next_task = nullptr;
|
||||
Task* prev_task = nullptr;
|
||||
|
||||
@ -98,6 +103,8 @@ struct Task
|
||||
|
||||
Descriptor* descriptor_from_fd(int fd, int& error);
|
||||
|
||||
bool is_superuser();
|
||||
|
||||
private:
|
||||
void resume_read();
|
||||
void resume_wait();
|
||||
|
@ -45,6 +45,11 @@ void sys_fork(Context* context)
|
||||
|
||||
child->ppid = parent->id;
|
||||
|
||||
child->uid = parent->uid;
|
||||
child->euid = parent->euid;
|
||||
child->gid = parent->gid;
|
||||
child->egid = parent->egid;
|
||||
|
||||
child->regs.rax = 0;
|
||||
context->rax = child->id;
|
||||
|
||||
|
@ -3,6 +3,10 @@
|
||||
|
||||
#define ID_PID 0
|
||||
#define ID_PPID 1
|
||||
#define ID_UID 2
|
||||
#define ID_EUID 3
|
||||
#define ID_GID 4
|
||||
#define ID_EGID 5
|
||||
|
||||
void sys_getprocid(Context* context, int field)
|
||||
{
|
||||
@ -16,6 +20,26 @@ void sys_getprocid(Context* context, int field)
|
||||
context->rax = Scheduler::current_task()->ppid;
|
||||
return;
|
||||
}
|
||||
else if (field == ID_UID)
|
||||
{
|
||||
context->rax = Scheduler::current_task()->uid;
|
||||
return;
|
||||
}
|
||||
else if (field == ID_EUID)
|
||||
{
|
||||
context->rax = Scheduler::current_task()->euid;
|
||||
return;
|
||||
}
|
||||
else if (field == ID_GID)
|
||||
{
|
||||
context->rax = Scheduler::current_task()->gid;
|
||||
return;
|
||||
}
|
||||
else if (field == ID_EGID)
|
||||
{
|
||||
context->rax = Scheduler::current_task()->egid;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
context->rax = -EINVAL;
|
||||
|
@ -125,4 +125,9 @@ Descriptor* Task::descriptor_from_fd(int fd, int& error)
|
||||
return nullptr;
|
||||
}
|
||||
return &files[fd];
|
||||
}
|
||||
|
||||
bool Task::is_superuser()
|
||||
{
|
||||
return euid == 0;
|
||||
}
|
@ -3,5 +3,9 @@
|
||||
|
||||
#define ID_PID 0
|
||||
#define ID_PPID 1
|
||||
#define ID_UID 2
|
||||
#define ID_EUID 3
|
||||
#define ID_GID 4
|
||||
#define ID_EGID 5
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user