Bug 235654 - databases/mariadb103-client installed mytop does not work with ~/.my.cnf
Summary: databases/mariadb103-client installed mytop does not work with ~/.my.cnf
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Bernard Spil
Depends on:
Reported: 2019-02-10 21:09 UTC by Miroslav Lachman
Modified: 2019-02-21 15:56 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (brnrd)

process configuration files / options in correct order (1.41 KB, patch)
2019-02-21 15:56 UTC, Miroslav Lachman
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Miroslav Lachman 2019-02-10 21:09:32 UTC
Previously the "mytop" was standalone port. I upgraded MariaDB 10.1 to 10.3 which is conflicting with installed "mytop". Original "mytop" was removed and "mytop" from mariadb103-client package does not work if user has ~/my.cnf with stored password for different user (login) than should be used with "mytop".

"mytop" should read its options from ~/.mytop file where I have all the options specified


But when I run "mytop" I got these error:

Cannot connect to MariaDB server. Please check the:

  * database you specified "mysql" (default is "test")
  * username you specified "mytop" (default is "root")
  * password you specified "AnotherPassword" (default is "")
  * hostname you specified "localhost" (default is "localhost")
  * port you specified "3306" (default is 3306)
  * socket you specified "/tmp/mysql.sock" (default is "")

The options my be specified on the command-line or in a ~/.mytop
config file. See the manual (perldoc mytop) for details.

Here's the exact error from DBI. It might help you debug:'

Access denied for user 'mytop'@'localhost' (using password: YES)

Where "AnotherPassword" is the password read from ~/.my.cnf which is password for my currently logged user and not password for user "mytop" under which "mytop" should run.

It worked for me for the last 10+ years with standalone "mytop" but does not work anymore.

The next problem is that "mytop" has dependencies on some Perl libraries but they are not specified in the mariadb103-client package. (all are installed in my case)
Comment 1 Miroslav Lachman 2019-02-21 15:55:19 UTC
Even if mytop's manpage says it should work as I expect, it does not work that way.

mytop will first read the [client] and [mytop] sections from your
my.cnf files. After that it will read the ~/.mytop file from your
home directory (if present). These are read before any of your
command-line arguments are processed, so your command-line arguments
will override directives in the config file.

The reality is that my.cnf and ~/.my.cnf are read first but are processed in the different way and values from my.cnf take precedence. Cannot be overridden from ~/.mytop or cmd args.

I changed the part for assigning values from ~/.mytop to act like reading ~/.my.cnf so it is now in the correct (and documented) order:
1) read my.cnf and ~/.my.cnf
2) read ~/.mytop
3) read command line arguments

All are processed in the same way.
Comment 2 Miroslav Lachman 2019-02-21 15:56:41 UTC
Created attachment 202233 [details]
process configuration files / options in correct order