refactor: capabilities - add unified launch routine
This commit is contained in:
1 parent
638dd9ee06
commit
5b90869101
9 files changed
+78
-61
No files matched your search
@@ -269,19 +269,8 @@ static inline void terminal_init(TerminalState* t, int cols, int rows) {
|
||||
terminal_init_cells(t, cols, rows, TERM_MAX_SCROLLBACK);
|
||||
t->cursor_visible = true;
|
||||
|
||||
// A console shell is a session launcher, exactly like the desktop, and is
|
||||
// granted on exactly the same terms: 0:/config/capabilities.toml decides
|
||||
// what shell.elf receives, and the kernel clamps that to what this session
|
||||
// was actually delegated. Deriving the grant here instead would be a
|
||||
// second, hardcoded list of "capabilities a console may confer" -- one the
|
||||
// table cannot see and cannot keep in step with.
|
||||
static constexpr const char* kShellPath = "0:/os/shell.elf";
|
||||
montauk::abi::SpawnCapabilities caps =
|
||||
montauk::caps::for_binary(kShellPath, montauk::caps::self_delegable());
|
||||
|
||||
t->child_pid = (caps.permitted != 0)
|
||||
? montauk::spawn_redir_with_caps(kShellPath, nullptr, caps)
|
||||
: montauk::spawn_redir(kShellPath);
|
||||
t->child_pid = montauk::caps::launch(kShellPath, {.redirected = true});
|
||||
if (t->child_pid > 0)
|
||||
montauk::childio_settermsz(t->child_pid, cols, rows);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user