more things broken for now

- shell now uses the path env variable
- commands run based on permission of the bin file
This commit is contained in:
2026-09-03 12:27:32 +02:00
parent 2715e5e28e
commit 6cc9727091
4 changed files with 35 additions and 14 deletions
+14 -3
View File
@@ -1,4 +1,4 @@
import { COMMAND_REGISTRY } from "@core/command_registry";
import { type DirectoryNode } from "@core/filesystem/treenode";
import { createErrorResult, type Result } from "@core/result";
import { getCurrentSession } from "@core/session_manager";
import { withExitCode, withHistory, type ShellState } from "@core/shell_state";
@@ -6,6 +6,7 @@ import { SIGNAL_MAP } from "@core/signal";
import type { ShellError } from "@core/util/errors";
import { createImmutableBuffer } from "@core/util/immutable_buffer";
import { tokenize } from "@core/util/parser";
import { resolvePath } from "@core/util/path_resolver";
import { EventEmitter } from "./event_emitter";
import { ProcessManager } from "./process_manager";
@@ -63,7 +64,12 @@ export class Shell {
if (!parsed[0]) return;
this._State = withHistory(this._State, input);
const command = COMMAND_REGISTRY.get(parsed[0]);
const inode = resolvePath(this._State, this._State.env.get("PATH")!);
const node = this._State.filesystem.getNode(inode) as DirectoryNode;
const command = node.children[parsed[0]];
//const command = COMMAND_REGISTRY.get(parsed[0]);
if (!command) {
const encoded = new TextEncoder().encode(`Command ${parsed[0]} not found`);
@@ -82,7 +88,7 @@ export class Shell {
return;
}
if (command.requiresRoot && getCurrentSession(this._State).user.uid != 0) {
if (this._State.filesystem.canExecute(command, getCurrentSession(this._State).user)) {
const result = createErrorResult(
"PermissionDenied",
`Permission Denied`,
@@ -95,6 +101,11 @@ export class Shell {
return;
}
const bin = this._State.filesystem.getNode(command);
// read file content
// try to serialize it to a function
// call that function with a new process
parsed.shift();
const pid = this._ProcessManager.createProcess(this._State, command, parsed);