summaryrefslogtreecommitdiff
path: root/src/ninep/ctl.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-30 23:12:58 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:17 -0300
commit9dc93a8d31f08f5aec81e7c076220b598db37cbb (patch)
tree4508f75d61b398da363beb31fc10b771a884c3a1 /src/ninep/ctl.zig
parentbcd8388d74e29398cb528206b05fd9491a4d4153 (diff)
downloadpardes-9dc93a8d31f08f5aec81e7c076220b598db37cbb.tar.gz
pardes-9dc93a8d31f08f5aec81e7c076220b598db37cbb.zip
A look at a file it may not read says which: "look: <path>: 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 <[email protected]>
Diffstat (limited to 'src/ninep/ctl.zig')
-rw-r--r--src/ninep/ctl.zig19
1 files changed, 19 insertions, 0 deletions
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");