╭ changed ─────────────────╮ │src/serve_ssh_protocol.zig│ ╰──────────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭───────────────────────────────────────────────────────────────────────────╮ │169 /// what the client wants to do on this channel. │ │170 pub const Request = union(enum) { │ │171 shell: ?PtySize, // pty info if a pty-req arrived before the shell│ │172 - exec: []const u8, // command string from the exec request │ │172 + exec: Exec, │ │173 + │ │174 + pub const Exec = struct { │ │175 + command: []const u8, │ │176 + /// the GIT_PROTOCOL env value, if one arrived before the exec│ │177 + git_protocol: ?[]const u8, │ │178 + }; │ │179 }; │ │180 │ │181 /// next thing that arrived from the client. │ ╰───────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────╮ │1798 remote_window: u32, // bytes we may still send to peer before they adjust │ │1799 max_packet: u32, // max CHANNEL_DATA payload the peer accepts in one packet│ │1800 pty: ?PtySize = null, │ │1801 + // value of GIT_PROTOCOL, the one env variable we keep │ │1802 + git_protocol_buf: [64]u8 = undefined, │ │1803 + git_protocol_len: ?usize = null, │ │1804 }; │ │1805 │ │1806 pub const PtySize = struct { width_cells: u16, height_cells: u16 }; │ ╰─────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────╮ │2003 } │ │2004 │ │2005 if (std.mem.eql(u8, req_type, "env")) { │ │1997 - // ignore environment variables silently (we don't pass them anywhere) │ │2006 + // string name, string value. the rest are ignored silently. │ │2007 + const name = try takeString(&r, max_packet_len); │ │2008 + const value = try takeString(&r, max_packet_len); │ │2009 + if (std.mem.eql(u8, name, "GIT_PROTOCOL") and value.len <= ch.git_protocol_buf.len) {│ │2010 + @memcpy(ch.git_protocol_buf[0..value.len], value); │ │2011 + ch.git_protocol_len = value.len; │ │2012 + } │ │2013 try replyChannelRequest(conn, ch, want_reply, true); │ │2014 return null; │ │2015 } │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────╮ │2032 // capture the command string for the handler to inspect │ │2033 const cmd = try takeString(&r, 4096); │ │2034 try replyChannelRequest(conn, ch, want_reply, true); │ │2020 - return .{ .exec = cmd }; │ │2035 + return .{ .exec = .{ │ │2036 + .command = cmd, │ │2037 + .git_protocol = if (ch.git_protocol_len) |len| ch.git_protocol_buf[0..len] else null,│ │2038 + } }; │ │2039 } │ │2040 │ │2041 // unknown request kind — fail it │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────╯