Bug #47216 programs should quit if the file specified by --defaults-file option isn't found
Submitted: 9 Sep 2009 10:25 Modified: 7 Mar 2010 1:44
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Options Severity:S3 (Non-critical)
Version:5.1.37 OS:Any
Assigned to: Alexey Botchkov CPU Architecture:Any

[9 Sep 2009 10:25] Shane Bester
Description:
if you explicitly specified a my.cnf file to use, I think it's reasonable enough to expect the program or server should immediately quit if that my.cnf is not found.  For example, I wanted to check an instance running on port 3308, but due to a typo in the my.cnf path, the instance on port 3306 got checked instead.

D:\5.1.37-win32\bin>mysqlcheck.exe --defaults-file=d:/tmp.my.cnf -c test
Could not open required defaults file: d:/tmp.my.cnf
Fatal error in defaults handling. Program aborted
test.a                                             OK
test.d                                             OK

If you had specified a different user/port/socket in the my.cnf you 
tried to specify using the --defaults-file option, but made a typo
the default localhost/3306/socket will be used instead!  This can lead to
upgrading or optimizing/repairing the totally wrong instance!

How to repeat:
mysqlcheck --defaults-file=/tmp/nonexisting.cnf test -c

If mysqlcheck fails to find the file it'll continue repairing anyway using default port, socket

Suggested fix:
quit if user specified --default-file that couldn't be found.
[9 Sep 2009 11:06] Valeriy Kravchuk
Thank you for the problem report.
[9 Sep 2009 11:12] Peter Laursen
I expressed similar concerns here:
http://bugs.mysql.com/bug.php?id=42028

In this case an erroneous command syntax caused upgrade of the server instance listening on the default port.
[9 Sep 2009 12:05] MySQL Verification Team
just to clarify what i meant by "programs" in the synopsis;  at least the following:  mysql, mysqld, mysql_upgrade, mysqlcheck, myisamchk, mysqlshow, and it appears any other program that accepts the --defaults-file option
[1 Oct 2009 12:58] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/85368

3146 Alexey Botchkov	2009-10-01
      Bug#47216      programs should quit if the file specified by --defaults-file option isn't found
          added code to exit a tool if the forced config file wasn't found
      
      per-file comments:
        client/mysql.cc
      Bug#47216      programs should quit if the file specified by --defaults-file option isn't found
          added code to exit a tool if the forced config file wasn't found
        client/mysql_upgrade.c
      Bug#47216      programs should quit if the file specified by --defaults-file option isn't found
          added code to exit a tool if the forced config file wasn't found
        client/mysqladmin.cc
      Bug#47216      programs should quit if the file specified by --defaults-file option isn't found
          added code to exit a tool if the forced config file wasn't found
        client/mysqlcheck.c
      Bug#47216      programs should quit if the file specified by --defaults-file option isn't found
          added code to exit a tool if the forced config file wasn't found
        client/mysqldump.c
      Bug#47216      programs should quit if the file specified by --defaults-file option isn't found
          added code to exit a tool if the forced config file wasn't found
        client/mysqlimport.c
      Bug#47216      programs should quit if the file specified by --defaults-file option isn't found
          added code to exit a tool if the forced config file wasn't found
        client/mysqlshow.c
      Bug#47216      programs should quit if the file specified by --defaults-file option isn't found
          added code to exit a tool if the forced config file wasn't found
        client/mysqlslap.c
      Bug#47216      programs should quit if the file specified by --defaults-file option isn't found
          added code to exit a tool if the forced config file wasn't found
        mysql-test/t/mysql.test
      Bug#47216      programs should quit if the file specified by --defaults-file option isn't found
         test added
        sql/mysqld.cc
      Bug#47216      programs should quit if the file specified by --defaults-file option isn't found
          added code to exit a tool if the forced config file wasn't found
        storage/myisam/myisamchk.c
      Bug#47216      programs should quit if the file specified by --defaults-file option isn't found
          added code to exit a tool if the forced config file wasn't found
        storage/myisam/myisampack.c
      Bug#47216      programs should quit if the file specified by --defaults-file option isn't found
          added code to exit a tool if the forced config file wasn't found
