#!/usr/bin/bash

# CVE-2026-107814: Warn if the mysql user's HOME directory is writable by
# the mysql user. An attacker with FILE privilege could plant a malicious
# .bashrc/.bash_profile there, which would execute if an admin ever runs
# 'su -s /bin/bash - mysql' or 'sudo -u mysql bash'.

if [ "$HOME" != "/" ] && [ "$HOME" != "/nonexistent" ] && [ "$HOME" != "/dev/null" ]
then
cat <<EOF >&2
Warning: Insecure MariaDB home directory detected: ${HOME}
Please change it to '/' to ensure that code cannot be run using
${HOME}/.bashrc or ${HOME}/.bash_profile if ever logging in as
the 'mysql' user.
To change the home directory: usermod -d / mysql
More information: https://www.cve.org/CVERecord?id=CVE-2026-107814
EOF
fi
