server: add CLIENT_LOCAL_FILES to default server capabilities#1163
Conversation
A go-mysql server acting as a proxy must advertise CLIENT_LOCAL_FILES in the handshake so that connecting clients agree to send file packets for LOAD DATA LOCAL INFILE queries. Without this flag, clients that negotiate CLIENT_LOCAL_FILES will never receive the 0xfb request packet from the proxy-as-server, making it impossible to relay LOAD DATA LOCAL INFILE through a transparent proxy. Closes go-mysql-org#1160 Co-authored-by: Cursor <[email protected]>
|
Hi @lance6716 (or other) FYI, these are the last 3 contributions that I need to have "our" proxy application working:
We can work on them, one by one, if you want. |
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
|
/gemini review |
Extend server capability assertions to include CLIENT_LOCAL_FILES and add a handshake round-trip test that verifies the flag survives negotiation when requested by the client. Co-authored-by: Cursor <[email protected]>
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request enables the mysql.CLIENT_LOCAL_FILES capability by default in both NewDefaultServer and NewServerWithAuth, and adds a corresponding integration test to verify that the capability is successfully negotiated. The review feedback highlights a security concern: enabling CLIENT_LOCAL_FILES by default can expose servers to unauthorized local file access. Since the capability field is unexported, users currently have no way to disable it. It is recommended to provide exported helper methods, such as SetCapability and UnsetCapability, to allow downstream users to configure these capabilities for security compliance.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Expose Server.Capability, SetCapability, and UnsetCapability so downstream users can opt out of CLIENT_LOCAL_FILES when they do not need LOAD DATA LOCAL INFILE relay support. Add TestLocalFilesCapabilityCanBeDisabled to verify the flag is not negotiated after UnsetCapability. Co-authored-by: Cursor <[email protected]>
|
/gemini review |
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
There was a problem hiding this comment.
Code Review
This pull request adds support for the CLIENT_LOCAL_FILES capability in the MySQL server configuration, allowing it to be advertised and negotiated or disabled. It also introduces getter and setter methods (Capability, SetCapability, UnsetCapability) for the server's capability flags. However, because Server is a shared configuration object accessed concurrently, modifying s.capability via SetCapability or UnsetCapability can lead to data races. It is recommended to use atomic operations for accessing and modifying the capability flags.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Remove CLIENT_LOCAL_FILES from default server capabilities so upgrades do not enable LOAD DATA LOCAL INFILE unless explicitly requested via SetCapability. Use atomic operations for Capability, SetCapability, and UnsetCapability to avoid data races on the shared Server config. Update handshake and tests to reflect opt-in behavior. Co-authored-by: Cursor <[email protected]>
|
@lance6716 do you see a "simpler" way to do it? (no rush... ;-) ) |
lance6716
left a comment
There was a problem hiding this comment.
I'd like to review 3 PRs one by one :-)
Will review the rest PRs about 20 hours later.
…ql-org#1163) * server: add CLIENT_LOCAL_FILES to default server capabilities A go-mysql server acting as a proxy must advertise CLIENT_LOCAL_FILES in the handshake so that connecting clients agree to send file packets for LOAD DATA LOCAL INFILE queries. Without this flag, clients that negotiate CLIENT_LOCAL_FILES will never receive the 0xfb request packet from the proxy-as-server, making it impossible to relay LOAD DATA LOCAL INFILE through a transparent proxy. Closes go-mysql-org#1160 Co-authored-by: Cursor <[email protected]> * test: verify CLIENT_LOCAL_FILES advertised and negotiated Extend server capability assertions to include CLIENT_LOCAL_FILES and add a handshake round-trip test that verifies the flag survives negotiation when requested by the client. Co-authored-by: Cursor <[email protected]> * server: add SetCapability and UnsetCapability for handshake flags Expose Server.Capability, SetCapability, and UnsetCapability so downstream users can opt out of CLIENT_LOCAL_FILES when they do not need LOAD DATA LOCAL INFILE relay support. Add TestLocalFilesCapabilityCanBeDisabled to verify the flag is not negotiated after UnsetCapability. Co-authored-by: Cursor <[email protected]> * server: opt-in CLIENT_LOCAL_FILES and use atomic capability flags Remove CLIENT_LOCAL_FILES from default server capabilities so upgrades do not enable LOAD DATA LOCAL INFILE unless explicitly requested via SetCapability. Use atomic operations for Capability, SetCapability, and UnsetCapability to avoid data races on the shared Server config. Update handshake and tests to reflect opt-in behavior. Co-authored-by: Cursor <[email protected]> --------- Co-authored-by: Cursor <[email protected]>
Summary
Add
mysql.CLIENT_LOCAL_FILESto the capability bitmask in bothNewDefaultServerandNewServerWithAuth.Closes #1160
Motivation
A go-mysql server used as a transparent MySQL proxy must advertise
CLIENT_LOCAL_FILESin the initial handshake so that connecting clients agree to participate in theLOAD DATA LOCAL INFILEprotocol.Without this flag, even if the client supports
LOCAL INFILE, it will never send file packets to the proxy because the capability was not offered during negotiation. This makesLOAD DATA LOCAL INFILErelay impossible in proxy scenarios.Changes
server/server_conf.go— one line added to each of the two server constructors:Notes
mysql.CLIENT_LOCAL_FILESis already defined inmysql/const.go.ExecQueryRelayLocalInfile) which provides the client-side relay API needed to complete the proxy pipeline.Made with Cursor