[9 Oct 2009 16:13] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/86427

3150 Alexey Botchkov	2009-10-09
      Bug#47216      programs should quit if the file specified by --defaults-file option isn't found
          added code to exit a tool if the forced config file wasn't found
      
      per-file comments:
        client/mysql.cc
      Bug#47216      programs should quit if the file specified by --defaults-file option isn't found
          added code to exit a tool if the forced config file wasn't found
        client/mysql_upgrade.c
      Bug#47216      programs should quit if the file specified by --defaults-file option isn't found
          added code to exit a tool if the forced config file wasn't found
        client/mysqladmin.cc
      Bug#47216      programs should quit if the file specified by --defaults-file option isn't found
          added code to exit a tool if the forced config file wasn't found
        client/mysqlcheck.c
      Bug#47216      programs should quit if the file specified by --defaults-file option isn't found
          added code to exit a tool if the forced config file wasn't found
        client/mysqldump.c
      Bug#47216      programs should quit if the file specified by --defaults-file option isn't found
          added code to exit a tool if the forced config file wasn't found
        client/mysqlimport.c
      Bug#47216      programs should quit if the file specified by --defaults-file option isn't found
          added code to exit a tool if the forced config file wasn't found
        client/mysqlshow.c
      Bug#47216      programs should quit if the file specified by --defaults-file option isn't found
          added code to exit a tool if the forced config file wasn't found
        client/mysqlslap.c
      Bug#47216      programs should quit if the file specified by --defaults-file option isn't found
          added code to exit a tool if the forced config file wasn't found
        mysql-test/t/mysql.test
      Bug#47216      programs should quit if the file specified by --defaults-file option isn't found
         test added
        sql/mysqld.cc
      Bug#47216      programs should quit if the file specified by --defaults-file option isn't found
          added code to exit a tool if the forced config file wasn't found
        storage/myisam/myisamchk.c
      Bug#47216      programs should quit if the file specified by --defaults-file option isn't found
          added code to exit a tool if the forced config file wasn't found
        storage/myisam/myisampack.c
      Bug#47216      programs should quit if the file specified by --defaults-file option isn't found
          added code to exit a tool if the forced config file wasn't found
[28 Oct 2009 12:37] Alexander Barkov
The patch http://lists.mysql.com/commits/86427 looks Ok.

Please fix coding style in the lines you edit.

For example:

-  load_defaults("my",load_default_groups,&argc,&argv);
+  if (load_defaults("my",load_default_groups,&argc,&argv))
+    return 1;

Extra spaces should be added:

-  load_defaults("my",load_default_groups,&argc,&argv);
+  if (load_defaults("my", load_default_groups, &argc, &argv))  <-- in this line
+    return 1;
[18 Nov 2009 14:40] Alexey Botchkov
pushed into mysql-next-mr-bugfixing
[20 Nov 2009 12:57] Bugs System
Pushed into 6.0.14-alpha (revid:kostja@sun.com-20091120124947-yi6h2jbgw0kbciwm) (version source revid:holyfoot@mysql.com-20091117114617-75quk99yr1coxv8c) (merge vers: 6.0.14-alpha) (pib:13)
[23 Nov 2009 20:08] Paul DuBois
Noted in 6.0.14 changelog.

Setting report to NDI pending push into 5.6.x.
[11 Dec 2009 6:04] Bugs System
Pushed into 5.6.0-beta (revid:alik@sun.com-20091211055628-ltr7fero363uev7r) (version source revid:alik@sun.com-20091211055453-717czhtezc74u8db) (merge vers: 5.6.0-beta) (pib:13)
[11 Dec 2009 19:55] Paul DuBois
Noted in 5.6.0 changelog.
[6 Mar 2010 11:08] Bugs System
Pushed into 5.5.3-m3 (revid:alik@sun.com-20100306103849-hha31z2enhh7jwt3) (version source revid:vvaintroub@mysql.com-20091211201717-03qf8ckwiw0np80p) (merge vers: 5.6.0-beta) (pib:16)
[7 Mar 2010 1:44] Paul DuBois
Moved 5.6.0 changelog entry to 5.5.3.