Fix phpMyAdmin SSO login and harden SSO/security posture
phpMyAdmin login was broken because phpmyadmin_install.sh never wired the private phpMyAdmin copy into the web server: no Apache Alias was registered via DirectAdmin CustomBuild, so the SSO redirect target was unreachable. Add configure_apache_alias()/apply_apache_alias() (Alias + Directory blocks, ./build rewrite_confs, httpd reload), detect the real Apache group instead of hardcoding diradmin:diradmin, stop silently swallowing chown/chmod failures, and verify an optional SHA256 for the downloaded phpMyAdmin tarball. Extend phpmyadmin_health_check.sh to detect a missing/incorrect Apache alias and to probe HTTP reachability. Security hardening: scope temporary phpMyAdmin SSO MySQL roles to 127.0.0.1 instead of '%', tighten SSO ticket file permissions to 0640 (they contain a plaintext MySQL password), and log MySQL connection failures for diagnosis instead of swallowing them silently. Bump version to 1.2.12 and rebuild the release archive.
This commit is contained in:
@@ -16,21 +16,19 @@ grep -Fq 'PHPMYADMIN_VERSION="${PHPMYADMIN_VERSION:-5.2.3}"' "$SCRIPT" \
|
||||
grep -Fq 'PHPMYADMIN_TARBALL_URL="${PHPMYADMIN_TARBALL_URL:-https://files.phpmyadmin.net/phpMyAdmin/5.2.3/phpMyAdmin-5.2.3-all-languages.tar.gz}"' "$SCRIPT" \
|
||||
|| fail "phpMyAdmin tarball URL is not the explicit 5.2.3 URL"
|
||||
|
||||
mkdir -p "$TMP_DIR/phpMyAdmin"
|
||||
cat > "$TMP_DIR/phpMyAdmin/config.inc.php" <<'PHP'
|
||||
<?php
|
||||
$cfg = [];
|
||||
PHP
|
||||
mkdir -p "$TMP_DIR/phpMyAdmin-source"
|
||||
cat > "$TMP_DIR/phpMyAdmin-source/index.php" <<'PHP'
|
||||
<?php
|
||||
echo 'private phpMyAdmin';
|
||||
PHP
|
||||
|
||||
PHPMYADMIN_EXISTING_DIR="$TMP_DIR/phpMyAdmin" \
|
||||
CUSTOMBUILD_DIR="$TMP_DIR/custombuild"
|
||||
mkdir -p "$CUSTOMBUILD_DIR"
|
||||
|
||||
PHPMYADMIN_PRIVATE_DIR="$TMP_DIR/alt-mysql-phpmyadmin" \
|
||||
PHPMYADMIN_SOURCE_DIR="$TMP_DIR/phpMyAdmin-source" \
|
||||
PHPMYADMIN_INSTALL_ASSUME_ROOT=1 \
|
||||
CUSTOMBUILD_DIR="$CUSTOMBUILD_DIR" \
|
||||
bash "$SCRIPT" >/dev/null
|
||||
|
||||
PRIVATE_DIR="$TMP_DIR/alt-mysql-phpmyadmin"
|
||||
@@ -39,15 +37,27 @@ SIGNON_SCRIPT="$PRIVATE_DIR/da_signon.php"
|
||||
SIGNON_URL_PAGE="$PRIVATE_DIR/da_login.php"
|
||||
TICKET_DIR="$PRIVATE_DIR/runtime/tickets"
|
||||
SESSION_DIR="$TMP_DIR/sessions"
|
||||
ALIAS_CONF="$CUSTOMBUILD_DIR/custom/ap2/conf/extra/httpd-alias.conf"
|
||||
|
||||
[ -r "$PRIVATE_DIR/index.php" ] || fail "private phpMyAdmin copy was not installed"
|
||||
[ -r "$CONFIG_INC" ] || fail "private phpMyAdmin config was not created"
|
||||
[ -r "$SIGNON_SCRIPT" ] || fail "signon script was not created"
|
||||
[ -r "$SIGNON_URL_PAGE" ] || fail "phpMyAdmin SignonURL page was not created"
|
||||
[ -d "$TICKET_DIR" ] || fail "phpMyAdmin ticket directory was not created"
|
||||
if grep -Fq "config.mysql.inc.php" "$TMP_DIR/phpMyAdmin/config.inc.php"; then
|
||||
fail "installer modified existing CustomBuild phpMyAdmin config"
|
||||
fi
|
||||
|
||||
[ -r "$ALIAS_CONF" ] || fail "Apache alias config was not created"
|
||||
grep -Fq "# BEGIN ALT_MYSQL_PHPMYADMIN" "$ALIAS_CONF" || fail "Apache alias block marker missing"
|
||||
grep -Fq "Alias /alt-mysql-phpmyadmin ${PRIVATE_DIR}" "$ALIAS_CONF" || fail "Apache alias does not point at private phpMyAdmin dir"
|
||||
grep -Fq "# END ALT_MYSQL_PHPMYADMIN" "$ALIAS_CONF" || fail "Apache alias end marker missing"
|
||||
|
||||
PHPMYADMIN_PRIVATE_DIR="$TMP_DIR/alt-mysql-phpmyadmin" \
|
||||
PHPMYADMIN_SOURCE_DIR="$TMP_DIR/phpMyAdmin-source" \
|
||||
PHPMYADMIN_INSTALL_ASSUME_ROOT=1 \
|
||||
CUSTOMBUILD_DIR="$CUSTOMBUILD_DIR" \
|
||||
bash "$SCRIPT" >/dev/null
|
||||
|
||||
BEGIN_COUNT="$(grep -Fc "# BEGIN ALT_MYSQL_PHPMYADMIN" "$ALIAS_CONF" || true)"
|
||||
[ "$BEGIN_COUNT" -eq 1 ] || fail "Apache alias block was duplicated on re-run (found $BEGIN_COUNT times)"
|
||||
|
||||
SERVER_JSON="$(php -r '
|
||||
$_SERVER["HTTPS"] = "on";
|
||||
@@ -143,7 +153,16 @@ php -d session.save_path="$SESSION_DIR" -r '
|
||||
exit(3);
|
||||
}
|
||||
' "$SIGNON_SCRIPT" || fail "signon script cannot read SSO session while phpMyAdmin session is active"
|
||||
PHPMYADMIN_PRIVATE_DIR="$PRIVATE_DIR" bash "$PLUGIN_DIR/scripts/setup/phpmyadmin_health_check.sh" >/dev/null \
|
||||
|| fail "phpMyAdmin health check should pass for SignonURL-capable config"
|
||||
PHPMYADMIN_PRIVATE_DIR="$PRIVATE_DIR" CUSTOMBUILD_DIR="$CUSTOMBUILD_DIR" \
|
||||
bash "$PLUGIN_DIR/scripts/setup/phpmyadmin_health_check.sh" >/dev/null \
|
||||
|| fail "phpMyAdmin health check should pass for SignonURL-capable config with Apache alias present"
|
||||
|
||||
EMPTY_CUSTOMBUILD_DIR="$TMP_DIR/custombuild-empty"
|
||||
mkdir -p "$EMPTY_CUSTOMBUILD_DIR"
|
||||
HEALTH_OUTPUT="$(PHPMYADMIN_PRIVATE_DIR="$PRIVATE_DIR" CUSTOMBUILD_DIR="$EMPTY_CUSTOMBUILD_DIR" \
|
||||
bash "$PLUGIN_DIR/scripts/setup/phpmyadmin_health_check.sh" 2>&1)" \
|
||||
&& fail "phpMyAdmin health check should fail when the Apache alias is missing"
|
||||
echo "$HEALTH_OUTPUT" | grep -Fqi "alias" \
|
||||
|| fail "phpMyAdmin health check failure message should mention the missing Apache alias (got: $HEALTH_OUTPUT)"
|
||||
|
||||
echo "phpmyadmin_install_test: OK"
|
||||
|
||||
Reference in New Issue
Block a user