Skip to content

fix(roles/mariadb_server): mariadbd drops out of mysqld_t on upgrade - #327

Merged
NavidSassan merged 4 commits into
mainfrom
fix/mariadb-server-selinux-mysqld-exec-label
Aug 26, 2026
Merged

fix(roles/mariadb_server): mariadbd drops out of mysqld_t on upgrade#327
NavidSassan merged 4 commits into
mainfrom
fix/mariadb-server-selinux-mysqld-exec-label

Conversation

@bhatti-lf

Copy link
Copy Markdown
Contributor

Every MariaDB package upgrade resets /usr/sbin/mariadbd to bin_t, because the
MariaDB repo packages ship no file contexts for that binary name (MDEV-30520).

That stayed invisible until MariaDB 11.4.13 / 11.8.9 moved the galera recovery into
ExecStart (MDEV-40629): systemd now execs /bin/sh and lands in initrc_t instead
of the unconfined unconfined_service_t, and httpd_t is denied connectto on the
MariaDB socket. Applications then return 500 with
SQLSTATE[HY000] [2002] Permission denied.

To fix this: Install mysql-selinux, which ships the contexts for all mariadbd binary names.
The semanage fcontext /usr/bin/mariadbd only works on EL10, not on EL8 and EL9.
Also drops the drop-in's ExecStartPre chcon, which could never work because of
ProtectSystem=full.

@markuslf

Copy link
Copy Markdown
Member

Urgent.

Comment thread roles/mariadb_server/tasks/main.yml Outdated
Comment thread roles/mariadb_server/tasks/main.yml Outdated
Comment thread roles/mariadb_server/tasks/main.yml Outdated
Comment thread extensions/molecule/setup_nextcloud/verify.yml
bhatti-lf and others added 3 commits August 26, 2026 15:08
The comment claimed the exclusion keeps Galera nodes out of mysqld_t. It
only does so on EL8. On EL9 and EL10 MariaDB-server declares
(mysql-selinux >= 1.0.14 if selinux-policy-targeted), so the policy is
installed and rpm labels the binary regardless of this role, and Galera
nodes run confined either way. Measured on a Rocky 9 node where both
SELinux tasks were skipped: mariadbd still ran in mysqld_t.

Also name the actual failure behind Errcode: 13, which is the donor's
mariabackup failing to reach the local socket during SST, and point at
#328, where the Galera breakage is tracked.

The socket drop-in gains the same treatment: once mariadbd runs in
mysqld_t the base policy labels the socket through a type_transition, so
the ExecStartPost only matters on hosts where it does not, which the
comment now says instead of implying the chcon is always needed.

verify.yml: ps exits 1 when no process matches, so the label check failed
with a bare rc=1 instead of the fail_msg. Split into a "is it running"
assert and the domain assert.
@NavidSassan
NavidSassan merged commit 622bfe8 into main Aug 26, 2026
12 checks passed
@NavidSassan
NavidSassan deleted the fix/mariadb-server-selinux-mysqld-exec-label branch August 26, 2026 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants