Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 693000 - dev-db/mysql-init-scripts: fails to set correct permissions on /var/run/mysqld
Summary: dev-db/mysql-init-scripts: fails to set correct permissions on /var/run/mysqld
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-08-28 09:29 UTC by pva
Modified: 2019-08-28 14:43 UTC (History)
1 user (show)

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


Attachments
emerge --info dev-db/mariadb (mariadb--emerge-info.txt,5.24 KB, text/plain)
2019-08-28 09:29 UTC, pva
Details
output of rm /run/mysql && emerge mysq-init-scripts (mysql-init-scripts-out.txt,2.39 KB, text/plain)
2019-08-28 10:29 UTC, pva
Details

Note You need to log in before you can comment on or make changes to this bug.
Description pva 2019-08-28 09:29:30 UTC
Created attachment 588410 [details]
emerge --info dev-db/mariadb

After `emerge dev-db/mariadb` if fails to run `emerge dev-db/mariadb config` with an error:


===== Error output =====
test ~ # emerge --config =dev-db/mariadb-10.2.22-r1


Configuring pkg...

 * Trying to get password for mysql 'root' user from 'mysql' section ...
 * Trying to get password for mysql 'root' user from 'client' section ...
 * Please provide a password for the mysql 'root' user now
 * or through the /root/.my.cnf file.
 * Avoid ["'\_%] characters in the password
    >
 * Retype the password
    >
 * Creating the mysql database and setting proper permissions on it ...
 * Command: /usr/share/mariadb/scripts/mysql_install_db --basedir=/usr --loose-skip-grant-tables --loose-skip-host-cache --loose-skip-name-resolve --loose-skip-networking --loose-skip-slave-start --loose-skip-ssl --loose-skip-log-bin --loose-skip-relay-log --loose-skip-slow-query-log --loose-skip-external-locking --loose-skip-log-slave-updates --datadir=///var/lib/mysql --tmpdir=///tmp/
 * Starting mysqld ...
 * Command //usr/sbin/mysqld 		 --loose-skip-grant-tables --loose-skip-host-cache --loose-skip-name-resolve --loose-skip-networking --loose-skip-slave-start --loose-skip-ssl --loose-skip-log-bin --loose-skip-relay-log --loose-skip-slow-query-log --loose-skip-external-locking --loose-skip-log-slave-updates --user=mysql 		--log-warnings=0 		--basedir=//usr 		--datadir=///var/lib/mysql 		--max_allowed_packet=8M 	--net_buffer_length=16K 		--socket=//var/run/mysqld/mysqld6711.sock 		--pid-file=//var/run/mysqld/mysqld10951.pid 		--tmpdir=///tmp/
.2019-08-27 23:37:22 137076643276608 [Note] //usr/sbin/mysqld (mysqld 10.2.22-MariaDB) starting as process 16409 ...                                                                                                                            [ ok ]........
 * ERROR: dev-db/mariadb-10.2.22-r1::gentoo failed (config phase):
 *   Completely failed to start up mysqld with: //usr/sbin/mysqld 		 --loose-skip-grant-tables --loose-skip-host-cache --loose-skip-name-resolve --loose-skip-networking --loose-skip-slave-start --loose-skip-ssl --loose-skip-log-bin --loose-skip-relay-log --loose-skip-slow-query-log --loose-skip-external-locking --loose-skip-log-slave-updates --user=mysql 		--log-warnings=0 		--basedir=//usr 		--datadir=///var/lib/mysql 	--max_allowed_packet=8M 		--net_buffer_length=16K 		--socket=//var/run/mysqld/mysqld6711.sock 		--pid-file=//var/run/mysqld/mysqld10951.pid 		--tmpdir=///tmp/
 *
 * Call stack:
 *     ebuild.sh, line 125:  Called pkg_config
 *   environment, line 5280:  Called die
 * The specific snippet of code:
 *           die "Completely failed to start up mysqld with: ${mysqld}";
 *
 * If you need support, post the output of `emerge --info '=dev-db/mariadb-10.2.22-r1::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=dev-db/mariadb-10.2.22-r1::gentoo'`.
!!! When you file a bug report, please include the following information:
GENTOO_VM=  CLASSPATH="" JAVA_HOME=""
JAVACFLAGS="" COMPILER=""
and of course, the output of emerge --info =mariadb-10.2.22
 * The complete build log is located at '/var/tmp/portage/dev-db/mariadb-10.2.22-r1/temp/build.log.gz'.
 * The ebuild environment file is located at '/var/tmp/portage/dev-db/mariadb-10.2.22-r1/temp/environment'.
 * Working directory: '/var/tmp/portage/dev-db/mariadb-10.2.22-r1/homedir'
 * S: '/var/tmp/portage/dev-db/mariadb-10.2.22-r1/work/mariadb-10.2.22'

========================

The problem is with owner of /var/run/mysqld:
drwxr-xr-x 2 root root 40 Aug 28 07:06 /var/run/mysqld

This dirrectory was created by dev-db/mysql-init-scripts ebuild which runs in pkg_postinst():
   tmpfiles_process mysql.conf

And this is where owner is supposed to be set. Unfortunatle on new system there is no mysql user/group and thus setting owner fails:

>>> Merging dev-db/mysql-init-scripts-2.3 to /
[...skipping files installation...]
>>> /usr/libexec/mysqld-wait-ready
chown: invalid user: «mysql»
chgrp: invalid group: «mysql»
[...skip einfo output...]
>>> dev-db/mysql-init-scripts-2.3 merged.

To fix we need pkg_setup() in mysql-init-scripts ebuild:

pkg_setup() {
    enewgroup mysql 60 || die "problem adding 'mysql' group"
    enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
}
Comment 1 pva 2019-08-28 09:31:01 UTC
I've tested stable branch:
=dev-db/mariadb-10.2.22-r1
=dev-db/mysql-init-scripts-2.3
but after reading ebuild I thinks this error exists in ~arch too.
Comment 2 pva 2019-08-28 09:35:00 UTC
BTW, may be we should not create directories in /var/run/ in ebuild at all... Why mysql-init-scripts does this?
Comment 3 Thomas Deutschmann (RETIRED) gentoo-dev 2019-08-28 10:01:54 UTC
Your conclusion is invalid: Yes, we are using tmpfiles service which is supported in systemd *and* OpenRC world to manage /run/mysqld directory. But this will only work if the directory doesn't exist yet.

So it looks like /run/mysqld already existed with invalid permissions. In this case we are not going to do anything because we assume "you" know better...

In >=dev-db/mysql-8 we added a permission check to show a better error message to allow user to understand why --config failed: https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-db/mysql/mysql-8.0.17.ebuild?id=7d192490e75a8b42632128c1c7a6b0c918331f52#n684 Maybe we will backport this to mariadb, too. But we will never fix permissions for user because we can't know why something is set this way and if it's desired to change...
Comment 4 pva 2019-08-28 10:29:17 UTC
Well, take a look yourself:
1. I'm removing /var/run/mysqld
2. I run emerge dev-db/mysql-init-scripts
3. Dirrectory is in place with wrong owner.

b612-dev3-stage4 ~ # rm -rf /var/run/mysqld/
b612-dev3-stage4 ~ # emerge dev-db/mysql-init-scripts
...
>>> Installing (1 of 1) dev-db/mysql-init-scripts-2.3::gentoo
chown: неверный пользователь: «mysql»
chgrp: неверная группа: «mysql»
...

b612-dev3-stage4 ~ # ls -dla /var/run/mysqld
drwxr-xr-x 2 root root 40 авг 28 10:26 /var/run/mysqld

I'll attach full output.
Comment 5 pva 2019-08-28 10:29:56 UTC
Created attachment 588412 [details]
output of rm /run/mysql && emerge mysq-init-scripts
Comment 6 Thomas Deutschmann (RETIRED) gentoo-dev 2019-08-28 10:32:46 UTC
I cannot tell you why you are seeing this, but this is not normal. So you are doing something wrong or have something special, see:

> (chroot) dev1 / # ls -lv /run/
> total 0
> 
> (chroot) dev1 / # emerge -a1 --usepkg=n --nodeps '=dev-db/mysql-init-scripts-2.3'
> 
> These are the packages that would be merged, in order:
> 
> [ebuild  N     ] dev-db/mysql-init-scripts-2.3::gentoo  0 KiB
> 
> Total: 1 package (1 new), Size of downloads: 0 KiB
> 
> Would you like to merge these packages? [Yes/No] y
> 
> >>> Verifying ebuild manifests
> 
> >>> Emerging (1 of 1) dev-db/mysql-init-scripts-2.3::gentoo
> >>> Unpacking source...
> >>> Source unpacked in /var/tmp/portage/dev-db/mysql-init-scripts-2.3/work
> >>> Preparing source in /var/tmp/portage/dev-db/mysql-init-scripts-2.3/work ...
> >>> Source prepared.
> >>> Configuring source in /var/tmp/portage/dev-db/mysql-init-scripts-2.3/work ...
> >>> Source configured.
> >>> Compiling source in /var/tmp/portage/dev-db/mysql-init-scripts-2.3/work ...
> >>> Source compiled.
> >>> Test phase [not enabled]: dev-db/mysql-init-scripts-2.3
> 
> >>> Install dev-db/mysql-init-scripts-2.3 into /var/tmp/portage/dev-db/mysql-init-scripts-2.3/image/
> >>> Completed installing dev-db/mysql-init-scripts-2.3 into /var/tmp/portage/dev-db/mysql-init-scripts-2.3/image/
> 
>  * Final size of build directory:  0 KiB
>  * Final size of installed tree:  60 KiB
> 
> ./
> ./etc/
> ./etc/conf.d/
> ./etc/conf.d/mysql
> ./etc/conf.d/mysql-s6
> ./etc/init.d/
> ./etc/init.d/mysql-s6
> ./etc/init.d/mysql
> ./etc/init.d/mysql-supervise
> ./etc/logrotate.d/
> ./etc/logrotate.d/mysql
> ./var/
> ./var/svc.d/
> ./var/svc.d/mysql/
> ./var/svc.d/mysql/run
> ./var/svc.d/mysql/log/
> ./var/svc.d/mysql/log/run
> ./usr/
> ./usr/libexec/
> ./usr/libexec/mysqld-wait-ready
> ./usr/lib/
> ./usr/lib/tmpfiles.d/
> ./usr/lib/tmpfiles.d/mysql.conf
> ./lib/
> ./lib/systemd/
> ./lib/systemd/system/
> ./lib/systemd/system/mysqld.service
> ./lib/systemd/system/mysqld@.service
> >>> Done.
> 
> >>> Installing (1 of 1) dev-db/mysql-init-scripts-2.3::gentoo
>  * checking 12 files for package collisions
> >>> Merging dev-db/mysql-init-scripts-2.3 to /
> --- /lib/
> --- /lib/systemd/
> --- /lib/systemd/system/
> >>> /lib/systemd/system/mysqld@.service
> >>> /lib/systemd/system/mysqld.service
> --- /usr/
> --- /usr/lib/
> --- /usr/lib/tmpfiles.d/
> >>> /usr/lib/tmpfiles.d/mysql.conf
> --- /usr/libexec/
> >>> /usr/libexec/mysqld-wait-ready
> --- /var/
> >>> /var/svc.d/
> >>> /var/svc.d/mysql/
> >>> /var/svc.d/mysql/log/
> >>> /var/svc.d/mysql/log/run
> >>> /var/svc.d/mysql/run
> --- /etc/
> --- /etc/logrotate.d/
> >>> /etc/logrotate.d/mysql
> --- /etc/init.d/
> >>> /etc/init.d/mysql-supervise
> >>> /etc/init.d/mysql
> >>> /etc/init.d/mysql-s6
> --- /etc/conf.d/
> >>> /etc/conf.d/mysql-s6
> >>> /etc/conf.d/mysql
>  *
>  * To use the mysql-s6 script, you need to install the optional sys-apps/s6 package.
>  * If you wish to use s6 logging support, comment out the log-error setting in your my.cnf
>  *
>  * Starting with version 10.1.8, MariaDB includes an improved systemd unit named mariadb.service
>  * You should prefer that unit over this package's mysqld.service.
>  *
> >>> dev-db/mysql-init-scripts-2.3 merged.
> >>> Regenerating /etc/ld.so.cache...
> 
>  * Messages for package dev-db/mysql-init-scripts-2.3:
> 
>  *
>  * To use the mysql-s6 script, you need to install the optional sys-apps/s6 package.
>  * If you wish to use s6 logging support, comment out the log-error setting in your my.cnf
>  *
>  * Starting with version 10.1.8, MariaDB includes an improved systemd unit named mariadb.service
>  * You should prefer that unit over this package's mysqld.service.
> >>> Auto-cleaning packages...
> 
> >>> No outdated packages were found on your system.
> 
>  * GNU info directory index is up-to-date.
> (chroot) dev1 / # ls -lv /run
> total 0
> drwxr-xr-x 2 mysql mysql 6 Aug 28 12:23 mysqld
Comment 7 pva 2019-08-28 11:24:48 UTC
(In reply to Thomas Deutschmann from comment #6)
> I cannot tell you why you are seeing this, but this is not normal. So you
> are doing something wrong or have something special, see:
> 
> > (chroot) dev1 / # ls -lv /run
...
> > (chroot) dev1 / # ls -lv /run
> > total 0
> > drwxr-xr-x 2 mysql mysql 6 Aug 28 12:23 mysqld

Could you, please, remove mysql user/group from the system. I'm sure this will help to reproduce this problem.

Plase, note, that mysql-init-scripts are merged before mariadb, where this user/group is used.
Comment 8 Thomas Deutschmann (RETIRED) gentoo-dev 2019-08-28 11:26:06 UTC
The problem is that dev-db/mysql-init-scripts uses mysql user/group but doesn't depend on acct-{user,group}/mysql.
Comment 9 Larry the Git Cow gentoo-dev 2019-08-28 11:38:21 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5c61d964bfc659eb2a8474552853311a2b1d8503

commit 5c61d964bfc659eb2a8474552853311a2b1d8503
Author:     Thomas Deutschmann <whissi@gentoo.org>
AuthorDate: 2019-08-28 11:34:23 +0000
Commit:     Thomas Deutschmann <whissi@gentoo.org>
CommitDate: 2019-08-28 11:38:14 +0000

    dev-db/mysql-init-scripts: package requires acct-{user,group}/mysql
    
    ...already in pkg_post* phase.
    
    Bug: https://bugs.gentoo.org/693000
    Package-Manager: Portage-2.3.72, Repoman-2.3.17
    Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>

 .../mysql-init-scripts-2.3-r2.ebuild               | 71 ++++++++++++++++++++++
 1 file changed, 71 insertions(+)
Comment 10 Tomáš Mózes 2019-08-28 12:25:11 UTC
I saw this too and it wasn't immediatelly visible what's wrong.
Comment 11 Larry the Git Cow gentoo-dev 2019-08-28 14:43:31 UTC
The bug has been closed via the following commit(s):

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

commit cda4995e825424bf017dc4a76e249d0531f841d4
Author:     Thomas Deutschmann <whissi@gentoo.org>
AuthorDate: 2019-08-28 14:17:49 +0000
Commit:     Thomas Deutschmann <whissi@gentoo.org>
CommitDate: 2019-08-28 14:43:21 +0000

    dev-db/mysql-init-scripts: rev bump
    
    - Move acct-* dependencies to RDEPEND to support binary packages.
      Note: According to devmanual there will be a problem once emerge
            will merge RDEPEND after the actual package.
    
    - Handle the case when option is defined multiple times.
    
    Closes: https://bugs.gentoo.org/693000
    Closes: https://bugs.gentoo.org/686378
    Package-Manager: Portage-2.3.72, Repoman-2.3.17
    Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>

 .../mysql-init-scripts/files/logrotate.mysql-2.3   |  5 +-
 .../mysql-init-scripts-2.3-r3.ebuild               | 70 ++++++++++++++++++++++
 2 files changed, 74 insertions(+), 1 deletion(-)