authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-11-07 20:25:04-05:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-11-07 20:56:33-05:00
log9373abf7f77c37094f9ba6ca68287d8a06ebafa0
treec9fb5a5324d741042de3c581d8719bb2b27c889a
parent75adba7cb9501f33453275c187bcd7f4b11eaa9d

std.http.Client: change ssl key log creation permission bits

This is the same mode used by openssh for private keys. This does not change the mode of an existing file, so users who need something different can pre-create the file with their designed permissions or change them after the fact, and running another process that writes to the key log will not change it back.

1 files changed, 7 insertions(+), 1 deletions(-)

lib/std/http/Client.zig+7-1
...@@ -1361,7 +1361,13 @@ pub fn connectTcp(client: *Client, host: []const u8, port: u16, protocol: Connec...@@ -1361,7 +1361,13 @@ pub fn connectTcp(client: *Client, host: []const u8, port: u16, protocol: Connec
1361 error.OutOfMemory => return error.OutOfMemory,1361 error.OutOfMemory => return error.OutOfMemory,
1362 };1362 };
1363 defer client.allocator.free(ssl_key_log_path);1363 defer client.allocator.free(ssl_key_log_path);
1364 break :ssl_key_log_file std.fs.cwd().createFile(ssl_key_log_path, .{ .truncate = false }) catch null;1364 break :ssl_key_log_file std.fs.cwd().createFile(ssl_key_log_path, .{
1365 .truncate = false,
1366 .mode = switch (builtin.os.tag) {
1367 .windows, .wasi => 0,
1368 else => 0o600,
1369 },
1370 }) catch null;
1365 } else null;1371 } else null;
1366 errdefer if (ssl_key_log_file) |key_log_file| key_log_file.close();1372 errdefer if (ssl_key_log_file) |key_log_file| key_log_file.close();
13671373