Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions addons/mariadb/scripts-ut-spec/galera_start_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,27 @@ EOF
The output should include "GALERA_SOCKETLESS_MARIADBD_THRESHOLD"
End
End

Describe "wsrep_sst_auth is not persisted (H11)"
# rsync SST does not use wsrep_sst_auth; writing it to DATA_DIR (a
# needSnapshot volume) leaked the plaintext root password into snapshots.

It "does not write wsrep_sst_auth to any file"
When run sh -c "grep -nE 'wsrep_sst_auth=.*>|> +\"?\\\$?\\{?sst_conf' \"$(script_file)\" || true"
The status should be success
The output should equal ""
End

It "does not load a defaults-extra-file for SST auth"
When run sh -c "grep -F 'defaults-extra-file=' \"$(script_file)\" | grep -F 'sst' || true"
The status should be success
The output should equal ""
End

It "removes any stale .galera-sst-auth.cnf left by a previous chart version"
When call script_contains "rm -f \"\${DATA_DIR}/.galera-sst-auth.cnf\""
The status should be success
The output should include ".galera-sst-auth.cnf"
End
End
End
17 changes: 8 additions & 9 deletions addons/mariadb/scripts/galera-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,16 @@ main() {
local cluster_address
cluster_address=$(build_cluster_address)

# wsrep_sst_auth must not appear on the command line (visible in ps output).
# Write it to a file under DATA_DIR (the persistent volume, always writable)
# and load it via --defaults-extra-file so MariaDB picks it up at startup.
local sst_conf="${DATA_DIR}/.galera-sst-auth.cnf"
printf '[mysqld]\nwsrep_sst_auth=%s:%s\n' \
"${MARIADB_ROOT_USER}" "${MARIADB_ROOT_PASSWORD}" > "$sst_conf"
chown mysql:mysql "$sst_conf"
chmod 600 "$sst_conf"
# Do NOT persist wsrep_sst_auth. It is only consumed by the mariabackup/
# xtrabackup/mysqldump SST methods; this addon uses `wsrep_sst_method = rsync`
# (config/mariadb-galera.tpl), which does not authenticate via wsrep_sst_auth,
# so the credential was unused. Worse, it was written to DATA_DIR — a
# `needSnapshot: true` volume — so the plaintext root password rode into every
# volume snapshot / backup. Remove any stale file left by a previous chart
# version; do not recreate it.
rm -f "${DATA_DIR}/.galera-sst-auth.cnf" 2>/dev/null || true

local wsrep_args=(
"--defaults-extra-file=${sst_conf}"
"--wsrep-cluster-address=${cluster_address}"
"--wsrep-cluster-name=${CLUSTER_NAME:-mariadb-galera}"
"--wsrep-node-name=${POD_NAME}"
Expand Down
Loading