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:...@@ -11,7 +11,10 @@ MIT:
11= https://spdx.org/licenses/MIT11= https://spdx.org/licenses/MIT
12- git https://github.com/nektro/zig-extras12- git https://github.com/nektro/zig-extras
13- git https://github.com/nektro/zig-sys-darwin13- git https://github.com/nektro/zig-sys-darwin
14- git https://github.com/nektro/zig-sys-freebsd
14- git https://github.com/nektro/zig-sys-linux15- 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
15- git https://github.com/nektro/zig-time18- git https://github.com/nektro/zig-time
16- git https://github.com/nektro/zig-tracer19- git https://github.com/nektro/zig-tracer
17- git https://github.com/nektro/zig-unicode-ucd20- git https://github.com/nektro/zig-unicode-ucd
src/postgresql.zig+5-3
...@@ -11,6 +11,9 @@ const tracer = @import("tracer");...@@ -11,6 +11,9 @@ const tracer = @import("tracer");
1111
12const sys = switch (builtin.target.os.tag) {12const sys = switch (builtin.target.os.tag) {
13 .linux => @import("sys-linux"),13 .linux => @import("sys-linux"),
14 .freebsd => @import("sys-freebsd"),
15 .netbsd => @import("sys-netbsd"),
16 .openbsd => @import("sys-openbsd"),
14 else => unreachable,17 else => unreachable,
15};18};
1619
...@@ -37,8 +40,7 @@ pub fn connect(allocator: std.mem.Allocator, connect_s: [:0]const u8) !Driver {...@@ -37,8 +40,7 @@ pub fn connect(allocator: std.mem.Allocator, connect_s: [:0]const u8) !Driver {
3740
38 // https://github.com/postgres/postgres/blob/REL_18_0/src/include/common/scram-common.h#L32-L3741 // https://github.com/postgres/postgres/blob/REL_18_0/src/include/common/scram-common.h#L32-L37
39 const nonce_len = 18;42 const nonce_len = 18;
40 var cnonce_buf: [nonce_len]u8 = @splat(0);43 const cnonce = nio.randomBytes(nonce_len);
41 var cnonce = try sys.getrandom(&cnonce_buf, 0);
42 _ = &cnonce;44 _ = &cnonce;
4345
44 var snonce_b64_buf: [128]u8 = @splat(0);46 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 {...@@ -111,7 +113,7 @@ pub fn connect(allocator: std.mem.Allocator, connect_s: [:0]const u8) !Driver {
111 // 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-ext113 // 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
113 var cnonce_b64_buf: [Base64Enc.calcSize(nonce_len)]u8 = @splat(0);115 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
116 var salt_b64_buf: [128]u8 = @splat(0);118 var salt_b64_buf: [128]u8 = @splat(0);
117 var salt_b64: []u8 = salt_b64_buf[0..];119 var salt_b64: []u8 = salt_b64_buf[0..];
zig.mod+3
...@@ -19,3 +19,6 @@ dependencies:...@@ -19,3 +19,6 @@ dependencies:
19 - src: git https://github.com/nektro/zig-net19 - src: git https://github.com/nektro/zig-net
20 - src: git https://github.com/nektro/zig-nio20 - src: git https://github.com/nektro/zig-nio
21 - src: git https://github.com/nektro/zig-sys-linux21 - 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