Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 677396 - dev-db/mysql-init-scripts: init script can't parse "pid_file"
Summary: dev-db/mysql-init-scripts: init script can't parse "pid_file"
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Linux MySQL bugs team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-02-06 23:33 UTC by Michael Orlitzky
Modified: 2019-03-05 21:28 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Orlitzky gentoo-dev 2019-02-06 23:33:27 UTC
The init script tries to do,

  local pidfile=$(get_config "${MY_CNF}" pid-file | tail -n1)

which doesn't work if you set "pid_file" (with an underscore) in my.cnf. The version with the underscore is what appears in the MySQL/MariaDB online documentation.


Unrelated: if I were you, I would completely ignore the PID path from my.cnf. The PID file falls under the purview of the init system, who is in charge of setting up the correct permissions and everything else. If a user changes the path in my.cnf, he's going to get a bad surprise when you start calling "chown" on random directories on his system. Not that there's any reason to change it anyway. Force it via the command-line to go in "/run/${RC_SVCNAME}/${RC_SVCNAME}.pid" and be done with it =)
Comment 1 Brian Evans (RETIRED) gentoo-dev 2019-02-18 13:54:35 UTC
(In reply to Michael Orlitzky from comment #0)
> The init script tries to do,
> 
>   local pidfile=$(get_config "${MY_CNF}" pid-file | tail -n1)
> 
> which doesn't work if you set "pid_file" (with an underscore) in my.cnf. The
> version with the underscore is what appears in the MySQL/MariaDB online
> documentation.
> 

We provide a pid-file line in 50-distro-server.cnf which is meant to be included by the user.  They are notified about this integration in the elog.

What people have to understand is that underscores are "variables" and hyphens are "command options".  Yes I know it is confusing but both of these options are valid and we've been using pid-file for a long, long time now.

> 
> Unrelated: if I were you, I would completely ignore the PID path from
> my.cnf. The PID file falls under the purview of the init system, who is in
> charge of setting up the correct permissions and everything else. If a user
> changes the path in my.cnf, he's going to get a bad surprise when you start
> calling "chown" on random directories on his system. Not that there's any
> reason to change it anyway. Force it via the command-line to go in
> "/run/${RC_SVCNAME}/${RC_SVCNAME}.pid" and be done with it =)

As seen in bug 678272, we need a consistent resource in the configuration such that logrotate scripts work to HUP the server.

The only alternative to this is to radically change 'root'@'localhost' like other distros and eliminate password authentication and rely on UNIX user auth instead.
Comment 2 Michael Orlitzky gentoo-dev 2019-02-18 15:15:47 UTC
(In reply to Brian Evans from comment #1)
> 
> We provide a pid-file line in 50-distro-server.cnf which is meant to be
> included by the user.  They are notified about this integration in the elog.

Fair enough, I did indeed change the existing entry. But I did so based on the MariaDB docs, and to make it match the style of the other my.cnf parameters that I have set.


> > Not that there's any
> > reason to change it anyway. Force it via the command-line to go in
> > "/run/${RC_SVCNAME}/${RC_SVCNAME}.pid" and be done with it =)
> 
> As seen in bug 678272, we need a consistent resource in the configuration
> such that logrotate scripts work to HUP the server.
> 

That's... exactly why I'm suggesting that you hard-code the PID file path in the init script. If the user changes it in my.cnf, everything breaks anyway. You can pass --pid-file to the daemon so that the my.cnf value is ignored. That fixes,

  * this bug
  * bug 678272
  * the security bug that someone is going to file when he tries to relocate
    his pid file to /run and finds /run owned by "mysql"

and it simplifies the init script (because you no longer need to parse that value).
Comment 3 Larry the Git Cow gentoo-dev 2019-03-05 21:28:09 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=29f98d49b8679417fe873aefb9182a43f2bafca4

commit 29f98d49b8679417fe873aefb9182a43f2bafca4
Author:     Brian Evans <grknight@gentoo.org>
AuthorDate: 2019-03-05 21:27:48 +0000
Commit:     Brian Evans <grknight@gentoo.org>
CommitDate: 2019-03-05 21:27:48 +0000

    dev-db/mysql-init-scripts: Fix up pid file searching
    
    Changed how the pid file is searched for in both logrotate and init
    
    Closes: https://bugs.gentoo.org/677396
    Closes: https://bugs.gentoo.org/678272
    Package-Manager: Portage-2.3.62, Repoman-2.3.12
    Signed-off-by: Brian Evans <grknight@gentoo.org>

 dev-db/mysql-init-scripts/files/init.d-2.3         | 194 +++++++++++++++++++++
 dev-db/mysql-init-scripts/files/init.d-s6-2.3      | 163 +++++++++++++++++
 .../mysql-init-scripts/files/init.d-supervise-2.3  | 180 +++++++++++++++++++
 .../mysql-init-scripts/files/logrotate.mysql-2.3   |  14 ++
 .../mysql-init-scripts-2.3.ebuild                  |  67 +++++++
 5 files changed, 618 insertions(+)