summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.zig30
-rw-r--r--docs/next-tests.md2
-rw-r--r--docs/typ/building.typ19
-rw-r--r--docs/typ/builtins-gui.json1
-rw-r--r--docs/typ/builtins-tty.json1
-rw-r--r--docs/typ/cheatsheet.typ1
-rw-r--r--docs/typ/reference.typ9
-rw-r--r--src/9p_io.zig2
-rw-r--r--src/CHANGELOG.md3
-rw-r--r--src/builtins.zig11
-rw-r--r--src/config.zig1
-rw-r--r--src/exec.zig30
-rw-r--r--src/fs-help.txt2
-rw-r--r--src/host_io.zig16
-rw-r--r--src/linux/v9fs.zig201
-rw-r--r--src/panes.zig2
-rw-r--r--src/pardes.zig19
-rw-r--r--test/v9fs.py196
-rw-r--r--test/v9fs_driver_test.py26
-rw-r--r--test/v9fs_terminal.py108
20 files changed, 10 insertions, 670 deletions
diff --git a/build.zig b/build.zig
index c90485b6..bb2b8641 100644
--- a/build.zig
+++ b/build.zig
@@ -1748,36 +1748,6 @@ pub fn build(b: *std.Build) void {
run_discovery.has_side_effects = true;
b.step("fs-discovery-test", "test browsable pane creation over 9P").dependOn(&run_discovery.step);
- if (target.result.os.tag == .linux) {
- const v9fs_helper = b.addExecutable(.{
- .name = "pardes-v9fs",
- .root_module = b.createModule(.{
- .root_source_file = b.path("src/linux/v9fs.zig"),
- .target = target,
- .optimize = requested_optimize,
- .link_libc = true,
- }),
- });
- // Ordinary executable; each launch asks sudo inside its own PTY.
- installHome(b, v9fs_helper, home_bin);
- const run_v9fs = b.addSystemCommand(&.{ "python3", "-B", "test/v9fs.py" });
- run_v9fs.addArtifactArg(exe);
- run_v9fs.addArtifactArg(v9fs_helper);
- run_v9fs.setCwd(b.path("."));
- run_v9fs.has_side_effects = true;
- b.step("v9fs-test", "probe Linux kernel 9P mounts in a private subprocess namespace (requires sudo -v)").dependOn(&run_v9fs.step);
- const run_v9fs_driver = b.addSystemCommand(&.{ "python3", "-B", "test/v9fs_driver_test.py" });
- run_v9fs_driver.setCwd(b.path("."));
- run_v9fs_driver.has_side_effects = true;
- b.step("v9fs-driver-test", "test kernel-mount probe launcher without privileges or compiling the editor").dependOn(&run_v9fs_driver.step);
- const run_v9fs_terminal = b.addSystemCommand(&.{ "python3", "-B", "test/v9fs_terminal.py" });
- run_v9fs_terminal.addArtifactArg(exe);
- run_v9fs_terminal.addArtifactArg(v9fs_helper);
- run_v9fs_terminal.setCwd(b.path("."));
- run_v9fs_terminal.has_side_effects = true;
- b.step("v9fs-terminal-test", "exercise Tty9p authentication routing and cleanup without mount privileges").dependOn(&run_v9fs_terminal.step);
- }
-
const run_agent_session_test = b.addSystemCommand(&.{ "python3", "-B", "test/agent_session_test.py" });
run_agent_session_test.addArtifactArg(exe);
if (platform == .gui) run_agent_session_test.addArg("--gui-grid");
diff --git a/docs/next-tests.md b/docs/next-tests.md
index b7b5d3ef..5b4f3f0d 100644
--- a/docs/next-tests.md
+++ b/docs/next-tests.md
@@ -38,7 +38,7 @@ agent's survey. The `e2e` line (kbdin, mousein) is its first step.
- **snap9p** reads /screen through `Files`.
The Python suites in the build (fs.py, monkey9p.py, gui_monkey.py,
- v9fs*.py, agent_session_test.py) move onto it or onto Session, then
+ agent_session_test.py) move onto it or onto Session, then
leave the build. The developer tools (ui_review, record_demos,
appearance_gallery…) stay Python, as examples. A real process performs
its effects, so tests that need one can land at T2.
diff --git a/docs/typ/building.typ b/docs/typ/building.typ
index d8c089f6..b1d8d127 100644
--- a/docs/typ/building.typ
+++ b/docs/typ/building.typ
@@ -16,7 +16,7 @@ builds MuPDF and is on by default (`-Dmupdf=false` drops it). 9P over QUIC
(`-Dquic=true`) uses system OpenSSL 3.6+ and pkg-config.
#pairs(
- [`zig build`], [the terminal shell and the SDL window together, *installed into `~/.local/bin`* (`pardes`, `pardes-gui`, and `pardes-v9fs`, the #word("Tty9p") helper)],
+ [`zig build`], [the terminal shell and the SDL window together, *installed into `~/.local/bin`* (`pardes` and `pardes-gui`)],
[`zig build -Dplatform=tty`], [the terminal shell alone],
[`zig build -Dplatform=gui`], [the SDL3 window alone],
[`zig build web -Dplatform=web -Dtarget=wasm32-freestanding -Ddump=<file>`], [a freestanding wasm core plus vanilla JavaScript (`docs/web.md`)],
@@ -85,7 +85,6 @@ zig build agent-session-test interactive session driver checks over 9P
zig build 9p-test freestanding protocol tests
zig build 9p-io-test native 9P transports and client
zig build quic-test -Dquic=true optional QUIC transport tests
-zig build v9fs-test a real kernel mount (needs sudo -v; fails, not skips, without it)
zig build snap scripted input traces against frozen golden grids
zig build monkey random snapshot scripts hunting panics (not a gate)
zig build hxdiff differential suite against helix's own behaviour
@@ -314,7 +313,7 @@ symlink whose socket refuses a connect is removed with its socket. pardes
binds its own socket rather than going through `cloud9.post`, which takes
only flat names. A reader of the registry must `stat` through the symlink.
-== Kernel mounts and Tty9p
+== Kernel mounts
For Linux v9fs use `version=9p2000,cache=none,access=any`, `trans=unix`
(or `trans=tcp` with `port=`), `uname`, `dfltuid` and `dfltgid` for the
@@ -322,20 +321,6 @@ local user, and an empty `aname`. Linux follows `O_TRUNC` with a `Twstat`
of zero length and an `mtime` hint; pardes takes the truncation and drops
the hint.
-#word("Tty9p") starts the normal shell and queues a quoted helper command,
-which bash and fish run at their first prompt as a foreground job, so
-sudo has the terminal. The unprivileged launcher makes a private temporary
-mountpoint and runs `sudo -E`; the elevated `pardes-v9fs` helper makes a
-private mount namespace, mounts the session's socket with
-`trans=unix,version=9p2000,cache=none,access=any,nosuid,nodev,noexec`,
-drops every root id and capability, and runs the shell as the user (with
-the caller's `PATH` again). The namespace and the mount go with its last
-process. Nothing setuid and no passwordless sudo rule is installed; the
-helper takes explicit paths and a command and is no restricted broker, so
-never grant it passwordless sudo. The host finds the helper beside its own
-executable, or at `PARDES_V9FS_HELPER`. Code: `src/linux/v9fs.zig`;
-`zig build v9fs-terminal-test` and `v9fs-driver-test` need no privileges.
-
= Other notes
`docs/` keeps the platform and design notes beside this book:
diff --git a/docs/typ/builtins-gui.json b/docs/typ/builtins-gui.json
index e731b75e..c7553186 100644
--- a/docs/typ/builtins-gui.json
+++ b/docs/typ/builtins-gui.json
@@ -146,7 +146,6 @@
{"name": "TreeContext", "leader": null, "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Show the declarations enclosing the top row at the pane's head, on or off."},
{"name": "TreeContextTagStyle", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "A pane's TreeContext rows draw in the tag's style, on or off."},
{"name": "Tty", "leader": "SPC n t", "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "A shell in the calling pane's directory, raw from the first frame."},
- {"name": "Tty9p", "leader": "SPC n 9", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "A Linux terminal with the current session mounted through kernel v9fs."},
{"name": "Tutor", "leader": "SPC h t", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Open the tutor, a document to work through."},
{"name": "Unattach", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Unattach a pane from the pane it answers for: it stays where it is, a pane of its own, and the next search from that pane opens another under it."},
{"name": "Undo", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "acme's Undo and Redo: step the pane's body back or forward through its edits, from a tag, a pane ctl or exec."},
diff --git a/docs/typ/builtins-tty.json b/docs/typ/builtins-tty.json
index fe81b3fa..613627a7 100644
--- a/docs/typ/builtins-tty.json
+++ b/docs/typ/builtins-tty.json
@@ -129,7 +129,6 @@
{"name": "TreeContext", "leader": null, "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Show the declarations enclosing the top row at the pane's head, on or off."},
{"name": "TreeContextTagStyle", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "A pane's TreeContext rows draw in the tag's style, on or off."},
{"name": "Tty", "leader": "SPC n t", "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "A shell in the calling pane's directory, raw from the first frame."},
- {"name": "Tty9p", "leader": "SPC n 9", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "A Linux terminal with the current session mounted through kernel v9fs."},
{"name": "Tutor", "leader": "SPC h t", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Open the tutor, a document to work through."},
{"name": "Unattach", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Unattach a pane from the pane it answers for: it stays where it is, a pane of its own, and the next search from that pane opens another under it."},
{"name": "Undo", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "acme's Undo and Redo: step the pane's body back or forward through its edits, from a tag, a pane ctl or exec."},
diff --git a/docs/typ/cheatsheet.typ b/docs/typ/cheatsheet.typ
index a831273b..a70b56e2 100644
--- a/docs/typ/cheatsheet.typ
+++ b/docs/typ/cheatsheet.typ
@@ -92,7 +92,6 @@ Helix-style: motions *select*, then an edit acts on the selection. Mode box: bla
key("SPC f c"), word("Config"),
key("SPC d"), word("Del"),
key("SPC n t"), word("Tty"),
- key("SPC n 9"), word("Tty9p"),
key("SPC w"), word("Window"),
key("SPC j j"), word("Last"),
key("SPC j l"), word("Jumplist"),
diff --git a/docs/typ/reference.typ b/docs/typ/reference.typ
index 45863f04..b272306c 100644
--- a/docs/typ/reference.typ
+++ b/docs/typ/reference.typ
@@ -1118,15 +1118,8 @@ every pane pardes spawns gets it as `$PARDES_MOUNT`. Under `9ns --unix SOCK
plan9port's `9p write` opens with OTRUNC, so on #file("body") it replaces
the whole text. To append, use `>>` through a mount. Through a FUSE mount
bash's `read -t` cannot time out: wrap a follow loop in `timeout`. The
-scripting chapter's rule (a mount, else `9p`) covers most uses. Two more:
+scripting chapter's rule (a mount, else `9p`) covers most uses. One more:
-- #word("Tty9p") (#key("SPC n 9")) opens a terminal with the session
- kernel-mounted (Linux v9fs): it asks for your sudo password in the pane,
- mounts the socket in a private mount namespace and starts your shell as
- you, with `PARDES_MOUNT` naming the mount. Only that shell sees it, and
- each takes one of the session's 16 connections. It needs the `9p` and
- `9pnet_fd` kernel modules and the `pardes-v9fs` helper the build installs
- beside `pardes`.
- `test/ninep.py` is a Python 9P client that exists only in the source tree
(it is not installed). It is for when nothing is mounted and `9p` is not
there, or when a fid must stay open (#file("event"), #file("pty/data"), a
diff --git a/src/9p_io.zig b/src/9p_io.zig
index 377440bd..7ae341bd 100644
--- a/src/9p_io.zig
+++ b/src/9p_io.zig
@@ -2283,7 +2283,7 @@ fn exportEnv(socket: ?[]const u8, serial: u32, adopts: bool) void {
/// `$NINE_MOUNT/pardes/<name>`, the name the registry gives the socket.
/// Any other $NINE_MOUNT is a mount of another server, made before this
/// session had a socket: unknown, so unset, and a script falls back to
-/// `9p -a "unix!$PARDES_9P"`. A Tty9p shell sets its own (linux/v9fs.zig).
+/// `9p -a "unix!$PARDES_9P"`.
fn exportMount(sock_path: []const u8) void {
const mntgen = if (libc.getenv("NINE_MNTGEN")) |v| std.mem.eql(u8, std.mem.span(v), "1") else false;
const root = if (libc.getenv("NINE_MOUNT")) |v| std.mem.span(v) else "";
diff --git a/src/CHANGELOG.md b/src/CHANGELOG.md
index fff21d83..f6607176 100644
--- a/src/CHANGELOG.md
+++ b/src/CHANGELOG.md
@@ -25,6 +25,9 @@
- A click on a tag, a column's or the workspace's puts its cursor there
in normal mode, where it put it in insert mode: `i` types there, Enter
or Tab runs the word under it.
+- `Tty9p` and its `pardes-v9fs` helper are gone (a terminal with the
+ session kernel-mounted through Linux v9fs, a one-off), with their tests;
+ a kernel mount made by hand still works, as the build notes say.
- One `pardes --daemon` per user keeps sessions, started by the first
session and gone once it keeps nothing. `pardes` in a terminal forks
its session off and stays as its stub: `Detach` (`SPC s D`), or a
diff --git a/src/builtins.zig b/src/builtins.zig
index 38a4d835..dc50b85c 100644
--- a/src/builtins.zig
+++ b/src/builtins.zig
@@ -1486,17 +1486,6 @@ pub const Tty = struct {
}
};
-/// A Linux terminal with the current session mounted through kernel v9fs.
-/// A word of every hosted build, Linux's or not: a build's words are its
-/// Help's rows, which a replica of another build's session makes as its
-/// session did (a Linux client of a FreeBSD one diverged at SPC ?).
-pub const Tty9p = struct {
- pub const enabled = pardes.hosted;
- pub fn run(c: Ctx) void {
- exec.spawnV9fsTty(c.p, c.id);
- }
-};
-
/// Binds this terminal as a language's REPL, so an exec on that language's
/// files is typed into it instead of run. The language is named as the
/// syntax table has it: an exec made on the body of a file in that
diff --git a/src/config.zig b/src/config.zig
index c1f1981c..603e51f2 100644
--- a/src/config.zig
+++ b/src/config.zig
@@ -209,7 +209,6 @@ pub const leader_path = paths: {
}
if (builtins.EffectCode.enabled) table.set(.EffectCode, null);
if (builtins.TreeContext.enabled) table.set(.TreeContext, null);
- if (builtins.Tty9p.enabled) table.set(.Tty9p, "n9");
if (pardes.hosted) {
table.set(.ThemeFile, null);
table.set(.DumpThemes, null);
diff --git a/src/exec.zig b/src/exec.zig
index af312c45..ad051c32 100644
--- a/src/exec.zig
+++ b/src/exec.zig
@@ -43,10 +43,6 @@ pub fn takesCommandLine(p: *const Pardes, id: usize) bool {
// (Text in pardes's own edit buffer is not the shell's yet: an exec of
// it, or of anything, types only what it runs.)
if (panes.terminal.promptInputReady(pane) and !panes.terminal.promptInputEmpty(pane)) return false;
- // A mounted shell sits behind sudo's process supervisor. Its OSC 133
- // prompt marks identify input readiness; the launcher's executable is
- // not the shell executable used by the ordinary process heuristic.
- if (pane.v9fs_on_spawn) return panes.terminal.promptInputReady(pane);
return !p.hostTtyTaken(id);
}
@@ -405,29 +401,6 @@ fn askWrite(p: *Pardes, id: usize, serial: u32, path: []const u8) void {
/// Tty: a shell in the caller's directory, raw from the first frame,
/// stacked below the caller like Alt-n's new shell.
pub fn spawnTty(p: *Pardes, from: usize) ?*Pane {
- return spawnTtyWithMount(p, from, false);
-}
-
-pub fn spawnV9fsTty(p: *Pardes, from: usize) void {
- if (comptime !hosted) return p.reportError(from, "Tty9p", error.LinuxRequired);
- // The session's host's and its 9P server's: a replica, of another
- // build too (a Linux client of a FreeBSD session), has their answers.
- if (!pardes.tape.authority(onLinux, .{}))
- return p.reportError(from, "Tty9p", error.LinuxRequired);
- if (!pardes.tape.authority(servesSocket, .{p}))
- return p.reportError(from, "Tty9p", error.SessionSocketRequired);
- _ = spawnTtyWithMount(p, from, true);
-}
-
-fn onLinux() bool {
- return @import("builtin").os.tag == .linux;
-}
-
-fn servesSocket(p: *Pardes) bool {
- return p.fs.socket_path.len != 0;
-}
-
-fn spawnTtyWithMount(p: *Pardes, from: usize, v9fs: bool) ?*Pane {
// No pane asking (an empty window's tag): the session's directory, as
// New's scratch is.
// A directory that is not there makes no terminal: its shell could not
@@ -451,8 +424,7 @@ fn spawnTtyWithMount(p: *Pardes, from: usize, v9fs: bool) ?*Pane {
p.reportError(from, "Tty", err);
return null;
};
- nt.greet = !v9fs;
- nt.v9fs_on_spawn = v9fs;
+ nt.greet = true;
nt.body.mode = .tty;
placeNew(p, from, from, free, .shell);
if (refusedPlacement(p, free)) {
diff --git a/src/fs-help.txt b/src/fs-help.txt
index b62a13b8..35594e6d 100644
--- a/src/fs-help.txt
+++ b/src/fs-help.txt
@@ -23,7 +23,7 @@ pane/<n>/ name body tag ctl addr dot limit data xdata sel dirty mark scroll er
on terminals pty/data (keys in, output out), pty/status, pty/ctl (winsize, sig, exec), pty/run (a line, its exit and output)
os/, src/ the host filesystem; the editor's own sources
-$m below: $PARDES_MOUNT (set under 9ns --mntgen and in a Tty9p shell); without it, 9p -a "unix!$PARDES_9P".
+$m below: $PARDES_MOUNT (set under 9ns --mntgen); without it, 9p -a "unix!$PARDES_9P".
cat $m/index which panes exist
n=$(cat $m/pane/new) make a pane of your own (each open makes one), take its serial
diff --git a/src/host_io.zig b/src/host_io.zig
index b1ed8b4b..3b91ea7e 100644
--- a/src/host_io.zig
+++ b/src/host_io.zig
@@ -2027,13 +2027,6 @@ pub fn forkShell(
command_buf[line.len] = 0;
spawn.argv = Shell.commandArgv(spawn.path, command_buf[0..line.len :0].ptr);
}
- var helper_buf: [4096]u8 = undefined;
- const mounted = one_line == null and if (core) |c| if (c.panes[pane]) |pn| pn.v9fs_on_spawn else false else false;
- const helper: ?[:0]u8 = if (mounted) blk: {
- if (comptime builtin.os.tag != .linux) return error.LinuxRequired;
- if (fs == null) return error.SessionSocketRequired;
- break :blk try @import("linux/v9fs.zig").helperPath(&helper_buf);
- } else null;
// The last argument is whether this session takes its children's Looks —
// every session does but a `--nested` one, and a fork with no core at all
// (the tests below) is nobody's parent.
@@ -2045,15 +2038,6 @@ pub fn forkShell(
// acme's `$winid`: the pane a command was run from, so a script it runs
// can address that pane; unset for a shell and a header tag's command.
exportWinid(if (core) |c| (if (c.panes[pane]) |pn| (if (pn.command != null) pn.command_from else 0) else 0) else 0);
- if (helper) |path| {
- const c = core.?;
- const pn = c.panes[pane].?;
- const socket = ChildEnv.exported("PARDES_9P") orelse return error.SessionSocketRequired;
- var command: std.Io.Writer.Allocating = .init(c.gpa);
- defer command.deinit();
- try @import("linux/v9fs.zig").writeLaunchCommand(&command.writer, path, socket, &spawn.argv);
- if (!try pardes.panes.terminal.queuePendingCommand(pn, command.written())) return error.ShellAlreadyStarted;
- }
// Built here and not after the fork: between fork and exec the child may
// not call setenv, whose malloc can deadlock against a pty reader thread
// that held the heap when the fork took its snapshot.
diff --git a/src/linux/v9fs.zig b/src/linux/v9fs.zig
deleted file mode 100644
index 47be298b..00000000
--- a/src/linux/v9fs.zig
+++ /dev/null
@@ -1,201 +0,0 @@
-//! Linux kernel-mount launcher. Installed as an ordinary executable beside
-//! Pardes; sudo authorizes each launch. Never install setuid.
-const std = @import("std");
-const builtin = @import("builtin");
-
-extern "c" fn unshare(flags: c_int) c_int;
-extern "c" fn mount(source: ?[*:0]const u8, target: [*:0]const u8, filesystemtype: ?[*:0]const u8, flags: c_ulong, data: ?*const anyopaque) c_int;
-extern "c" fn setgroups(size: usize, list: ?[*]const c_uint) c_int;
-extern "c" fn initgroups(user: [*:0]const u8, group: c_uint) c_int;
-extern "c" fn execv(path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8) c_int;
-extern "c" fn execvp(path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8) c_int;
-extern "c" fn mkdtemp(template: [*:0]u8) ?[*:0]u8;
-extern "c" fn setenv(name: [*:0]const u8, value: [*:0]const u8, overwrite: c_int) c_int;
-extern "c" fn unsetenv(name: [*:0]const u8) c_int;
-
-pub const executable = "pardes-v9fs";
-
-/// One command for the normal interactive shell's startup queue. Quote every
-/// argument so paths and shell setup strings remain data in bash, fish and sh.
-pub fn writeLaunchCommand(writer: *std.Io.Writer, helper: []const u8, socket: []const u8, shell_argv: []const ?[*:0]const u8) !void {
- try quote(writer, helper);
- try writer.writeAll(" --launch ");
- try quote(writer, socket);
- try writer.writeAll(" --");
- for (shell_argv) |maybe| {
- const arg = maybe orelse break;
- try writer.writeByte(' ');
- try quote(writer, std.mem.span(arg));
- }
-}
-
-fn quote(writer: *std.Io.Writer, value: []const u8) !void {
- // A literal newline would submit the interactive command before it is
- // complete. These are paths/setup arguments, not arbitrary shell input.
- if (std.mem.indexOfAny(u8, value, "\r\n") != null) return error.MultilineLaunchArgument;
- try writer.writeByte('\'');
- for (value) |byte| {
- if (byte == '\'') try writer.writeAll("'\\''") else try writer.writeByte(byte);
- }
- try writer.writeByte('\'');
-}
-
-fn selfPath(buf: []u8) ![:0]u8 {
- const n = std.c.readlink("/proc/self/exe", buf.ptr, buf.len - 1);
- if (n < 0 or n >= buf.len - 1) return error.ExecutablePathUnavailable;
- const len: usize = @intCast(n);
- buf[len] = 0;
- return buf[0..len :0];
-}
-
-/// Resolve before fork, without relying on the shell's PATH. The override is
-/// useful for build-cache binaries whose helper is in a different directory.
-pub fn helperPath(buf: []u8) ![:0]u8 {
- const path = if (std.c.getenv("PARDES_V9FS_HELPER")) |env| blk: {
- const override = std.mem.span(env);
- if (!std.fs.path.isAbsolute(override)) return error.AbsoluteHelperPathRequired;
- break :blk try std.fmt.bufPrintSentinel(buf, "{s}", .{override}, 0);
- } else blk: {
- var own: [4096]u8 = undefined;
- const parent = std.fs.path.dirname(try selfPath(&own)) orelse return error.ExecutablePathUnavailable;
- break :blk try std.fmt.bufPrintSentinel(buf, "{s}/{s}", .{ parent, executable }, 0);
- };
- if (std.c.access(path.ptr, 1) != 0) return error.V9fsHelperNotFound;
- return path;
-}
-
-fn usage() void {
- std.debug.print(
- \\usage: pardes-v9fs --launch SOCKET -- /absolute/shell [args...]
- \\ Ask sudo in this terminal, mount privately, and start an unprivileged shell.
- \\ PARDES_MOUNT names the mount. The caller's environment is preserved with sudo -E.
- \\internal: pardes-v9fs SOCKET MOUNTPOINT UID GID -- /absolute/command [args...]
- \\ Requires explicit root execution. Never install setuid or grant blanket NOPASSWD.
- \\
- , .{});
-}
-
-var sudo_pid: std.atomic.Value(std.c.pid_t) = .init(-1);
-
-fn forwardSignal(sig: std.posix.SIG) callconv(.c) void {
- const pid = sudo_pid.load(.monotonic);
- if (pid > 0) _ = std.c.kill(pid, sig);
-}
-
-fn launch(arena: std.mem.Allocator, args: []const [:0]const u8) !u8 {
- if (args.len < 5 or !std.mem.eql(u8, args[3], "--")) return error.InvalidArguments;
- if (std.c.geteuid() == 0 or std.c.getuid() != std.c.geteuid()) return error.UnprivilegedLaunchRequired;
- if (!std.fs.path.isAbsolute(args[2]) or !std.fs.path.isAbsolute(args[4])) return error.AbsolutePathRequired;
- var own: [4096]u8 = undefined;
- const helper = try selfPath(&own);
- var target = "/tmp/pardes-v9fs-XXXXXX".*;
- if (mkdtemp(&target) == null) return error.MountDirectoryFailed;
- defer _ = std.c.rmdir(&target);
- try check(setenv("PARDES_MOUNT", &target, 1), "export mount path");
- inline for (.{ "PATH", "HOME", "USER", "LOGNAME", "SHELL" }) |name| {
- const saved = "PARDES_V9FS_" ++ name;
- if (std.c.getenv(name)) |value| {
- try check(setenv(saved, value, 1), "preserve shell environment");
- } else _ = unsetenv(saved);
- }
- const uid = try std.fmt.allocPrintSentinel(arena, "{d}", .{std.c.getuid()}, 0);
- const gid = try std.fmt.allocPrintSentinel(arena, "{d}", .{std.c.getgid()}, 0);
- const prefix = [_]?[*:0]const u8{ "sudo", "-E", "--", helper.ptr, args[2].ptr, &target, uid.ptr, gid.ptr, "--" };
- const argv = try arena.allocSentinel(?[*:0]const u8, prefix.len + args.len - 4, null);
- @memcpy(argv[0..prefix.len], &prefix);
- for (args[4..], prefix.len..) |arg, i| argv[i] = arg.ptr;
- std.debug.print("Mounting Pardes at {s}\n", .{target});
- const pid = std.c.fork();
- if (pid < 0) return error.ForkFailed;
- if (pid == 0) {
- // host_io's resetChildSignals, here in its own module: every signal
- // back to its default and none blocked before the exec.
- const default: std.posix.Sigaction = .{ .handler = .{ .handler = std.posix.SIG.DFL }, .mask = std.posix.sigemptyset(), .flags = 0 };
- var sig: u8 = 1;
- while (sig < 65) : (sig += 1) {
- if (sig == @backingInt(std.posix.SIG.KILL) or sig == @backingInt(std.posix.SIG.STOP)) continue;
- _ = std.c.sigaction(@fromBackingInt(@intCast(sig)), &default, null);
- }
- const none = std.posix.sigemptyset();
- std.posix.sigprocmask(std.posix.SIG.SETMASK, &none, null);
- _ = execvp("sudo", argv.ptr);
- std.c._exit(127);
- }
- sudo_pid.store(pid, .monotonic);
- const action: std.posix.Sigaction = .{ .handler = .{ .handler = forwardSignal }, .mask = std.posix.sigemptyset(), .flags = 0 };
- for ([_]std.posix.SIG{ .HUP, .INT, .TERM }) |sig| std.posix.sigaction(sig, &action, null);
- var status: c_int = 0;
- while (std.c.waitpid(pid, &status, 0) < 0) {
- if (std.posix.errno(-1) != .INTR) return error.WaitFailed;
- }
- sudo_pid.store(-1, .monotonic);
- return if (status & 0x7f == 0) @intCast((status >> 8) & 0xff) else @intCast(128 + (status & 0x7f));
-}
-
-fn check(rc: c_int, operation: []const u8) !void {
- if (rc == 0) return;
- const err = std.posix.errno(rc);
- std.debug.print("v9fs: {s}: {s}\n", .{ operation, @tagName(err) });
- return error.SystemCallFailed;
-}
-
-fn userId(text: []const u8) !c_uint {
- const id = std.fmt.parseInt(c_uint, text, 10) catch return error.InvalidUserId;
- if (id == 0 or id == std.math.maxInt(c_uint)) return error.InvalidUserId;
- return id;
-}
-
-pub fn main(init: std.process.Init) !void {
- if (builtin.os.tag != .linux) return error.LinuxRequired;
- const arena = init.arena.allocator();
- const args = try init.minimal.args.toSlice(arena);
- if (args.len == 2 and std.mem.eql(u8, args[1], "--help")) {
- usage();
- return;
- }
- if (args.len > 1 and std.mem.eql(u8, args[1], "--launch")) {
- const status = try launch(arena, args);
- std.process.exit(status);
- }
- if (args.len < 7 or !std.mem.eql(u8, args[5], "--")) {
- usage();
- return error.InvalidArguments;
- }
- for ([_][]const u8{ args[1], args[2], args[6] }) |path| {
- if (!std.fs.path.isAbsolute(path)) return error.AbsolutePathRequired;
- }
- const uid = try userId(args[3]);
- const gid = try userId(args[4]);
- if (std.c.getuid() != std.c.geteuid()) return error.SetuidInstallationUnsupported;
- if (std.c.geteuid() != 0) {
- std.debug.print("v9fs: native 9P mounts need CAP_SYS_ADMIN in the initial user namespace; use --launch to ask sudo in this terminal.\n", .{});
- return error.MountPrivilegeRequired;
- }
-
- // Prepare everything before changing namespace or credentials.
- const options = try std.fmt.allocPrintSentinel(arena, "trans=unix,version=9p2000,cache=none,access=any,uname={d},dfltuid={d},dfltgid={d}", .{ uid, uid, gid }, 0);
- const argv = try arena.allocSentinel(?[*:0]const u8, args.len - 6, null);
- for (args[6..], 0..) |arg, i| argv[i] = arg.ptr;
-
- try check(unshare(0x00020000), "create private mount namespace (CAP_SYS_ADMIN required)"); // CLONE_NEWNS
- try check(mount(null, "/", null, (1 << 14) | (1 << 18), null), "make mount propagation recursively private"); // MS_REC | MS_PRIVATE
- try check(mount(args[1].ptr, args[2].ptr, "9p", 2 | 4 | 8, options.ptr), "mount 9P2000 over Unix socket (kernel 9p and 9pnet_fd support required)"); // NOSUID | NODEV | NOEXEC
-
- try check(setgroups(0, null), "clear supplementary groups");
- const account = std.c.getpwuid(uid) orelse return error.UserAccountNotFound;
- try check(initgroups(account.name orelse return error.UserAccountNotFound, gid), "restore user groups");
- try check(std.c.setresgid(gid, gid, gid), "drop group privileges");
- try check(std.c.setresuid(uid, uid, uid), "drop user privileges");
- // sudo can replace identity variables and PATH even with -E. Restore
- // those values only after dropping privileges.
- inline for (.{ "PATH", "HOME", "USER", "LOGNAME", "SHELL" }) |name| {
- const saved = "PARDES_V9FS_" ++ name;
- if (std.c.getenv(saved)) |value| {
- try check(setenv(name, value, 1), "restore shell environment");
- _ = unsetenv(saved);
- }
- }
- _ = execv(args[6].ptr, argv.ptr);
- // Namespace destruction releases the mount when its last process exits.
- try check(-1, "execute unprivileged command");
-}
diff --git a/src/panes.zig b/src/panes.zig
index 095e215f..fd3cfab0 100644
--- a/src/panes.zig
+++ b/src/panes.zig
@@ -194,8 +194,6 @@ pub const Pane = struct {
/// at, and which of them: only that word goes ahead on the warning
/// (builtins.zig warnModified).
discard_warned: ?struct { revision: u32, by: Discarding } = null,
- /// Native host queues the Linux v9fs launcher in this pane's initial shell.
- v9fs_on_spawn: bool = false,
file: ?File.State = null,
image: ?Image.State = null,
pdf: PdfSlot = if (Pdf.enabled) null else {},
diff --git a/src/pardes.zig b/src/pardes.zig
index 6c5a01af..4c1d0a10 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -965,25 +965,6 @@ test "a terminal respawned into a closed pane's slot hangs the old shell up firs
try std.testing.expect(closed and spawned);
}
-test "Tty9p marks only the new Linux terminal for a mounted shell" {
- if (comptime !hosted or @import("builtin").os.tag != .linux) return error.SkipZigTest;
- const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true });
- defer p.deinit();
- p.fs.socket_path = "/tmp/pardes-test.sock";
- try std.testing.expect(p.executeBuiltinLine(0, "Tty9p"));
- try std.testing.expect(p.active != 0);
- try std.testing.expect(!p.panes[0].?.v9fs_on_spawn);
- const pane = p.panes[p.active].?;
- try std.testing.expect(pane.isTerminal() and pane.body.mode == .tty);
- try std.testing.expect(pane.v9fs_on_spawn);
- try std.testing.expect(!pane.greet);
- try std.testing.expect(!exec.takesCommandLine(p, p.active));
- panes.terminal.feedOutput(p, pane, "\x1b]133;A\x07$ \x1b]133;B\x07");
- try std.testing.expect(exec.takesCommandLine(p, p.active));
- panes.terminal.feedOutput(p, pane, "\x1b]133;C\x07");
- try std.testing.expect(!exec.takesCommandLine(p, p.active));
-}
-
test "first document fallback splits like Tty from the originating pane" {
for ([_]u16{ 100, 198 }) |width| for (0..3) |from| {
for ([_]bool{ false, true }) |collapsed| {
diff --git a/test/v9fs.py b/test/v9fs.py
deleted file mode 100644
index 30efe9fb..00000000
--- a/test/v9fs.py
+++ /dev/null
@@ -1,196 +0,0 @@
-#!/usr/bin/env python3
-"""Opt-in Linux kernel-mount probe; the editor always runs unprivileged.
-
-Run after `sudo -v` with a native Pardes binary and the runtime v9fs helper.
-The helper alone runs through sudo, creates a private mount namespace, mounts
-9P, drops privileges, and execs this file's worker. No FUSE or global mount.
-"""
-import argparse
-import json
-import os
-import pwd
-from pathlib import Path
-import subprocess
-import sys
-import tempfile
-import time
-import traceback
-
-from fs import session
-from ninep import Client
-
-
-def write_existing(path, data, *, truncate=False):
- flags = os.O_WRONLY | (os.O_TRUNC if truncate else 0)
- fd = os.open(path, flags)
- try:
- assert os.write(fd, data) == len(data), str(path)
- finally:
- os.close(fd)
-
-
-def worker(mountpoint, socket, uid, gid, original_namespace):
- assert os.getresuid() == (uid, uid, uid), os.getresuid()
- assert os.getresgid() == (gid, gid, gid), os.getresgid()
- assert set(os.getgroups()) == set(os.getgrouplist(pwd.getpwuid(uid).pw_name, gid)), os.getgroups()
- assert os.readlink('/proc/self/ns/mnt') != original_namespace
- status = dict(line.split(':', 1) for line in Path('/proc/self/status').read_text().splitlines())
- for field in ('CapEff', 'CapPrm', 'CapAmb'):
- assert int(status[field].strip(), 16) == 0, (field, status[field])
- entries = Path('/proc/self/mountinfo').read_text().splitlines()
- mounted = [line for line in entries if line.split()[4] == str(mountpoint)]
- assert len(mounted) == 1 and ' - 9p ' in mounted[0], mounted
- assert not any(field.startswith(('shared:', 'master:')) for field in mounted[0].split()[6:])
-
- tree = mountpoint
- assert {'os', 'index', 'pane', 'status', 'look', 'exec', 'log', 'screen', 'README'} <= set(os.listdir(tree))
- assert 'self' not in os.listdir(tree) and 'new' not in os.listdir(tree)
- assert 'new' not in os.listdir(tree / 'pane'), 'a listing would make a pane per stat'
- # A direct connection provides independent evidence for VFS reads/writes.
- with Client(socket) as client:
- assert (tree / 'index').read_bytes() == client.read('/index')
- assert (tree / 'pane/1/body').read_bytes() == b'initial\n'
-
- before = client.read('/index')
- subprocess.run(['ls', '-l', str(tree), str(tree / 'pane' / '1')], check=True, capture_output=True, timeout=5)
- subprocess.run(['find', str(tree / 'pane'), '-ls'], check=True, capture_output=True, timeout=5)
- assert (tree / 'README').read_bytes() == client.read('/README')
- assert client.read('/index') == before, 'browsing created panes'
- # Opening pane/new makes a pane and the read names it, so no trip
- # through the index. Whether a repeated path reaches the server at all
- # is the kernel's dentry cache's business, so the second pane comes
- # over the wire, where the open is exact.
- def serials():
- return {int(row.split()[0]) for row in (tree / 'index').read_bytes().splitlines()}
-
- def mkpane():
- known = serials()
- made = int((tree / 'pane' / 'new').read_bytes())
- assert made not in known, 'the open of new made no pane'
- return made
-
- serial = mkpane()
- another = int(client.read('/pane/new'))
- assert serial != another, 'a second open of new reused a pane'
- (tree / 'pane' / str(another)).rmdir()
- assert another not in serials()
- pane = tree / 'pane' / str(serial)
- wire = f'/pane/{serial}'
- assert str(serial) in os.listdir(tree / 'pane')
- assert serial in [int(row.split()[0]) for row in (tree / 'index').read_bytes().splitlines()]
-
- write_existing(pane / 'body', b'kernel body\n', truncate=True)
- assert client.read(wire + '/body') == b'kernel body\n'
- # Reopen must observe changes made through another 9P connection.
- client.write(wire + '/body', b'wire update\n', truncate=True)
- assert (pane / 'body').read_bytes() == b'wire update\n'
- write_existing(pane / 'body', b'appended\n')
- assert client.read(wire + '/body') == b'wire update\nappended\n'
- write_existing(pane / 'addr', b'#0,#4')
- write_existing(pane / 'data', b'v9fs')
- assert client.read(wire + '/body') == b'v9fs update\nappended\n'
-
- # Exercise an actual shell redirection, including its O_TRUNC open.
- subprocess.run(['/bin/sh', '-c', 'printf "kernel-probe\\n" > "$1/name"',
- 'v9fs-probe', str(pane)], check=True, timeout=5)
- tag = client.read(wire + '/tag')
- assert tag.split(maxsplit=1)[0] == str(socket.parent / 'kernel-probe').encode(), tag
- # Children inherit this single mount and can use ordinary tools.
- copied = subprocess.run(['/bin/cat', str(pane / 'body')],
- check=True, capture_output=True, timeout=5).stdout
- assert copied == b'v9fs update\nappended\n'
-
- command = b'Msg kernel-v9fs-ready'
- write_existing(pane / 'body', command, truncate=True)
- write_existing(pane / 'event', f'MX0 {len(command)}\n'.encode())
- # Event writes acknowledge dispatch, so reopen screen until rendered.
- deadline = time.monotonic() + 5
- while True:
- screen = json.loads((tree / 'screen').read_bytes())
- if 'kernel-v9fs-ready' in ''.join(cell[0] for cell in screen['cells']):
- break
- assert time.monotonic() < deadline, 'Exec result was not rendered'
- time.sleep(.01)
-
- # Reading OS files through the exported tree does not recurse through
- # the mount: the core still lives in the supervisor's namespace.
- assert (mountpoint / 'os' / str(socket.parent).lstrip('/') / 'kernel.txt').read_bytes() == b'initial\n'
- (tree / 'pane' / str(serial)).rmdir()
- assert serial not in [int(row.split()[0]) for row in (tree / 'index').read_bytes().splitlines()]
-
- print('v9fs: namespace isolation, privilege drop, inherited mount, directory refresh, '
- 'text edits, control writes, Exec and screen checks passed', flush=True)
-
-
-def run_helper(command, timeout=30):
- # Keep the caller's controlling terminal: sudo credentials are commonly
- # scoped to it. setsid/start_new_session makes an earlier sudo -v useless.
- # The elevated helper itself creates the separate *mount* namespace.
- child = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
- text=True)
- try:
- stdout, stderr = child.communicate(timeout=timeout)
- except subprocess.TimeoutExpired:
- # sudo forwards signals to its command. Keep the server alive while
- # stopping the mount user, then let session() clean up.
- child.terminate()
- try:
- child.communicate(timeout=5)
- except subprocess.TimeoutExpired:
- child.kill()
- child.communicate(timeout=5)
- raise RuntimeError('kernel probe timed out; no compatibility result')
- if child.returncode:
- raise RuntimeError(f'kernel probe failed ({child.returncode})\n{stdout}{stderr}')
- return stdout
-
-
-def run(binary, helper):
- if sys.platform != 'linux':
- raise RuntimeError('this probe requires Linux v9fs')
- if os.getuid() == 0:
- raise RuntimeError('run the driver as your normal user; only the mount helper uses sudo')
- # Never prompt from a build step. An unavailable prerequisite is a failure,
- # not a skipped test that might be mistaken for mounted-filesystem coverage.
- available = subprocess.run(['sudo', '-n', '-v'], capture_output=True, text=True, timeout=5)
- if available.returncode:
- raise RuntimeError('mount authorization unavailable: run sudo -v in your terminal, then retry\n'
- + available.stderr.strip())
- namespace = os.readlink('/proc/self/ns/mnt')
- with tempfile.TemporaryDirectory(prefix='pardes-v9fs-') as directory:
- root = Path(directory)
- target = root / 'mount'
- target.mkdir()
- with session(str(binary), root, 'kernel') as (client, address):
- command = ['sudo', '-n', '--', str(helper), str(address), str(target),
- str(os.getuid()), str(os.getgid()), '--', sys.executable, '-B',
- str(Path(__file__).resolve()), '--worker', str(target), str(address),
- str(os.getuid()), str(os.getgid()), namespace]
- print(run_helper(command), end='')
- assert os.readlink('/proc/self/ns/mnt') == namespace
- assert list(target.iterdir()) == [], 'mount escaped its private namespace'
- assert client.read('/pane/1/body') == b'initial\n', 'core stopped serving after probe exit'
- print('v9fs: supervisor namespace unchanged and session cleanup passed')
-
-
-def main():
- if len(sys.argv) > 1 and sys.argv[1] == '--worker':
- if len(sys.argv) != 7:
- raise RuntimeError('invalid internal worker arguments')
- worker(Path(sys.argv[2]), Path(sys.argv[3]), int(sys.argv[4]), int(sys.argv[5]), sys.argv[6])
- return
- parser = argparse.ArgumentParser(description=__doc__)
- parser.add_argument('binary', type=lambda text: Path(text).resolve(strict=True))
- parser.add_argument('helper', type=lambda text: Path(text).resolve(strict=True))
- args = parser.parse_args()
- run(args.binary, args.helper)
-
-
-if __name__ == '__main__':
- try:
- main()
- except (AssertionError, OSError, RuntimeError, subprocess.SubprocessError) as error:
- if len(sys.argv) > 1 and sys.argv[1] == '--worker':
- traceback.print_exc()
- print(f'v9fs: {error}', file=sys.stderr)
- sys.exit(1)
diff --git a/test/v9fs_driver_test.py b/test/v9fs_driver_test.py
deleted file mode 100644
index 9781c4fe..00000000
--- a/test/v9fs_driver_test.py
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env python3
-"""Unprivileged regression checks for the v9fs helper launcher."""
-import os
-import sys
-import unittest
-
-from v9fs import run_helper
-
-
-class HelperLaunchTests(unittest.TestCase):
- def test_preserves_session_for_terminal_scoped_sudo_credentials(self):
- output = run_helper([sys.executable, '-c', 'import os; print(os.getsid(0))'])
- self.assertEqual(int(output), os.getsid(0))
-
- def test_failure_preserves_diagnostics(self):
- with self.assertRaisesRegex(RuntimeError, r'(?s)failed \(7\).*mount refused'):
- run_helper([sys.executable, '-c',
- 'import sys; print("mount refused", file=sys.stderr); sys.exit(7)'])
-
- def test_timeout_is_not_a_passing_probe(self):
- with self.assertRaisesRegex(RuntimeError, 'timed out; no compatibility result'):
- run_helper([sys.executable, '-c', 'import time; time.sleep(60)'], timeout=.1)
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/test/v9fs_terminal.py b/test/v9fs_terminal.py
deleted file mode 100644
index b49246d1..00000000
--- a/test/v9fs_terminal.py
+++ /dev/null
@@ -1,108 +0,0 @@
-#!/usr/bin/env python3
-"""Exercise Tty9p and its real launcher with a nonprivileged sudo stand-in.
-
-This checks PTY routing and lifecycle, not kernel-mount compatibility (v9fs.py).
-"""
-import json
-import os
-from pathlib import Path
-import signal
-import shutil
-import sys
-import tempfile
-import time
-
-from fs import execute, new_pane, session
-
-
-def until(probe, description):
- deadline = time.monotonic() + 8
- while time.monotonic() < deadline:
- result = probe()
- if result:
- return result
- time.sleep(.02)
- raise AssertionError(description)
-
-
-def test(binary, helper):
- with tempfile.TemporaryDirectory(prefix='pardes-v9fs-terminal-') as directory:
- root = Path(directory)
- # Exercise shell quoting with a real executable path containing both
- # whitespace and an apostrophe, under bash and fish where available.
- quoted_helper = root / "helper's quoted path"
- shutil.copy2(helper, quoted_helper)
- helper = quoted_helper
- sudo = root / 'sudo'
- # A fresh PATH in the owned fixture selects this stand-in. It never
- # invokes real sudo, mounts anything, or handles a real password.
- sudo.write_text(f'#!{sys.executable}\n' + '''
-import json, os, signal, sys, termios
-from pathlib import Path
-tty = os.open('/dev/tty', os.O_RDWR)
-assert os.isatty(tty)
-report = dict(argv=sys.argv[1:], pane=os.environ['PARDES_PANE'],
- socket=os.environ['PARDES_9P'], mount=os.environ['PARDES_MOUNT'],
- path=os.environ['PARDES_V9FS_PATH'], launcher=os.getppid(), pid=os.getpid())
-parent_status = Path(f"/proc/{report['launcher']}/status").read_text().splitlines()
-shell_pid = next(line.split()[1] for line in parent_status if line.startswith('PPid:'))
-report['shell'] = os.readlink(f'/proc/{shell_pid}/exe')
-Path(os.environ['V9FS_REPORT']).write_text(json.dumps(report))
-before = termios.tcgetattr(tty)
-hidden = termios.tcgetattr(tty)
-hidden[3] &= ~termios.ECHO
-termios.tcsetattr(tty, termios.TCSANOW, hidden)
-os.write(tty, b'V9FS_AUTH_READY: ')
-response = os.read(tty, 100)
-termios.tcsetattr(tty, termios.TCSANOW, before)
-os.write(tty, b'V9FS_INPUT_RECEIVED\\n')
-os.write(tty, b'sudo stand-in: authentication refused\\n')
-sys.exit(1)
-''')
- sudo.chmod(0o700)
- shells = [shutil.which('bash') or '/bin/sh', shutil.which('fish') or '/bin/sh']
- for shell, interrupted in zip(shells, (False, True)):
- report_path = root / ('interrupted.json' if interrupted else 'normal.json')
- path = str(root) + ':' + os.environ.get('PATH', '/usr/bin:/bin')
- name = 'interrupted' if interrupted else 'normal'
- with session(str(binary), root, name, inherited={
- 'PARDES_V9FS_HELPER': str(helper), 'PATH': path,
- 'V9FS_REPORT': str(report_path), 'SHELL': shell,
- }) as (client, address):
- control = new_pane(client, b'')
- execute(client, control, 'Shell ' + shell)
- execute(client, control, 'Tty9p')
- until(report_path.exists, 'Tty9p did not reach the sudo stand-in')
- report = json.loads(report_path.read_text())
- pane = f"/pane/{report['pane']}"
- until(lambda: b'V9FS_AUTH_READY' in client.read(pane + '/body'), 'prompt not visible')
- assert report['socket'] == str(address)
- assert report['argv'][:2] == ['-E', '--'], report
- assert report['argv'][2] == str(helper), report
- assert report['argv'][3] == str(address), report
- assert report['argv'][4] == report['mount'], report
- assert report['argv'][5:8] == [str(os.getuid()), str(os.getgid()), '--'], report
- assert report['path'] == path
- assert report['shell'] == str(Path(shell).resolve()), report
- # The detached core remains responsive during authentication.
- assert client.read('/pane/1/body') == b'initial\n'
- target = Path(report['mount'])
- assert target.is_dir() and list(target.iterdir()) == []
- if interrupted:
- os.kill(report['launcher'], signal.SIGTERM)
- else:
- client.write(pane + '/pty/data', b'probe-response\r')
- until(lambda: b'V9FS_INPUT_RECEIVED' in client.read(pane + '/body'), 'input did not reach new PTY')
- assert b'probe-response' not in client.read(pane + '/body'), 'password input was echoed'
- until(lambda: not target.exists(), 'launcher left its temporary mountpoint')
- # Failure/cancellation returns to the original interactive
- # shell, so the pane is useful and its errors remain visible.
- client.write(pane + '/pty/data', b'printf "OUTER_READY:%s\\n" "$PARDES_PANE"\r')
- expected = ('OUTER_READY:' + report['pane']).encode()
- until(lambda: expected in client.read(pane + '/body'), 'original shell did not remain usable')
- assert client.read('/pane/1/body') == b'initial\n'
- print('Tty9p: shell-first startup, quoted paths, hidden password input, failure recovery and cleanup passed')
-
-
-if __name__ == '__main__':
- test(Path(sys.argv[1]).resolve(), Path(sys.argv[2]).resolve())