Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 878951 - dev-db/mysql-8.0.31: build fails if portage user cannot access mysqld's tempdir
Summary: dev-db/mysql-8.0.31: build fails if portage user cannot access mysqld's tempdir
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Linux MySQL bugs team
URL: https://bugs.mysql.com/bug.php?id=108947
Whiteboard:
Keywords: PullRequest
Depends on:
Blocks: 878907 878909
  Show dependency tree
 
Reported: 2022-11-01 04:41 UTC by Hank Leininger
Modified: 2022-11-03 06:53 UTC (History)
1 user (show)

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 Hank Leininger 2022-11-01 04:41:43 UTC
I created an upstream bug also, https://bugs.mysql.com/bug.php?id=108947

If a host has mysql configured to use a tmpdir that only the mysql user can access, then compiling mysql will fail towards the very end:

[100%] Generating Docs/INFO_BIN
/usr/bin/cmake -DMYSQLD_EXECUTABLE=/var/tmp/portage/dev-db/mysql-8.0.31/work/mysql_build/runtime_output_directory/mysqld -DCMAKE_BUILD_TYPE=RelWithDebInfo -P /var/tmp/portage/dev-db/mysql-8.0.31/work/mysql/cmake/info_bin.cmake
CMake Error at info_macros.cmake:185 (MESSAGE):
  mysqld --help failed: mysqld: Can't get stat of '/usr/local/mysql-data/tmp'
  (OS errno 13 - Permission denied)

  2022-11-01T03:14:41.014206Z 0 [ERROR] [MY-010119] [Server] Aborting

Call Stack (most recent call first):
  /var/tmp/portage/dev-db/mysql-8.0.31/work/mysql/cmake/info_bin.cmake:36 (CREATE_INFO_BIN)


make[2]: *** [CMakeFiles/INFO_BIN.dir/build.make:71: CMakeFiles/INFO_BIN] Error 1
make[2]: Leaving directory '/var/tmp/portage/dev-db/mysql-8.0.31/work/mysql_build'
make[1]: *** [CMakeFiles/Makefile2:2735: CMakeFiles/INFO_BIN.dir/all] Error 2
make[1]: Leaving directory '/var/tmp/portage/dev-db/mysql-8.0.31/work/mysql_build'
make: *** [Makefile:156: all] Error 2

Here info_bin.cmake is calling CREATE_INFO_BIN defined in cmake/info_macros.cmake.in

In my case, mysql's tmpdir = /usr/local/mysql-data/tmp, which is mysql-only, inaccessible to user portage:

# namei -l /usr/local/mysql-data/tmp
f: /usr/local/mysql-data/tmp
drwxr-xr-x root  root  /
drwxr-xr-x root  root  usr
drwxr-xr-x root  root  local
drwxrwx--T root  mysql mysql-data
drwxr-xr-x mysql mysql tmp

This was never a problem until recently; between 8.0.27 and 8.0.31 this was added:

$ diff -u \
  /var/tmp/portage/dev-db/mysql-8.0.27/work/mysql/cmake/info_macros.cmake.in \
  /var/tmp/portage/dev-db/mysql-8.0.31/work/mysql/cmake/info_macros.cmake.in
...
+  IF(HAVE_BUILD_ID_SUPPORT AND NOT WITHOUT_SERVER)
+    FILE(APPEND ${INFO_BIN} "\n===== BUILD ID =====\n")
+    EXECUTE_PROCESS(COMMAND
+      ${MYSQLD_EXECUTABLE} --help
+      OUTPUT_VARIABLE mysqld_help
...

This will call the just-built mysqld binary, but it reads in configs from the real /etc/mysql/ if present, causing an error.

It seems that adding --no-defaults to that mysqld invocation avoids the problem of user portage trying to follow paths only user mysql can access, but still includes the BuildID in the output that the recipe wants.

Fix:

--- a/cmake/info_macros.cmake.in        2022-09-13 12:15:16.000000000 -0400
+++ b/cmake/info_macros.cmake.in        2022-11-01 00:12:06.270464679 -0400
@@ -175,7 +175,7 @@
   IF(HAVE_BUILD_ID_SUPPORT AND NOT WITHOUT_SERVER)
     FILE(APPEND ${INFO_BIN} "\n===== BUILD ID =====\n")
     EXECUTE_PROCESS(COMMAND
-      ${MYSQLD_EXECUTABLE} --help
+      ${MYSQLD_EXECUTABLE} --no-defaults --help
       OUTPUT_VARIABLE mysqld_help
       RESULT_VARIABLE mysqld_help_result
       ERROR_VARIABLE mysqld_help_error
Comment 1 Hank Leininger 2022-11-01 17:09:03 UTC
Upstream has declared unsupported/WONTFIX, they require that the building user have access to any production mysql instance's tmpdir.

PR incoming...
Comment 2 Larry the Git Cow gentoo-dev 2022-11-01 23:21:54 UTC
The bug has been closed via the following commit(s):

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

commit b0d5d24230e62e69f4bae50be4746551f1d95451
Author:     Hank Leininger <hlein@korelogic.com>
AuthorDate: 2022-11-01 17:34:22 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2022-11-01 23:21:41 +0000

    dev-db/mysql: fix compilation when tmpdir not accessible by portage
    
    Upstream has declared WONTFIX; gentoo is not supported, and neither
    is compiling as a user who cannot read mysql-only directories:
    https://bugs.mysql.com/bug.php?id=108947
    
    Closes: https://bugs.gentoo.org/878951
    Closes: https://github.com/gentoo/gentoo/pull/28085
    Signed-off-by: Hank Leininger <hlein@korelogic.com>
    Signed-off-by: Sam James <sam@gentoo.org>

 .../mysql-8.0.31-build-tmpdir-nodefault.patch      |   12 +
 dev-db/mysql/mysql-8.0.31-r1.ebuild                | 1224 ++++++++++++++++++++
 2 files changed, 1236 insertions(+)