diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-01 08:37:39 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 08:53:11 -0300 |
| commit | 84b3bb51d7009902659e05f94c53c82d109ba8f6 (patch) | |
| tree | 7c2fb29a96cfc2d76f7dfea6adf12998339ea246 /src/pardes.zig | |
| parent | 642bcfd9e37c1a3437c2757434c1d6d9c941d9c4 (diff) | |
| download | pardes-84b3bb51d7009902659e05f94c53c82d109ba8f6.tar.gz pardes-84b3bb51d7009902659e05f94c53c82d109ba8f6.zip | |
DumpDir refuses a relative directory and one that may not be written, up front, and a Dump that could not make its directory says permission denied
A relative DumpDir was resolved from wherever pardes started, and one
under a directory that may not be written was taken, the Dump failing
later as `no such directory`. DumpDir now takes an absolute or `~` path
whose nearest directory there may be written, and refuses any other with
what it takes; a Dump refused by a directory above says permission
denied (fs.deniedAbove), as a Save does.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/pardes.zig')
| -rw-r--r-- | src/pardes.zig | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/pardes.zig b/src/pardes.zig index 2b0ed8f0..dbb37084 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -5563,7 +5563,12 @@ pub const Pardes = struct { const parent = std.fs.path.dirname(path) orelse "/"; const kind: ?std.Io.File.Kind = if (comptime hosted) (if (filesystem.localPath(parent)) |local| exec.kindOf(local) else .directory) else .directory; const no_dir = err == error.FileNotFound or err == error.NotDir or kind != .directory; - if (kind != null and kind != .directory) { + // Not there because one above refuses: that is why, EACCES. + const denied = no_dir and kind == null and (if (comptime hosted) (if (filesystem.localPath(parent)) |local| filesystem.deniedAbove(local) else false) else false); + if (denied) { + var said: [limits.host_path_cap + 48]u8 = undefined; + p.reportFailure(p.active, std.fmt.bufPrint(&said, "{s}: permission denied", .{operation}) catch "Dump: permission denied"); + } else if (kind != null and kind != .directory) { var said: [limits.host_path_cap + 48]u8 = undefined; p.reportFailure(p.active, std.fmt.bufPrint(&said, "{s}: {s} is not a directory", .{ operation, parent }) catch "Dump: not a directory"); } else if (no_dir) { |
