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