Bug 182547 - [PATCH] databases/mariadb55-server: Respect hier(7) (also affects databases/mariadb55-client)
Summary: [PATCH] databases/mariadb55-server: Respect hier(7) (also affects databases/m...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Michael Gmelin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-01 15:00 UTC by Michael Gmelin
Modified: 2014-05-21 11:43 UTC (History)
1 user (show)

See Also:


Attachments
mariadb-5.5.33a_1.patch (6.93 KB, patch)
2013-10-01 15:00 UTC, Michael Gmelin
no flags Details | Diff
mariadb55-mycnf-quip.patch (72.34 KB, patch)
2013-10-01 20:30 UTC, Michael Gmelin
no flags Details | Diff
mariadb55-mycnf-compromise.patch (73.15 KB, patch)
2013-10-01 23:19 UTC, Michael Gmelin
no flags Details | Diff
mariadb55-mycnf-compromise.patch (7.45 KB, patch)
2013-10-02 00:06 UTC, Michael Gmelin
no flags Details | Diff
mariadb55-mycnf-20131015.patch (11.10 KB, patch)
2013-10-15 21:20 UTC, Michael Gmelin
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Gmelin 2013-10-01 15:00:00 UTC
Like outlined in [1], MariaDB looks for my.cnf in /etc and /etc/mysql
instead of $PREFIX/etc and $PREFIX/etc/mysql. The attached patch fixes
this, so that hier(7) is respected and $PREFIX/etc is used instead of
/etc. This is in line with the behavior found in and expected by
$PREFIX/bin/mysqld_safe.  A note has been put in pkg-message (using
pkg-message.in) to inform users about the fix. Portrevision has been
bumped.

[1] http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/182426#reply2

Port maintainer (never@nevermind.kiev.ua) is cc'd.

Generated with FreeBSD Port Tools 0.99_7 (mode: change, diff: suffix)

Fix: Apply the attached patch to mariadb55-{server|client}

cd /usr/ports
patch -p0 </path/to/mariadb-5.5.33a_1.patch

portmaster databases/mariadb55-server
...
===>>> pkg-message for mariadb-client-5.5.33a_1
************************************************************************

MariaDB respects hier(7) and doesn't check /etc and /etc/mysql for
my.cnf. Please move existing my.cnf files from those paths to
/usr/local/etc and /usr/local/etc/mysql.

************************************************************************

===>>> pkg-message for mariadb-server-5.5.33a_1
************************************************************************

Remember to run mysql_upgrade (with the optional --datadir=<dbdir> flag)
the first time you start the MySQL server after an upgrade from an
earlier version.

MariaDB respects hier(7) and doesn't check /etc and /etc/mysql for
my.cnf. Please move existing my.cnf files from those paths to
/usr/local/etc and /usr/local/etc/mysql.

************************************************************************

How-To-Repeat: echo garbage >/etc/my.cnf
mysql
(shouldn't barf, but will)

echo garbage >/usr/local/etc/my.cnf
mysql
(should barf, but won't)
Comment 1 Edwin Groothuis freebsd_committer 2013-10-01 15:00:09 UTC
State Changed
From-To: open->feedback

Awaiting maintainers feedback (via the GNATS Auto Assign Tool)
Comment 2 Edwin Groothuis freebsd_committer 2013-10-01 15:00:09 UTC
Maintainer of databases/mariadb55-server,

Please note that PR ports/182547 has just been submitted.

If it contains a patch for an upgrade, an enhancement or a bug fix
you agree on, reply to this email stating that you approve the patch
and a committer will take care of it.

The full text of the PR can be found at:
    http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/182547

-- 
Edwin Groothuis via the GNATS Auto Assign Tool
edwin@FreeBSD.org
Comment 3 quip 2013-10-01 19:03:48 UTC
I tried MariaDB today (older version: 5.5.31) as a replacement for MySQL 
5.5 and I found this problem with not using my.cnf from 
/usr/local/etc/my.cnf

The old behavior in MySQL 5.5 was this:

# my_print_defaults --help | grep -A1 'Default options'
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf 
/usr/local/etc/mysql/my.cnf ~/.my.cnf

MariaDB uses only these:

# my_print_defaults --help | grep -A1 'Default options'
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf

So I propose to do the same as original MySQL 5.5 above

Miroslav Lachman
Comment 4 Michael Gmelin 2013-10-01 20:30:19 UTC
I honestly think that nobody in their right mind should place MySQL
configuration fiels in /etc on FreeBSD and at least some of the scripts
(e.g. checking for redundant configurations on startup) are not
and never have been prepared for handling this situation. I even think
it would be better to change the mysql port to the proposed behavior as
well.

Maybe it would make sense to discuss this on ports@ and/or with the
maintainer of the mysql ports.

That said, since this is the port maintainer's decision to make, I
created an additional patch attached to this email to allow Alexandr
to decide for himself without any extra work.

Cheers,
Michael

-- 
Michael Gmelin
Comment 5 Miroslav Lachman 2013-10-01 20:52:01 UTC
I totally agree with you from the FreeBSD point of view. But on another 
way, I can imagine somebody with my.cnf configuration file in /etc/ even 
on FreeBSD, because it is documented in manpage
http://dev.mysql.com/doc/refman/5.5/en/option-files.html and because it 
was "default" in MariaDB for a long time
It is better to not break some "rare user's" setup.

If we decide to get rid of /etc/ and /etc/mysql/ dirs, then it shoul be 
mentioned in UPDATING too and maybe provide some check on install or 
service re-start for transitional time which will again warn the user 
about this change (beside the pkg-message). Becaus missing my.cnf at 
startup can cause serious problem.

Miroslav Lachman
Comment 6 Michael Gmelin 2013-10-01 23:19:51 UTC
On Tue, 01 Oct 2013 21:52:01 +0200
Miroslav Lachman <000.fbsd@quip.cz> wrote:

> I totally agree with you from the FreeBSD point of view. But on
> another way, I can imagine somebody with my.cnf configuration file
> in /etc/ even on FreeBSD, because it is documented in manpage
> http://dev.mysql.com/doc/refman/5.5/en/option-files.html and because
> it was "default" in MariaDB for a long time
> It is better to not break some "rare user's" setup.
> 
> If we decide to get rid of /etc/ and /etc/mysql/ dirs, then it shoul
> be mentioned in UPDATING too and maybe provide some check on install
> or service re-start for transitional time which will again warn the
> user about this change (beside the pkg-message). Becaus missing
> my.cnf at startup can cause serious problem.
> 
> Miroslav Lachman
> 

I see various reasonable approaches for avoiding the missing my.cnf
scenario:

1. Check on install, using a port mechanism + pkg-install for packages.
   Might be annoying and error prone and won't help if the user places
   a file in /etc or /etc/mysql after installing the port/package.
2. Check on starting mysql-server (modify /usr/local/bin/mysqld_safe)
   and fail to start if /etc/my.cnf or /etc/mysql/my.cnf exist. This is
   easy to accomplish, but only helps for starting mysqld and not for
   the monitor or other client applications.
3. Modify MariaDB confsources, so it handles the existence
   of /etc/my.cnf or /etc/mysql/my.cnf like a syntax error in
   my.cnf.

I like option 3 best, because it helps new users who are trying to
configure MariaDB for the first time based on the resources you
mentioned above as well as users upgrading or migrating from MySQL. I
looked into mysys/default.c, and the check can be implemented quite
easily at about line 805:

if (strstr(name, "/etc") == name)
{
  fprintf(stderr,
            "error: Config file %s in invalid location, please move to
            or merge with %%PREFIX%%%s\n",
            name,name);
     goto err;
}

I implemented this in the patch attached, which replaces all previous
patches submitted in this PR. So now mysql fails to initialize
if /etc/my.cnf and/or /etc/mysql/my.cnf exist, e.g.:

# touch /etc/my.cnf
# mkdir /etc/mysql
# touch /etc/mysql/my.cnf
# mysql
error: Config file /etc/my.cnf in invalid location, please move to or
merge with /usr/local/etc/my.cnf
Fatal error in defaults handling. Program aborted
# rm /etc/my.cnf
# mysql
error: Config file /etc/mysql/my.cnf in invalid location, please move
to or merge with /usr/local/etc/mysql/my.cnf
Fatal error in defaults handling. Program aborted
# rm /etc/mysql/my.cnf
# mysql
...
MariaDB [(none)]>

Obviously this is also true for "service mysql-server start".

On top op this we still have pkg-message in both ports stating:
"MariaDB respects hier(7) and doesn't check /etc and /etc/mysql for
my.cnf. Please move existing my.cnf files from those paths to
/usr/local/etc and /usr/local/etc/mysql."

What do you think?

Cheers,
Michael

-- 
Michael Gmelin
Comment 7 Michael Gmelin 2013-10-02 00:06:55 UTC
The last patch contained a lot of unnecessary garbage
(databases/mariadb55*.orig), please find attached a "clean" version.

Sorry for the noise.

Apply:
cd /usr/ports/databases
patch -p1 </path/to/mariadb55-mycnf-compromise.patch 

Cheers,
Michael

-- 
Michael Gmelin
Comment 8 Miroslav Lachman 2013-10-02 20:55:29 UTC
I am still not 100% sure we should handle existence of /etc/my.cnf as 
parse error.
Change of location of config file for Lighttpd was handled more 
gracefully - print warning message, if old path was found and use it 
even if config in new location is present. (it is there on all new 
installations, check is done in rc.d/lighttpd)

On the other way, if we print the message instructing user to move 
my.cnf to proper location, then it will not cause too much harm and 
problem can be solved within few seconds.
So I am fine with your suggested solution.

I will test your patch in a few days. I am too busy with my $WORK now.

Miroslav Lachman
Comment 9 Michael Gmelin 2013-10-10 20:30:05 UTC
On Wed, 02 Oct 2013 21:55:29 +0200
Miroslav Lachman <000.fbsd@quip.cz> wrote:

> I am still not 100% sure we should handle existence of /etc/my.cnf as 
> parse error.
> Change of location of config file for Lighttpd was handled more 
> gracefully - print warning message, if old path was found and use it 
> even if config in new location is present. (it is there on all new 
> installations, check is done in rc.d/lighttpd)
> 
> On the other way, if we print the message instructing user to move 
> my.cnf to proper location, then it will not cause too much harm and 
> problem can be solved within few seconds.
> So I am fine with your suggested solution.
> 
> I will test your patch in a few days. I am too busy with my $WORK now.
> 
> Miroslav Lachman

Did you have a chance to test the patch yet?

Michael

-- 
Michael Gmelin
Comment 10 Miroslav Lachman 2013-10-11 15:56:43 UTC
Michael Gmelin wrote:
> On Wed, 02 Oct 2013 21:55:29 +0200
> Miroslav Lachman<000.fbsd@quip.cz>  wrote:
>>
>> I will test your patch in a few days. I am too busy with my $WORK now.
>>
>> Miroslav Lachman
>
> Did you have a chance to test the patch yet?
>
> Michael

I tried it right now, but I have a problem. mariadb55-server cannot be 
built on my test machine FreeBSD 9.2-RC4 amd64 GENERIC.

I always get this error even with original (not patched) version:

Creating bzip'd tar ball in 
'/usr/ports/databases/mariadb55-server/work/mariadb55-server-5.5.33a.tbz'
tar: lib/mysql/plugin/auth_pam.so: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors.
pkg_create: make_dist: tar command failed with code 256

I'll investigate it later. I have mariadb55-server-5.5.33a built on 8.4 
production server, so I don't know why it failed on 9.2-RC4.
Comment 11 Michael Gmelin 2013-10-11 16:06:36 UTC
> I'll investigate it later. I have mariadb55-server-5.5.33a built on 8.4 pr=
oduction server, so I don't know why it failed on 9.2-RC4.

Could it be a victim of staging? Should not be related to my patch, but I ca=
n still look into it over the next few days.=
Comment 12 Miroslav Lachman 2013-10-11 17:41:01 UTC
Michael Gmelin wrote:
>> I'll investigate it later. I have mariadb55-server-5.5.33a built on 8.4 production server, so I don't know why it failed on 9.2-RC4.

I am not able to find a proper fix of the problem with auth_pam.so, so I 
just delete it from pkg-plist. MariaDB works without it.

Tests I did:

1) start MariaDB with /usr/local/etc/my.cnf
	works
2) start MariaDB with /etc/my.cnf
	failed to start [intended]
3) check my_print_defaults --help
	it still prints /etc/ and /etc/mysql/ as right locations for my.cnf
	[wrong]

