Skip to content

fix(mysql): advertise CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA in server greeting#5744

Merged
renecannao merged 4 commits into
v3.0from
fix/4760-lenenc-auth-v3.0
May 4, 2026
Merged

fix(mysql): advertise CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA in server greeting#5744
renecannao merged 4 commits into
v3.0from
fix/4760-lenenc-auth-v3.0

Conversation

@renecannao

@renecannao renecannao commented May 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Advertise CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA (0x00200000) in the server greeting packet's extended_capabilities, making ProxySQL compatible with clients like Boost MySQL that require this capability flag before connecting.
  • ProxySQL already correctly parses lenenc-encoded auth data from clients (MySQL_Protocol.cpp:1708); it just never advertised the flag, so strict clients refused to connect.
  • Updated the existing test_greeting_capabilities-t baseline regression check to include the new flag.
  • Added new test_plugin_auth_lenenc_client_data-t TAP test that exercises the full lenenc auth path end-to-end (server advertises flag, client negotiates it, query succeeds).

Context

Closes #4760

Testing

  • Library and test binaries compile cleanly.
  • lint_groups_json.py passes.
  • check_groups.py --source shows no regressions (pre-existing mysqlx_admin_alias_resolution_unit-t missing from groups.json is unrelated).

Summary by CodeRabbit

  • New Features

    • Server now advertises extended plugin authentication capabilities during the initial MySQL handshake, improving interoperability with modern MySQL clients.
  • Tests

    • Added integration test validating server capability advertisement and client-side negotiation for enhanced authentication features during connection handshake, including multiple configuration scenarios.

renecannao added 2 commits May 3, 2026 17:44
… greeting

ProxySQL already correctly parses the lenenc auth data format when
clients send it in the handshake response (MySQL_Protocol.cpp:1708),
but the server greeting packet never advertised the capability flag.

Clients like Boost MySQL require this flag before they will even attempt
a connection. Adding it to extended_capabilities makes ProxySQL
compatible with such clients without any protocol behavior change.

The existing test_greeting_capabilities-t test is updated to include the
new flag in the baseline regression check.

Closes: #4760
…_DATA

New TAP test test_plugin_auth_lenenc_client_data-t that:
- Connects via mariadb client library (which auto-negotiates lenenc auth
  when the server advertises it, same as Boost MySQL does)
- Verifies server greeting contains CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA
- Verifies client actually negotiated the flag (lenenc path exercised)
- Executes a query to confirm the session is fully functional
- Tests with deprecate_eof=ON and OFF

Registered in groups.json alongside test_greeting_capabilities-t.
@coderabbitai

coderabbitai Bot commented May 3, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7b598f77-438c-43a5-bb1a-a78b930d019d

📥 Commits

Reviewing files that changed from the base of the PR and between 05d0268 and 325b3e4.

📒 Files selected for processing (4)
  • lib/MySQL_Protocol.cpp
  • test/tap/groups/groups.json
  • test/tap/tests/test_greeting_capabilities-t.cpp
  • test/tap/tests/test_plugin_auth_lenenc_client_data-t.cpp
📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{cpp,h,hpp}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{cpp,h,hpp}: Class names must use PascalCase with protocol prefixes (MySQL_, PgSQL_, ProxySQL_)
Member variables must use snake_case naming convention
Constants and macros must use UPPER_SNAKE_CASE naming convention
Use conditional compilation via #ifdef PROXYSQL31, #ifdef PROXYSQL40, #ifdef PROXYSQLFFTO, #ifdef PROXYSQLTSDB, #ifdef PROXYSQLCLICKHOUSE for feature tier gating in core code

Files:

  • test/tap/tests/test_plugin_auth_lenenc_client_data-t.cpp
  • lib/MySQL_Protocol.cpp
  • test/tap/tests/test_greeting_capabilities-t.cpp
test/tap/tests/{test_*,-t}.cpp

📄 CodeRabbit inference engine (CLAUDE.md)

Test files must follow the naming pattern test_*.cpp or *-t.cpp in test/tap/tests/

Files:

  • test/tap/tests/test_plugin_auth_lenenc_client_data-t.cpp
  • test/tap/tests/test_greeting_capabilities-t.cpp
