authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-08-23 18:54:16-07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-08-23 18:54:16-07:00
log1e98900cd5f33455b5fef767640f6669f7b3dc35
tree81905ed2a2baed37d9e47eb0fe365399c3fbc5fa
parent65e9877c4d65eb4fb5bf9f2863f695afca7ff8fb
signature Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

add support for freebsd, netbsd, openbsd


3 files changed, 11 insertions(+), 3 deletions(-)

licenses.txt+3
......@@ -11,7 +11,10 @@ MIT:
1111= https://spdx.org/licenses/MIT
1212- git https://github.com/nektro/zig-extras
1313- git https://github.com/nektro/zig-sys-darwin
14- git https://github.com/nektro/zig-sys-freebsd
1415- git https://github.com/nektro/zig-sys-linux
16- git https://github.com/nektro/zig-sys-netbsd
17- git https://github.com/nektro/zig-sys-openbsd
1518- git https://github.com/nektro/zig-time
1619- git https://github.com/nektro/zig-tracer
1720- git https://github.com/nektro/zig-unicode-ucd
src/postgresql.zig+5-3
......@@ -11,6 +11,9 @@ const tracer = @import("tracer");
1111
1212const sys = switch (builtin.target.os.tag) {
1313 .linux => @import("sys-linux"),
14 .freebsd => @import("sys-freebsd"),
15 .netbsd => @import("sys-netbsd"),
16 .openbsd => @import("sys-openbsd"),
1417 else => unreachable,
1518};
1619
......@@ -37,8 +40,7 @@ pub fn connect(allocator: std.mem.Allocator, connect_s: [:0]const u8) !Driver {
3740
3841 // https://github.com/postgres/postgres/blob/REL_18_0/src/include/common/scram-common.h#L32-L37
3942 const nonce_len = 18;
40 var cnonce_buf: [nonce_len]u8 = @splat(0);
41 var cnonce = try sys.getrandom(&cnonce_buf, 0);
43 const cnonce = nio.randomBytes(nonce_len);
4244 _ = &cnonce;
4345
4446 var snonce_b64_buf: [128]u8 = @splat(0);
......@@ -111,7 +113,7 @@ pub fn connect(allocator: std.mem.Allocator, connect_s: [:0]const u8) !Driver {
111113 // server-error-value = "invalid-encoding" / "extensions-not-supported" / "invalid-proof" / "channel-bindings-dont-match" / "server-does-support-channel-binding" / "channel-binding-not-supported" / "unsupported-channel-binding-type" / "unknown-user" / "invalid-username-encoding" / "no-resources" / "other-error" / server-error-value-ext
112114
113115 var cnonce_b64_buf: [Base64Enc.calcSize(nonce_len)]u8 = @splat(0);
114 const cnonce_b64 = Base64Enc.encode(&cnonce_b64_buf, cnonce);
116 const cnonce_b64 = Base64Enc.encode(&cnonce_b64_buf, &cnonce);
115117
116118 var salt_b64_buf: [128]u8 = @splat(0);
117119 var salt_b64: []u8 = salt_b64_buf[0..];
zig.mod+3
......@@ -19,3 +19,6 @@ dependencies:
1919 - src: git https://github.com/nektro/zig-net
2020 - src: git https://github.com/nektro/zig-nio
2121 - src: git https://github.com/nektro/zig-sys-linux
22 - src: git https://github.com/nektro/zig-sys-freebsd
23 - src: git https://github.com/nektro/zig-sys-netbsd
24 - src: git https://github.com/nektro/zig-sys-openbsd