And I have a comment to (2). It prints the error message to a logfile, 
but user is not informed about any error with 'service' command.
I think it should be printed to the users console.

I did:

root@sm-reserve ~/# service mysql-server onestart
Starting mysql.

As you can see, 'service' command said "Starting mysql." and no error 
was shown, which is really bad. I thought it started with /etc/my.cnf 
and later found in a logfile, that MariaDB start failed:

root@sm-reserve ~/# tail -f /var/db/mysql/sm-reserve.codelab.cz.err

131011 18:18:23 mysqld_safe Starting mysqld daemon with databases from 
/var/db/mysql
error: Config file /etc/my.cnf in invalid location, please move to or 
merge with /usr/local/etc/my.cnf
Fatal error in defaults handling. Program aborted
131011 18:18:23 mysqld_safe mysqld from pid file 
/var/db/mysql/sm-reserve.codelab.cz.pid ended

Maybe it is not related to your patch but why 'service' (rc script 
mysql-server) is silent in the case of a failed start?

Miroslav Lachman
Comment 13 Michael Gmelin 2013-10-11 18:16:42 UTC
> On 11 Oct 2013, at 18:41, Miroslav Lachman <000.fbsd@quip.cz> wrote:
> Maybe it is not related to your patch but why 'service' (rc script mysql-s=
erver) is silent in the case of a failed start?
>
> Miroslav Lachman

