Bug 235654

Summary: databases/mariadb103-client installed mytop does not work with ~/.my.cnf
Product: Ports & Packages Reporter: Miroslav Lachman <000.fbsd>
Component: Individual Port(s)Assignee: Bernard Spil <brnrd>
Status: New ---    
Severity: Affects Some People Flags: bugzilla: maintainer-feedback? (brnrd)
Priority: ---    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
process configuration files / options in correct order none

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

user=mytop
pass=SomeStrongPasswordHere
host=localhost
db=mysql
delay=3
port=3306
socket=/tmp/mysql.sock
batchmode=0
header=1
color=1
idle=1
resolve=1

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.

manpage:
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