summaryrefslogtreecommitdiff
path: root/src/ninep/ctl.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 11:23:19 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:16 -0300
commit1ac8fbeedaf7cba881a7423b92ead1f739b8ac21 (patch)
treec3916f9918fb98252987331195cd1b70712c890d /src/ninep/ctl.zig
parent2c98513a23d060093d690dbd7743dda5ad86c117 (diff)
downloadpardes-1ac8fbeedaf7cba881a7423b92ead1f739b8ac21.tar.gz
pardes-1ac8fbeedaf7cba881a7423b92ead1f739b8ac21.zip
A script whose interpreter is not there is told apart from a missing shell, and Tty refuses it up front
Tty's up-front check found the script and let it through, so the pane was made, its exec failed ENOENT, and the log read new, msg shell: shell not found, del, then the err. The check now reads a script's #! line and refuses it, interpreter /no/such/interp not found, and an exec that fails ENOENT on a file that is there says the same. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/ninep/ctl.zig')
-rw-r--r--src/ninep/ctl.zig29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index 4b37c23e..31382279 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -1996,6 +1996,35 @@ test "pty/ctl exec in a directory that is gone fails ENOENT; a shell that cannot
try testing.expectEqualStrings("shell: access denied", p.fs.late_failure[0..p.fs.late_failure_len]);
}
+test "a script whose interpreter is not there: Tty refuses it up front, only an err logged" {
+ const p = try th.withTerm(testing.allocator);
+ defer p.deinit();
+ const Starting = struct {
+ fn spawn(_: ?*anyopaque, _: u8, _: []const u8) void {}
+ };
+ p.host = .{ .vtable = &.{ .spawn = Starting.spawn } };
+ defer p.host = .{};
+ var tmp = testing.tmpDir(.{});
+ defer tmp.cleanup();
+ try tmp.dir.writeFile(testing.io, .{ .sub_path = "bad", .data = "#!/no/such/interp\n", .flags = .{ .permissions = .executable_file } });
+ var dir_buf: [4096]u8 = undefined;
+ const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)];
+ var line: [4200]u8 = undefined;
+ const serial = serialOf(p);
+ var count: usize = 0;
+ for (p.panes) |slot| count += @intFromBool(slot != null);
+ const refused = wr(p, Node.of(serial, .ctl), try std.fmt.bufPrint(&line, "Tty {s}/bad\n", .{dir}));
+ try testing.expectEqual(E.NOENT, refused.errno());
+ try testing.expectEqualStrings("Tty: interpreter /no/such/interp not found", refused.reply.ename);
+ var after: usize = 0;
+ for (p.panes) |slot| after += @intFromBool(slot != null);
+ try testing.expectEqual(count, after);
+ // The log gained the err and nothing else: no new, msg or del.
+ try testing.expect(th.logHas(p, "Tty: interpreter /no/such/interp not found\n"));
+ try testing.expect(!th.logHas(p, "\nmsg "));
+ try testing.expect(!th.logHas(p, "\ndel "));
+}
+
test "every EINVAL a write gets says why, in its err record too; DEL is a control character in a line" {
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();