summaryrefslogtreecommitdiff
path: root/src/ninep/ctl.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/ninep/ctl.zig')
-rw-r--r--src/ninep/ctl.zig18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index 89c2e5dd..d4d09e0b 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -2332,8 +2332,9 @@ test "a Restore of a file that is no dump fails the write before any warning, an
try testing.expect(p.panes[0].?.discard_warned == null);
p.fs.late_failure_len = 0;
- p.dumpFailed("/nowhere/pardes.dump.zon", error.FileNotFound);
- try testing.expectEqualStrings("Dump /nowhere/pardes.dump.zon: no such directory", p.fs.late_failure[0..p.fs.late_failure_len]);
+ // (Under /tmp: under / a user's Dump is refused permission, not missing.)
+ p.dumpFailed("/tmp/pardes-nowhere-zz/pardes.dump.zon", error.FileNotFound);
+ try testing.expectEqualStrings("Dump /tmp/pardes-nowhere-zz/pardes.dump.zon: no such directory", p.fs.late_failure[0..p.fs.late_failure_len]);
// A DumpDir that is there but no directory says that.
p.fs.late_failure_len = 0;
p.dumpFailed("/dev/null/pardes.dump.zon", error.NotDir);
@@ -4357,3 +4358,16 @@ test "a ctl line over 1 MiB is refused once, EINVAL, and its tail is not run as
try testing.expectEqualStrings("", pane_files.fileOf(p.panes[0].?).?.content);
_ = call(p, .{ .tag = 4, .op = .release, .node = node, .handle = h });
}
+
+test "DumpDir refuses a relative directory and one that may not be written, up front; a Dump there says permission denied" {
+ if (comptime !pardes.hosted) return;
+ const p = try withFile(testing.allocator, "x\n");
+ defer p.deinit();
+ const root_ctl = @intFromEnum(tree.TopFile.ctl);
+ try testing.expectEqual(E.INVAL, wr(p, root_ctl, "DumpDir dumps\n").errno());
+ try testing.expectEqual(E.INVAL, wr(p, root_ctl, "DumpDir /proc/1/root/dumps\n").errno());
+ try testing.expectEqual(Status.ok, wr(p, root_ctl, "DumpDir /tmp/pardes-dumps-test\n").reply.status);
+ p.fs.late_failure_len = 0;
+ p.dumpFailed("/proc/1/root/x/pardes.dump.zon", error.FileNotFound);
+ try testing.expect(std.mem.endsWith(u8, p.fs.late_failure[0..p.fs.late_failure_len], ": permission denied"));
+}