Bug 18564 - koha-common.cnf parsing is too restrictive
Summary: koha-common.cnf parsing is too restrictive
Status: Pushed to Master
Alias: None
Product: Koha
Classification: Unclassified
Component: Installation and upgrade (command-line installer) (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Eric Vantillard
QA Contact: Marcel de Rooy
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-09 19:09 UTC by Eric Vantillard
Modified: 2017-10-20 20:15 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
patch changing the awk script (952 bytes, patch)
2017-05-17 15:18 UTC, Eric Vantillard
Details | Diff | Splinter Review
Bug 18564: MariaDB doesn't have a debian.cnf file (836 bytes, patch)
2017-06-22 22:49 UTC, M. Tompsett
Details | Diff | Splinter Review
Bug 18564: Improve koha-common.cnf parsing to pick the mysql host (1.25 KB, patch)
2017-09-26 17:41 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 18564: Improve koha-common.cnf parsing to pick the mysql host (1.34 KB, patch)
2017-10-20 09:49 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Vantillard 2017-05-09 19:09:18 UTC
my koha-common.cnf is using this form:

[client]
host=db
user=root
password="move_rootpwd_to_dotenv"

this file is working has expected with mysql tools.

but koha-create parsing will not find the db host resulting in koha-conf.xml containing no values in hostname element.

as a result trying to connect to the web serveur will raise an error :

Software error:

DBIx::Class::Storage::DBI::catch {...} (): DBI Connection failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1490. at /usr/share/koha/lib/Koha/Database.pm line 90
Compilation failed in require at /usr/share/koha/intranet/cgi-bin/mainpage.pl line 31.
BEGIN failed--compilation aborted at /usr/share/koha/intranet/cgi-bin/mainpage.pl line 31.
For help, please send mail to the webmaster ([no address given]), giving this error message and the time and date of the error.
Comment 1 Eric Vantillard 2017-05-09 19:20:05 UTC
adding spaces around the equal sign will resolve the issue

the problem is in kohl-create function getmysqlhost()

https://github.com/Koha-Community/Koha/blob/master/debian/scripts/koha-create#L124

the awk search require spaces
Comment 2 Eric Vantillard 2017-05-09 20:04:10 UTC
maybe something like that

awk '
BEGIN {
	FS="="
}
$1 ~/\[/ {
	inclient=0
}
$1 ~/\[client\]/ {
	inclient=1
	next
}
inclient==1 && $1 ~/host/ {
	print $2
}
' /etc/mysql/koha-common.cnf
Comment 3 Eric Vantillard 2017-05-17 15:18:42 UTC
Created attachment 63501 [details] [review]
patch changing the awk script
Comment 4 M. Tompsett 2017-06-22 22:32:31 UTC
Is this patch ready to sign off?
I have an amendment to make. :)
Comment 5 M. Tompsett 2017-06-22 22:49:14 UTC
Created attachment 64557 [details] [review]
Bug 18564: MariaDB doesn't have a debian.cnf file

The koha-common.cnf file is a link to debian.cnf, which MariaDB
does not install. This just forces a 'localhost' return value.
Comment 6 Jonathan Druart 2017-09-26 17:39:25 UTC
(In reply to M. Tompsett from comment #5)
> Created attachment 64557 [details] [review] [review]
> Bug 18564: MariaDB doesn't have a debian.cnf file
> 
> The koha-common.cnf file is a link to debian.cnf, which MariaDB
> does not install. This just forces a 'localhost' return value.

Please move it to its own bug report.
Comment 7 Jonathan Druart 2017-09-26 17:41:15 UTC
Created attachment 67371 [details] [review]
Bug 18564: Improve koha-common.cnf parsing to pick the mysql host

my koha-common.cnf is using this form:

[client]
host=db
user=root
password="move_rootpwd_to_dotenv"

this file is working has expected with mysql tools.

but koha-create parsing will not find the db host resulting in
koha-conf.xml containing no values in hostname element.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 8 Marcel de Rooy 2017-10-20 09:49:00 UTC
Created attachment 68315 [details] [review]
Bug 18564: Improve koha-common.cnf parsing to pick the mysql host

my koha-common.cnf is using this form:

[client]
host=db
user=root
password="move_rootpwd_to_dotenv"

this file is working has expected with mysql tools.

but koha-create parsing will not find the db host resulting in
koha-conf.xml containing no values in hostname element.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 9 Marcel de Rooy 2017-10-20 09:50:17 UTC
Thanks, Eric'.
Looks good to me, improving my awk skills on the way..
Comment 10 Jonathan Druart 2017-10-20 20:15:00 UTC
Patch pushed to master for 17.11.

Thanks and congrats Éric it is your first patch in!