Added privilidges
This commit is contained in:
41
kernel.c
41
kernel.c
@@ -36,8 +36,9 @@
|
||||
|
||||
/* Simple context passed to each Starling Terminal instance. */
|
||||
typedef struct {
|
||||
BootInfo *Boot;
|
||||
UINTN depth; /* 0 = top-level, 1+ = nested shells */
|
||||
BootInfo *Boot;
|
||||
UINTN depth; /* 0 = top-level, 1+ = nested shells */
|
||||
TaskPrivilege shell_priv; /* logical privilege for this shell */
|
||||
} StarlingContext;
|
||||
|
||||
/* ================================================================
|
||||
@@ -54,15 +55,18 @@ static void starling_terminal_task(void *arg)
|
||||
CHAR16 line[128];
|
||||
UINTN len = 0;
|
||||
UINTN depth = 0;
|
||||
TaskPrivilege shell_priv;
|
||||
|
||||
if (ctx == NULL || ctx->Boot == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
Boot = ctx->Boot;
|
||||
depth = ctx->depth;
|
||||
Boot = ctx->Boot;
|
||||
depth = ctx->depth;
|
||||
shell_priv = ctx->shell_priv;
|
||||
|
||||
SAFE_PRINT(Boot, L"\n\r[Starling Terminal depth %d] ready.\n\r\n\r", depth);
|
||||
SAFE_PRINT(Boot, L"\n\r[Starling Terminal depth %d, priv %d] ready.\n\r\n\r",
|
||||
depth, (INT32)shell_priv);
|
||||
SAFE_PRINT(Boot, L"starling> ");
|
||||
|
||||
while (TRUE) {
|
||||
@@ -114,10 +118,14 @@ static void starling_terminal_task(void *arg)
|
||||
SAFE_PRINT(Boot, L"Starling: failed to allocate nested terminal context.\n\r");
|
||||
SAFE_PRINT(Boot, L"starling> ");
|
||||
} else {
|
||||
child_ctx->Boot = Boot;
|
||||
child_ctx->depth = depth + 1;
|
||||
child_ctx->Boot = Boot;
|
||||
child_ctx->depth = depth + 1;
|
||||
child_ctx->shell_priv = shell_priv;
|
||||
|
||||
child_task = task_create(L"starling-term", starling_terminal_task, child_ctx);
|
||||
child_task = task_create_with_priv(L"starling-term",
|
||||
starling_terminal_task,
|
||||
child_ctx,
|
||||
shell_priv);
|
||||
if (child_task == NULL) {
|
||||
SAFE_PRINT(Boot, L"Starling: failed to spawn nested terminal.\n\r");
|
||||
kfree(child_ctx);
|
||||
@@ -132,7 +140,7 @@ static void starling_terminal_task(void *arg)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Task *cmd_task = execute_command(Boot, line);
|
||||
Task *cmd_task = execute_command(Boot, line, shell_priv);
|
||||
|
||||
/* If a command task was spawned, wait for it to finish. */
|
||||
if (cmd_task != NULL) {
|
||||
@@ -223,16 +231,21 @@ void kmain(BootInfo *Boot)
|
||||
if (ctx == NULL) {
|
||||
SAFE_PRINT(Boot, L"Failed to allocate Starling Terminal context; starting inline.\n\r");
|
||||
StarlingContext inline_ctx;
|
||||
inline_ctx.Boot = Boot;
|
||||
inline_ctx.depth = 0;
|
||||
inline_ctx.Boot = Boot;
|
||||
inline_ctx.depth = 0;
|
||||
inline_ctx.shell_priv = TASK_PRIV_USER;
|
||||
starling_terminal_task(&inline_ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
ctx->Boot = Boot;
|
||||
ctx->depth = 0;
|
||||
ctx->Boot = Boot;
|
||||
ctx->depth = 0;
|
||||
ctx->shell_priv = TASK_PRIV_USER;
|
||||
|
||||
terminal_task = task_create(L"starling-term", starling_terminal_task, ctx);
|
||||
terminal_task = task_create_with_priv(L"starling-term",
|
||||
starling_terminal_task,
|
||||
ctx,
|
||||
TASK_PRIV_USER);
|
||||
if (terminal_task == NULL) {
|
||||
SAFE_PRINT(Boot, L"Failed to start Starling Terminal task; falling back to kernel loop.\n\r");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user