Afaik service mysql always has been silent about errors (eg innodb log file s=
izes don't match etc) due to the way the daemon is started, this should be t=
he same with mysql55. I remember missing a warning about innodb not working m=
any years ago since it was buried in MySQL error log

So improving this - also for the MySQL port - would be great, but might be o=
utside of the scope of this PR.
Comment 14 Miroslav Lachman 2013-10-12 12:19:34 UTC
Michael Gmelin wrote:
> Afaik service mysql always has been silent about errors (eg innodb log file sizes don't match etc) due to the way the daemon is started, this should be the same with mysql55. I remember missing a warning about innodb not working many years ago since it was buried in MySQL error log
>
> So improving this - also for the MySQL port - would be great, but might be outside of the scope of this PR.

So how about this patch to rc.d/mysql-server:

--- /usr/local/etc/rc.d/mysql-server.orig 2013-10-11 18:09:34.000000000 
+0200
+++ /usr/local/etc/rc.d/mysql-server    2013-10-12 13:12:59.000000000 +0200
@@ -52,6 +52,11 @@

  mysql_prestart()
  {
+	if [ -f "/etc/my.cnf" -o -f "/etc/mysql/my.cnf" ]; then
+		echo "Please move existing my.cnf file from /etc to /usr/local/etc"
+		return 1
+	fi
+

And are you able to fix my_print_defaults --help to not print /etc/ and 
/etc/mysql/ as default options directories?

Miroslav
Comment 15 Michael Gmelin 2013-10-12 12:22:33 UTC
> On 12 Oct 2013, at 13:19, Miroslav Lachman <000.fbsd@quip.cz> wrote:
> @@ -52,6 +52,11 @@
>=20
> mysql_prestart()
> {
> +    if [ -f "/etc/my.cnf" -o -f "/etc/mysql/my.cnf" ]; then
> +        echo "Please move existing my.cnf file from /etc to /usr/local/et=
c"
> +        return 1
> +    fi
> +

Maybe make it two checks, so it reports the correct file locations?

>=20
> And are you able to fix my_print_defaults --help to not print /etc/ and /e=
tc/mysql/ as default options directories?
>=20
Should be possible, I will prepare a patch early next week.

Michael=
Comment 16 Michael Gmelin 2013-10-15 21:20:56 UTC
On Sat, 12 Oct 2013 13:19:34 +0200
Miroslav Lachman <000.fbsd@quip.cz> wrote:

> And are you able to fix my_print_defaults --help to not print /etc/
> and /etc/mysql/ as default options directories?
> 
> Miroslav

Hi,

Please find attached a patch that fixes my_print_defaults as well as
incorporates a modified version of what you suggested for
rc.d/mysql-server.

The patch is against the latest SVN version and incorporates
the fix Alexandr's posted about an hour ago
as PR 183001: http://www.freebsd.org/cgi/query-pr.cgi?pr=183001

Cheers,
Michael

-- 
Michael Gmelin
Comment 17 Florian Smeets freebsd_committer 2013-10-16 00:26:34 UTC
Responsible Changed
From-To: freebsd-ports-bugs->flo

I'll take it.
Comment 18 Michael Gmelin 2013-12-11 19:09:34 UTC
Any chance to get this committed?

MariaDB not picking up /usr/local/etc/my.cnf is *really* annoying
and may result in data loss.

-- 
Michael Gmelin
Comment 19 Florian Smeets freebsd_committer 2014-01-21 07:21:01 UTC
Responsible Changed
From-To: flo->grembo

It's your duty to commit this now :)
Comment 20 Miroslav Lachman 2014-05-15 00:09:39 UTC
Please, stop playing ping pong with this PR and commit the patch.
It is well tested fix improving compatibility with original MySQL port 
and fixing serious issue in the case of upgrad from the older MySQL 
version to MariaDB.
I was bitten in the a** again, because MariaDB ignored 
/usr/local/etc/my.cnf

This fix is in the queue for more than half year.
Where should we get the motivation to fix a bugs and post the patches / 
PRs, if even this simple patch cannot be committed for a long time.
Comment 21 Michael Gmelin 2014-05-15 10:25:24 UTC
> On 15 May 2014, at 01:09, Miroslav Lachman <000.fbsd@quip.cz> wrote:
>=20
> Please, stop playing ping pong with this PR and commit the patch.
> It is well tested fix improving compatibility with original MySQL port and=
 fixing serious issue in the case of upgrad from the older MySQL version to M=
ariaDB.
> I was bitten in the a** again, because MariaDB ignored /usr/local/etc/my.c=
nf
>=20
> This fix is in the queue for more than half year.
> Where should we get the motivation to fix a bugs and post the patches / PR=
s, if even this simple patch cannot be committed for a long time.

I'll take care of it.=
Comment 22 dfilter service freebsd_committer 2014-05-21 11:37:56 UTC
Author: grembo
Date: Wed May 21 10:37:51 2014
New Revision: 354740
URL: http://svnweb.freebsd.org/changeset/ports/354740
QAT: https://qat.redports.org/buildarchive/r354740/

Log:
  Respect hier(7) for config files
  
  PR:		ports/182547
  Reviewed by:	flo
  Approved by:	flo

Added:
  head/databases/mariadb55-client/files/pkg-message.in   (contents, props changed)
  head/databases/mariadb55-server/files/pkg-message.in   (contents, props changed)
Deleted:
  head/databases/mariadb55-server/pkg-message
Modified:
  head/UPDATING
  head/databases/mariadb55-client/Makefile
  head/databases/mariadb55-client/files/patch-mysys_default.c
  head/databases/mariadb55-server/Makefile
  head/databases/mariadb55-server/files/mysql-server.in
  head/databases/mariadb55-server/files/patch-mysys_default.c

Modified: head/UPDATING
==============================================================================
--- head/UPDATING	Wed May 21 10:32:46 2014	(r354739)
+++ head/UPDATING	Wed May 21 10:37:51 2014	(r354740)
@@ -5,6 +5,18 @@ they are unavoidable.
 You should get into the habit of checking this file for changes each time
 you update your ports collection, before attempting any port upgrades.
 
+20140521:
+  AFFECTS: users of databases/mariadb55*
+  AUTHOR: grembo@FreeBSD.org
+
+  The mariadb55-client and mariadb55-server port have been changed to
+  respect hier(7) and behave like the mysql ports. Therefore mysql-server
+  and mysql monitor will refuse to start if my.cnf exists in /etc or
+  /etc/mysql.
+
+  In case you're affected, please move /etc/my.cnf to /usr/local/etc and/or
+  /etc/mysql/my.cnf to /usr/local/etc/mysql.
+
 20140520:
   AFFECTS: users of security/dropbear
   AUTHOR: ak@FreeBSD.org

Modified: head/databases/mariadb55-client/Makefile
==============================================================================
--- head/databases/mariadb55-client/Makefile	Wed May 21 10:32:46 2014	(r354739)
+++ head/databases/mariadb55-client/Makefile	Wed May 21 10:37:51 2014	(r354740)
@@ -1,14 +1,14 @@
 # $FreeBSD$
 
 PORTNAME=	mariadb
-PORTREVISION=	0
+PORTREVISION=	1
 PKGNAMESUFFIX=	55-client
 
 COMMENT=	Multithreaded SQL database (client)
 
 MASTERDIR=	${.CURDIR}/../mariadb55-server
 
-PKGMESSAGE=	mustnotexist
+FILESDIR=	${.CURDIR}/files
 PATCHDIR=	${.CURDIR}/files
 PLIST=		${.CURDIR}/pkg-plist
 

Modified: head/databases/mariadb55-client/files/patch-mysys_default.c
==============================================================================
--- head/databases/mariadb55-client/files/patch-mysys_default.c	Wed May 21 10:32:46 2014	(r354739)
+++ head/databases/mariadb55-client/files/patch-mysys_default.c	Wed May 21 10:37:51 2014	(r354740)
@@ -1,5 +1,5 @@
---- mysys/default.c.orig	2012-12-17 03:57:40.000000000 +0200
-+++ mysys/default.c	2012-12-17 04:00:28.000000000 +0200
+--- mysys/default.c.orig	2013-10-01 21:15:03.544135869 +0200
++++ mysys/default.c	2013-10-01 21:15:38.871375504 +0200
 @@ -89,7 +89,7 @@
  
  /* Which directories are searched for options (and in which order) */
@@ -18,11 +18,41 @@
      /*
        Ignore world-writable regular files.
        This is mainly done to protect us to not read a file created by
-@@ -1229,6 +1229,7 @@
- #if defined(DEFAULT_SYSCONFDIR)
-   if (DEFAULT_SYSCONFDIR[0])
-     errors += add_directory(alloc, DEFAULT_SYSCONFDIR, dirs);
-+    errors += add_directory(alloc, DEFAULT_SYSCONFDIR "/mysql", dirs);
- #endif /* DEFAULT_SYSCONFDIR */
+@@ -803,6 +803,14 @@
+   if (!(fp= mysql_file_fopen(key_file_cnf, name, O_RDONLY, MYF(0))))
+     return 1;					/* Ignore wrong files */
+ 
++  if (strstr(name, "/etc") == name)
++  {
++    fprintf(stderr,
++	      "error: Config file %s in invalid location, please move to or merge with %%PREFIX%%%s\n",
++	      name,name);
++      goto err;
++  }
++
+   while (mysql_file_fgets(buff, sizeof(buff) - 1, fp))
+   {
+     line++;
+@@ -1067,7 +1067,8 @@
+           if (name[0] == FN_HOMELIB)	/* Add . to filenames in home */
+             *end++= '.';
+           strxmov(end, conf_file, *ext, " ", NullS);
+-          fputs(name, stdout);
++          if (strstr(name, "/etc") != name)
++            fputs(name, stdout);
+         }
+       }
+     }
+@@ -1226,10 +1226,8 @@
+   errors += add_directory(alloc, "/etc/", dirs);
+   errors += add_directory(alloc, "/etc/mysql/", dirs);
+ 
+-#if defined(DEFAULT_SYSCONFDIR)
+-  if (DEFAULT_SYSCONFDIR[0])
+-    errors += add_directory(alloc, DEFAULT_SYSCONFDIR, dirs);
+-#endif /* DEFAULT_SYSCONFDIR */
++  errors += add_directory(alloc, "%%PREFIX%%/etc/", dirs);
++  errors += add_directory(alloc, "%%PREFIX%%/etc/mysql/", dirs);
  
  #endif
+ 

Added: head/databases/mariadb55-client/files/pkg-message.in
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/mariadb55-client/files/pkg-message.in	Wed May 21 10:37:51 2014	(r354740)
@@ -0,0 +1,7 @@
+************************************************************************
+
+MariaDB respects hier(7) and doesn't check /etc and /etc/mysql for
+my.cnf. Please move existing my.cnf files from those paths to
+%%PREFIX%%/etc and %%PREFIX%%/etc/mysql.
+
+************************************************************************

Modified: head/databases/mariadb55-server/Makefile
==============================================================================
--- head/databases/mariadb55-server/Makefile	Wed May 21 10:32:46 2014	(r354739)
+++ head/databases/mariadb55-server/Makefile	Wed May 21 10:37:51 2014	(r354740)
@@ -2,7 +2,7 @@
 
 PORTNAME?=	mariadb
 PORTVERSION=	5.5.35
-PORTREVISION?=	0
+PORTREVISION?=	1
 CATEGORIES=	databases ipv6
 MASTER_SITES=	http://ftp.osuosl.org/pub/mariadb/${PORTNAME}-${PORTVERSION}/kvm-tarbake-jaunty-x86/ \
 		http://mirrors.supportex.net/mariadb/${PORTNAME}-${PORTVERSION}/kvm-tarbake-jaunty-x86/ \
@@ -18,6 +18,9 @@ PKGNAMESUFFIX?=	55-server
 MAINTAINER=	never@nevermind.kiev.ua
 COMMENT?=	Multithreaded SQL database (server)
 
+SUB_FILES=	pkg-message
+PKGMESSAGE=	${WRKDIR}/pkg-message
+
 SLAVEDIRS=	databases/mariadb55-client
 USES=		cmake gmake
 NO_OPTIONS_SORT=yes
@@ -133,6 +136,7 @@ EXTRA_PATCHES+=	${FILESDIR}/extra-patch-
 
 post-patch:
 	@${REINPLACE_CMD} 's/*.1/${MAN1}/' ${WRKSRC}/man/CMakeLists.txt
+	@${REINPLACE_CMD} 's|%%PREFIX%%|${PREFIX}|g' ${WRKSRC}/mysys/default.c
 	@${REINPLACE_CMD} 's|%%LOCALBASE%%|${LOCALBASE}|g' ${WRKSRC}/scripts/mysql_config.sh
 
 .include <bsd.port.pre.mk>

Modified: head/databases/mariadb55-server/files/mysql-server.in
==============================================================================
--- head/databases/mariadb55-server/files/mysql-server.in	Wed May 21 10:32:46 2014	(r354739)
+++ head/databases/mariadb55-server/files/mysql-server.in	Wed May 21 10:37:51 2014	(r354740)
@@ -52,6 +52,13 @@ mysql_create_auth_tables()
 
 mysql_prestart()
 {
+	local dir
+	for dir in /etc /etc/mysql; do
+		if [ -f "${dir}/my.cnf" ]; then
+			echo "Please move existing my.cnf file from ${dir} to %%PREFIX%%${dir}"
+			return 1
+		fi
+	done
 	if [ ! -d "${mysql_dbdir}/mysql/." ]; then
 		mysql_create_auth_tables || return 1
 	fi

Modified: head/databases/mariadb55-server/files/patch-mysys_default.c
==============================================================================
--- head/databases/mariadb55-server/files/patch-mysys_default.c	Wed May 21 10:32:46 2014	(r354739)
+++ head/databases/mariadb55-server/files/patch-mysys_default.c	Wed May 21 10:37:51 2014	(r354740)
@@ -1,6 +1,6 @@
---- mysys/default.c.orig	2010-11-02 23:01:13.000000000 +0100
-+++ mysys/default.c	2010-11-10 16:39:51.000000000 +0100
-@@ -70,7 +70,7 @@
+--- mysys/default.c.orig	2013-10-01 21:15:03.544135869 +0200
++++ mysys/default.c	2013-10-01 21:15:38.871375504 +0200
+@@ -89,7 +89,7 @@
  
  /* Which directories are searched for options (and in which order) */
  
@@ -9,7 +9,7 @@
  #define DEFAULT_DIRS_SIZE (MAX_DEFAULT_DIRS + 1)  /* Terminate with NULL */
  static const char **default_directories = NULL;
  
-@@ -711,7 +711,7 @@
+@@ -785,7 +785,7 @@
    {
      MY_STAT stat_info;
      if (!my_stat(name,&stat_info,MYF(0)))
@@ -18,14 +18,41 @@
      /*
        Ignore world-writable regular files.
        This is mainly done to protect us to not read a file created by
-@@ -1153,7 +1153,10 @@
+@@ -803,6 +803,14 @@
+   if (!(fp= mysql_file_fopen(key_file_cnf, name, O_RDONLY, MYF(0))))
+     return 1;					/* Ignore wrong files */
  
- #if defined(DEFAULT_SYSCONFDIR)
-   if (DEFAULT_SYSCONFDIR[0])
++  if (strstr(name, "/etc") == name)
 +  {
-     errors += add_directory(alloc, DEFAULT_SYSCONFDIR, dirs);
-+    errors += add_directory(alloc, DEFAULT_SYSCONFDIR "/mysql", dirs);
++    fprintf(stderr,
++	      "error: Config file %s in invalid location, please move to or merge with %%PREFIX%%%s\n",
++	      name,name);
++      goto err;
 +  }
- #endif /* DEFAULT_SYSCONFDIR */
++
+   while (mysql_file_fgets(buff, sizeof(buff) - 1, fp))
+   {
+     line++;
+@@ -1067,7 +1067,8 @@
+           if (name[0] == FN_HOMELIB)	/* Add . to filenames in home */
+             *end++= '.';
+           strxmov(end, conf_file, *ext, " ", NullS);
+-          fputs(name, stdout);
++          if (strstr(name, "/etc") != name)
++            fputs(name, stdout);
+         }
+       }
+     }
+@@ -1226,10 +1226,8 @@
+   errors += add_directory(alloc, "/etc/", dirs);
+   errors += add_directory(alloc, "/etc/mysql/", dirs);
+ 
+-#if defined(DEFAULT_SYSCONFDIR)
+-  if (DEFAULT_SYSCONFDIR[0])
+-    errors += add_directory(alloc, DEFAULT_SYSCONFDIR, dirs);
+-#endif /* DEFAULT_SYSCONFDIR */
++  errors += add_directory(alloc, "%%PREFIX%%/etc/", dirs);
++  errors += add_directory(alloc, "%%PREFIX%%/etc/mysql/", dirs);
  
  #endif
+ 

Added: head/databases/mariadb55-server/files/pkg-message.in
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/databases/mariadb55-server/files/pkg-message.in	Wed May 21 10:37:51 2014	(r354740)
@@ -0,0 +1,11 @@
+************************************************************************
+
+Remember to run mysql_upgrade (with the optional --datadir=<dbdir> flag)
+the first time you start the MySQL server after an upgrade from an
+earlier version.
+
+MariaDB respects hier(7) and doesn't check /etc and /etc/mysql for
+my.cnf. Please move existing my.cnf files from those paths to
+%%PREFIX%%/etc and %%PREFIX%%/etc/mysql.
+
+************************************************************************
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 23 Michael Gmelin freebsd_committer 2014-05-21 11:43:53 UTC
State Changed
From-To: feedback->closed

Committed.