From 237c19c13df6fdfe1a0b556028e2a85825af29b1 Mon Sep 17 00:00:00 2001 From: Myron Blair Date: Mon, 8 Jun 2026 16:05:03 +0000 Subject: [PATCH] Guard db-engine remove from dropping panel DB; restore VERSION --- VERSION | 2 +- panel/api/endpoints/system.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/VERSION b/VERSION index c7382d6..3eefcb9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5251494 +1.0.0 diff --git a/panel/api/endpoints/system.php b/panel/api/endpoints/system.php index 4b71642..170cc07 100644 --- a/panel/api/endpoints/system.php +++ b/panel/api/endpoints/system.php @@ -570,6 +570,16 @@ match ($action) { if (!in_array($engine, ['mysql','mariadb','postgresql'])) Response::error("Invalid engine"); if (!in_array($action, ['install','remove','start','stop','restart','set-active'])) Response::error("Invalid action"); + // Safety: never remove the engine that is currently hosting the NovaCPX panel DB + if ($action === 'remove') { + $activeConn = strtolower(DB_HOST === 'localhost' ? 'mysql' : ''); + $isMariaDB = str_contains(strtolower(shell_exec("mysql --version 2>/dev/null") ?: ''), 'mariadb'); + $runningEngine = $isMariaDB ? 'mariadb' : 'mysql'; + if ($engine === $runningEngine || ($engine === 'mysql' && $isMariaDB) || ($engine === 'mariadb' && !$isMariaDB)) { + Response::error("Cannot remove $engine — it is currently hosting the NovaCPX panel database. Migrate first.", 409); + } + } + $out = ''; if ($action === 'install') { $pkg = match($engine) {