test/tap/tests/*-t.cpp

📄 CodeRabbit inference engine (CLAUDE.md)

Test binaries are built via pattern rule in test/tap/tests/Makefile: make <testname>-t compiles <testname>-t.cpp into <testname>-t without requiring explicit Makefile targets

Files:

  • test/tap/tests/test_plugin_auth_lenenc_client_data-t.cpp
  • test/tap/tests/test_greeting_capabilities-t.cpp
🧠 Learnings (1)
📚 Learning: 2026-01-20T09:34:19.124Z
Learnt from: yuji-hatakeyama
Repo: sysown/proxysql PR: 5307
File: test/tap/tests/reg_test_5306-show_warnings_with_comment-t.cpp:39-48
Timestamp: 2026-01-20T09:34:19.124Z
Learning: In ProxySQL's TAP test suite, resource leaks (e.g., not calling mysql_close() on early return paths) are commonly tolerated because test processes are short-lived and OS frees resources on exit. This pattern applies to all C++ test files under test/tap/tests. When reviewing, recognize this as a project-wide test convention and focus on test correctness and isolation rather than insisting on fixing such leaks in these test files.

Applied to files:

  • test/tap/tests/test_plugin_auth_lenenc_client_data-t.cpp
  • test/tap/tests/test_greeting_capabilities-t.cpp
🔇 Additional comments (4)
lib/MySQL_Protocol.cpp (1)

1131-1137: LGTM — correct placement and no protocol behavior change.

CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA = 0x00200000 is bit 21, so it belongs exclusively in the upper word of the greeting. The lower-word memcpy at line 1108 copies only 2 bytes from server_capabilities (bits 0–15) and won't inadvertently broadcast this bit. The lenenc parsing path in PPHR_2() (line 1714) already existed and is keyed on vars1.capabilities (the client's flags), so there is no regression from server_capabilities not carrying this bit. The fix is purely advertisement-only, exactly as intended.

test/tap/tests/test_greeting_capabilities-t.cpp (1)

177-185: LGTM — baseline correctly updated to match the new greeting advertisement.

test/tap/groups/groups.json (1)

380-380: LGTM — properly inserted in alphabetical order with the correct -g3 target group set.

test/tap/tests/test_plugin_auth_lenenc_client_data-t.cpp (1)

59-131: LGTM — end-to-end test is well-structured.

Both the server-advertisement check (server_has_lenenc) and the client-negotiation check (client_has_lenenc) are intentional per the PR description, and the separate diag() lines (88–91) make it clear which side failed if the test ever breaks. Cleanup is consistent across all code paths.


📝 Walkthrough

Walkthrough

This PR adds support for advertising the CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA capability in the MySQL protocol handshake greeting. A new integration test validates the capability is properly advertised and negotiated, while baseline test expectations are updated accordingly.

Changes

Plugin Auth Capability Advertisement

Layer / File(s) Summary
Core Implementation
lib/MySQL_Protocol.cpp
extended_capabilities bitmask in generate_pkt_initial_handshake now includes CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA alongside existing CLIENT_PLUGIN_AUTH, CLIENT_SESSION_TRACKING, and CLIENT_REMEMBER_OPTIONS bits.
Test Infrastructure
test/tap/groups/groups.json
New test group entry "test_plugin_auth_lenenc_client_data-t" is registered to execute against legacy-g3 and MySQL variant targets (matching other test suite patterns).
Test Baseline Update
test/tap/tests/test_greeting_capabilities-t.cpp
BASELINE_PRESENT_CAPS is updated to require CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA in server greeting, so missing capability bits are reported as expected failures.
Integration Test
test/tap/tests/test_plugin_auth_lenenc_client_data-t.cpp
New TAP test validates capability advertisement by toggling mysql-enable_client_deprecate_eof, connecting via MariaDB/MySQL C API, verifying both server_capabilities and client_flag bits are set, and executing a connectivity test query.

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly Related Issues

  • Cannot connect to ProxySQL with boost mysql. #4760: Boost MySQL connector fails to connect to ProxySQL due to missing CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA capability flag in server handshake—this PR directly addresses that by advertising the required capability.

Possibly Related PRs

Poem

🐰 A flag hops forth with quiet grace,
CLIENT_PLUGIN_AUTH_LENENC takes its place,
In handshakes warm and headers bright,
The Boost connector finds its light! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: advertising CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA in the server greeting, which aligns directly with all the file changes.
Linked Issues check ✅ Passed The PR fully addresses issue #4760 by advertising CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA in server greeting, adding comprehensive tests, and validating the capability negotiation end-to-end.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the fix for issue #4760: capability advertisement in handshake, test coverage, and test configuration; no unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/4760-lenenc-auth-v3.0

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds the CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA capability to the MySQL server greeting in lib/MySQL_Protocol.cpp, allowing ProxySQL to support length-encoded authentication data. The changes also include a new test suite and updates to existing test configurations. Feedback suggests adding a fallback definition for the new capability flag to ensure compatibility with older development headers and recommends adding a null check for query results in the test code to prevent potential crashes.

CLIENT_MULTI_RESULTS,
CLIENT_PS_MULTI_RESULTS,
CLIENT_PLUGIN_AUTH,
CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To ensure compilation succeeds on systems with older MySQL/MariaDB development headers, consider adding a fallback definition for CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA at the top of this file, similar to what was done in lib/MySQL_Protocol.cpp and the new test file.

}

MYSQL_ROW row = mysql_fetch_row(res);
if (!row || strcmp(row[0], "1") != 0) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

It is safer to check if row[0] is not NULL before passing it to strcmp, even if the query is expected to return a value. This prevents potential crashes if the result set is unexpected.

	if (!row || row[0] == NULL || strcmp(row[0], "1") != 0) {

@sonarqubecloud

sonarqubecloud Bot commented May 4, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot connect to ProxySQL with boost mysql.

1 participant