From 9dc93a8d31f08f5aec81e7c076220b598db37cbb Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 30 Sep 2026 23:12:58 -0300 Subject: A look at a file it may not read says which: "look: : permission denied" The refusal said "look: permission denied", leaving the script to guess which of the paths it looked at was locked. A file or image that will not open is now named in the failure, its path cut in the middle when long. Co-Authored-By: Claude Opus 5.5 --- src/ninep/ctl.zig | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/ninep') diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 9a1a8da1..4a0f94c2 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -1760,6 +1760,25 @@ test "exec Save writes the named file through the host" { try testing.expectEqualStrings(pane.file.?.content, p.fallback.get("/tmp/renamed.txt").?); } +test "a look at a file it may not read fails the write naming the file" { + if (comptime !pardes.hosted) return; + const p = try withFile(testing.allocator, "x\n"); + defer p.deinit(); + var tmp = testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(testing.io, .{ .sub_path = "locked.txt", .data = "secret\n", .flags = .{ .permissions = .fromMode(0o000) } }); + 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 path = try std.fmt.bufPrint(&line, "{s}/locked.txt", .{dir}); + var want: [4200]u8 = undefined; + const expected = try std.fmt.bufPrint(&want, "look: {s}: permission denied", .{path}); + var with_newline: [4300]u8 = undefined; + const refused = wr(p, root_look, try std.fmt.bufPrint(&with_newline, "{s}\n", .{path})); + if (refused.reply.status == .ok) return error.SkipZigTest; // root reads anything + try testing.expectEqualStrings(expected, refused.reply.ename); +} + test "a refused Del written back through event fails that write, EIO, with its err" { const gpa = testing.allocator; const p = try withFile(gpa, "text\n"); -- cgit v1.3