From 796bc1530253312504c63291333579b7a91c14ad Mon Sep 17 00:00:00 2001 From: Bashy Date: Tue, 26 May 2026 16:13:21 +0300 Subject: [PATCH] Remove sudo from read-only systemctl calls in botcontrol is-active and show work without sudo as www-data; only start/stop/restart need elevated privileges. Co-Authored-By: Claude Sonnet 4.6 --- web/api/botcontrol.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/api/botcontrol.php b/web/api/botcontrol.php index ac4c138..5a8d0fb 100644 --- a/web/api/botcontrol.php +++ b/web/api/botcontrol.php @@ -21,10 +21,10 @@ if ($method === 'GET') { $action = $_GET['action'] ?? 'status'; if ($action !== 'status') { http_response_code(400); echo json_encode(['error' => 'Unknown action']); exit; } - exec('sudo systemctl is-active ' . escapeshellarg($service) . ' 2>&1', $activeOut, $activeCode); + exec('systemctl is-active ' . escapeshellarg($service) . ' 2>&1', $activeOut, $activeCode); $isActive = trim(implode('', $activeOut)) === 'active'; - exec('sudo systemctl show ' . escapeshellarg($service) . ' --property=ActiveEnterTimestamp --value 2>&1', $tsOut); + exec('systemctl show ' . escapeshellarg($service) . ' --property=ActiveEnterTimestamp --value 2>&1', $tsOut); $since = trim(implode('', $tsOut)); echo json_encode([ @@ -55,7 +55,7 @@ exec('sudo systemctl ' . $action . ' ' . escapeshellarg($service) . ' 2>&1', $ou Audit::log($db, 'bot_' . $action, $project_id, $service); // Return updated status after action -exec('sudo systemctl is-active ' . escapeshellarg($service) . ' 2>&1', $activeOut); +exec('systemctl is-active ' . escapeshellarg($service) . ' 2>&1', $activeOut); $isActive = trim(implode('', $activeOut)) === 'active'; echo json_encode([