Skip to content

MDEV-39290 mytop use invoking login as default user on Unix#4918

Merged
gkodinov merged 1 commit into
MariaDB:mainfrom
aquilamacedo:main
Apr 28, 2026
Merged

MDEV-39290 mytop use invoking login as default user on Unix#4918
gkodinov merged 1 commit into
MariaDB:mainfrom
aquilamacedo:main

Conversation

@aquilamacedo

Copy link
Copy Markdown
Contributor

mytop defaults the database user to root.

On Unix, the mysql and mariadb clients use the current OS login when no user is specified. Because of that difference, mytop may try to connect as root@localhost and fail on setups where local unix_socket access is configured for the normal user instead of root.

This patch changes the default on non-Windows systems to the invoking login name, using getpwuid($<) first, then LOGNAME, then USER, and finally root. Windows keeps the existing default of root.

It also updates the connection failure message and POD so the documented defaults match the actual behavior.

Jira ticket: Fixes MDEV-39290.

Testing

Manual checks on Debian 13 with MariaDB 11.8.6 client:

  1. As non-root, with no ~/.mytop and no -u:
    mytop -h 127.0.0.1 -P 65534 -b -s 1
    Result: error text shows username ... "testuser" and (default is "testuser").

  2. With both root@localhost and testuser@localhost using unix_socket:
    su - testuser -c 'mytop -b -s 1'
    Result: connects and prints status.

  3. As testuser, forcing -u root:
    su - testuser -c 'mytop -b -s 1 -u root'
    Result: uses root as requested, message still shows (default is "testuser").

  4. As root:
    sudo mytop -b -s 1
    Result: works with socket-authenticated root.

@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Apr 9, 2026

@gkodinov gkodinov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for your contribution! This is a preliminary review.

LGTM. I'd also explore the possibility of a regression test, but that's highly optional.

Please stand by for the final review.

@grooverdan
grooverdan enabled auto-merge (rebase) April 28, 2026 01:39
@ottok

ottok commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

This has two approvals. Why wasn't it merged?

@gkodinov

Copy link
Copy Markdown
Member

This has two approvals. Why wasn't it merged?

it needs to pass the buildbot tests first, Otto. In progress.

@gkodinov
gkodinov disabled auto-merge April 28, 2026 10:00
@gkodinov
gkodinov enabled auto-merge (rebase) April 28, 2026 10:01
@ottok

ottok commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

This has two approvals. Why wasn't it merged?

it needs to pass the buildbot tests first, Otto. In progress.

Is there something you can to do trigger the buildbot tests? They seem to have been pending for 3 weeks?

On non-Windows systems, use the invoking user's login name as the
default MariaDB username instead of hardcoding root.

Resolve the username from getpwuid($<), falling back to LOGNAME, USER,
and finally root. Keep the existing root default on Windows.

This makes mytop behave more like the mysql and mariadb clients and
avoids confusing authentication failures on systems where local socket
access is configured for the OS user rather than root.

Also update the connection error text and POD to describe the actual
default behavior.
@gkodinov

Copy link
Copy Markdown
Member

This has two approvals. Why wasn't it merged?

it needs to pass the buildbot tests first, Otto. In progress.

Is there something you can to do trigger the buildbot tests? They seem to have been pending for 3 weeks?

I'm doing my best. And monitoring it actively.

@gkodinov
gkodinov merged commit 1450236 into MariaDB:main Apr 28, 2026
18 checks passed
@grooverdan

Copy link
Copy Markdown
Member

This has two approvals. Why wasn't it merged?

I was waiting for a 13.0 branch, but apparently that is getting forked off main once the 13.0 preview branch gets merged to main.

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

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.

Development

Successfully merging this pull request may close these issues.

4 participants