From efa84ed663108f2730e3f3f7853caa43b793af65 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 17 Dec 2019 17:23:24 +0100 Subject: [rebootcontrol] Implement deletion of jump host --- modules-available/rebootcontrol/lang/de/messages.json | 1 + modules-available/rebootcontrol/pages/jumphost.inc.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/modules-available/rebootcontrol/lang/de/messages.json b/modules-available/rebootcontrol/lang/de/messages.json index 32da10b1..33a3fbde 100644 --- a/modules-available/rebootcontrol/lang/de/messages.json +++ b/modules-available/rebootcontrol/lang/de/messages.json @@ -2,6 +2,7 @@ "invalid-cidr": "Ung\u00fcltige CIDR-Angabe: {{0}}", "invalid-port": "Ung\u00fcltiger Port: {{0}}", "invalid-subnet": "Ung\u00fcltiges Subnetz: {{0}}", + "jumphost-deleted": "Sprung-Host {{0}} gel\u00f6scht", "jumphost-saved": "Sprung-Host {{0}} gespeichert", "no-clients-selected": "Keine Clients ausgew\u00e4hlt", "no-current-tasks": "Keine aktuellen oder k\u00fcrzlich abgeschlossenen Aufgaben", diff --git a/modules-available/rebootcontrol/pages/jumphost.inc.php b/modules-available/rebootcontrol/pages/jumphost.inc.php index 7d1877d2..bf0a67e2 100644 --- a/modules-available/rebootcontrol/pages/jumphost.inc.php +++ b/modules-available/rebootcontrol/pages/jumphost.inc.php @@ -28,10 +28,17 @@ class SubPage self::execCheckConnection($id); return; } + $id = Request::post('deleteid', false, 'int'); + if ($id !== false) { + User::assertPermission('jumphost.edit'); + self::deleteJumphost($id); + return; + } } private static function execCheckConnection($hostid) { + // Permcheck in caller $host = self::getJumpHost($hostid); $task = RebootControl::wakeViaJumpHost($host, '255.255.255.255', [['macaddr' => '00:11:22:33:44:55']]); if (!Taskmanager::isTask($task)) @@ -39,6 +46,14 @@ class SubPage Util::redirect('?do=rebootcontrol&show=task&type=checkhost&what=task&taskid=' . $task['id']); } + private static function deleteJumphost($hostid) + { + // Permcheck in caller + $host = self::getJumpHost($hostid); + Database::exec('DELETE FROM reboot_jumphost WHERE hostid = :hostid LIMIT 1', ['hostid' => $hostid]); + Message::addSuccess('jumphost-deleted', $host['host']); + } + private static function saveJumpHost() { User::assertPermission('jumphost.edit'); -- cgit v1.2.3-55-g7522