diff options
Diffstat (limited to 'src/ninep')
| -rw-r--r-- | src/ninep/ctl.zig | 19 |
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"); |
