Extend tmpfiles.d rules for ImageMode

After switching to a container image with bootc switch, systemd failed to start
mysqld because required runtime directories were missing or had wrong permissions.

Adding tmpfiles entries with correct ownership ensures systemd creates the
necessary directories at boot and gives them correct permissions, allowing the
mysql daemon to start.

"In a container build, you can write to '/var'. However, this will have a semantic
similar to a Dockerfile VOLUME instruction; the content from the container image
is only copied at initial install time. Any subsequent system updates will not
by default see new changes.

It's recommended instead to use e.g. systemd tmpfiles.d as a way to ensure that
newly added state "reconciles" across upgrades as desired."

https://docs.fedoraproject.org/en-US/bootc/filesystem/#_filesystem_bind_mount_var

This covers all the files in /var sicne we only ship these as can be seen here:
find | grep /var/
./mysql8.4-server-8.4.5-1.fc43.x86_64.rpm/var/lib
./mysql8.4-server-8.4.5-1.fc43.x86_64.rpm/var/lib/mysql
./mysql8.4-server-8.4.5-1.fc43.x86_64.rpm/var/lib/mysql-files
./mysql8.4-server-8.4.5-1.fc43.x86_64.rpm/var/lib/mysql-keyring
./mysql8.4-server-8.4.5-1.fc43.x86_64.rpm/var/log
./mysql8.4-server-8.4.5-1.fc43.x86_64.rpm/var/log/mysql

The '/usr' directory is not persistent therefore this change does not affect it
and the '/etc' directory is merged in a different way and also not under the
'mysql:mysql' user
This commit is contained in:
Nikola Davidova 2025-11-04 13:32:39 +00:00 committed by Pavol Sloboda
parent 2d6d1bf1c4
commit bdf88f920b
2 changed files with 11 additions and 0 deletions

View File

@ -1 +1,8 @@
d @PID_FILE_DIR@ 0755 mysql mysql -
Rules for ephemeral file systems (ImageMode)
/var/lib/mysql 0755 mysql mysql -
/var/log/mysql 0750 mysql mysql -
/var/log/mysql/mysql.log 0640 mysql mysql -
/var/lib/mysql-files 0750 mysql mysql -
/var/lib/mysql-keyring 0700 mysql mysql -

View File

@ -1000,11 +1000,15 @@ popd
%{_libexecdir}/mysql-scripts-common
%{_tmpfilesdir}/%{daemon_name}.conf
%{_sysusersdir}/%{name}.conf
# Remember to also update the mysql.tmpfiles.d.in file when updating these permissions
%attr(0755,mysql,mysql) %dir %{dbdatadir}
%attr(0750,mysql,mysql) %dir %{_localstatedir}/lib/mysql-files
%attr(0700,mysql,mysql) %dir %{_localstatedir}/lib/mysql-keyring
%attr(0755,mysql,mysql) %dir %{pidfiledir}
%attr(0750,mysql,mysql) %dir %{logfiledir}
%config(noreplace) %{logrotateddir}/%{daemon_name}
%if %{with devel}