From a4392a5eeedf331fc36f5eeab81122a6eddeb4b6 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 22 Jan 2021 13:32:21 +0100 Subject: [systemstatus] Add permissions for service restarting --- modules-available/systemstatus/lang/de/permissions.json | 4 ++++ modules-available/systemstatus/lang/en/permissions.json | 4 ++++ modules-available/systemstatus/lang/en/template-tags.json | 2 +- modules-available/systemstatus/page.inc.php | 6 +++++- modules-available/systemstatus/permissions/permissions.json | 12 ++++++++++++ modules-available/systemstatus/templates/ajax-journal.html | 3 ++- 6 files changed, 28 insertions(+), 3 deletions(-) diff --git a/modules-available/systemstatus/lang/de/permissions.json b/modules-available/systemstatus/lang/de/permissions.json index a3041fbc..9e7c5be9 100644 --- a/modules-available/systemstatus/lang/de/permissions.json +++ b/modules-available/systemstatus/lang/de/permissions.json @@ -1,4 +1,7 @@ { + "restart.dmsd": "bwLehrpool-Suite neustarten.", + "restart.dnbd3-server": "DNBD3-Server neustarten.", + "restart.ldadp": "LDADP neustarten.", "serverreboot": "Server neustarten.", "show.overview.addresses": "Zeige Adresskonfiguration auf \u00dcbersichtsseite.", "show.overview.diskstat": "Zeige Speicherplatzwerte auf \u00dcbersichtsseite.", @@ -6,6 +9,7 @@ "show.overview.services": "Zeige Dienste auf \u00dcbersichtsseite.", "show.overview.systeminfo": "Zeige Systemwerte auf \u00dcbersichtsseite.", "tab.dmsdlog": "Zugriff auf bwLehrpool-Suite-Server Statusausgabe.", + "tab.dnbd3log": "Zugriff auf DNBD3 Log.", "tab.ldadplog": "Zugriff auf LDAP\/AD-Proxy Logs.", "tab.lighttpdlog": "Zugriff auf Webserver-Logs.", "tab.netstat": "Zeige Ausgabe von netstat.", diff --git a/modules-available/systemstatus/lang/en/permissions.json b/modules-available/systemstatus/lang/en/permissions.json index 879fa882..d510e257 100644 --- a/modules-available/systemstatus/lang/en/permissions.json +++ b/modules-available/systemstatus/lang/en/permissions.json @@ -1,4 +1,7 @@ { + "restart.dmsd": "Restart bwLehrpool-Suite.", + "restart.dnbd3-server": "Restart DNBD3 server.", + "restart.ldadp": "Restart LDADP.", "serverreboot": "Reboot server.", "show.overview.addresses": "Show addresses on overview page.", "show.overview.diskstat": "Show diskstats on overview page.", @@ -6,6 +9,7 @@ "show.overview.services": "Show services on overview page.", "show.overview.systeminfo": "Show systeminfo on overview page.", "tab.dmsdlog": "Show bwLehrpool-Suite status.", + "tab.dnbd3log": "Show DNBD3 log.", "tab.ldadplog": "Show LDAP\/AD proxy logs.", "tab.lighttpdlog": "Show web server logs.", "tab.netstat": "Show output of netstat.", diff --git a/modules-available/systemstatus/lang/en/template-tags.json b/modules-available/systemstatus/lang/en/template-tags.json index 9eec08c4..b7f9867a 100644 --- a/modules-available/systemstatus/lang/en/template-tags.json +++ b/modules-available/systemstatus/lang/en/template-tags.json @@ -5,7 +5,7 @@ "lang_attention": "Attention!", "lang_average": "Average", "lang_capacity": "Capacity", - "lang_confirmRestart": "Are you sure you want to restart this service? This can leads to interruptions.", + "lang_confirmRestart": "Are you sure you want to restart this service? This can lead to interruptions.", "lang_cpuLoad": "CPU Load", "lang_dmsdUnreachable": "dmsd not reachable", "lang_failure": "Failure", diff --git a/modules-available/systemstatus/page.inc.php b/modules-available/systemstatus/page.inc.php index 05a98e94..238537d8 100644 --- a/modules-available/systemstatus/page.inc.php +++ b/modules-available/systemstatus/page.inc.php @@ -33,7 +33,8 @@ class Page_SystemStatus extends Page $service = Request::post('service', Request::REQUIRED, 'string'); $task = Taskmanager::submit('Systemctl', ['operation' => $action, 'service' => $service]); $extra = ''; - $cmp = preg_replace('/\.service$|@.*$/', '', $service); + $cmp = preg_replace('/(@.*|\.service)$/', '', $service); + User::assertPermission("restart.$cmp"); if ($cmp === 'dmsd') { $extra = '#id-DmsdLog_pane'; } elseif ($cmp === 'ldadp') { @@ -292,11 +293,14 @@ class Page_SystemStatus extends Page protected function showJournal($service, $permission) { + $cmp = preg_replace('/(@.*|\.service)$/', '', $service); User::assertPermission($permission); $output = [ 'name' => $service, 'service' => $service, 'task' => Taskmanager::submit('Systemctl', ['operation' => 'journal', 'service' => $service]), + 'restart_disabled' => User::hasPermission('restart.' . $cmp) + ? '' : 'disabled', ]; echo Render::parse('ajax-journal', ['modules' => [$output]]); } diff --git a/modules-available/systemstatus/permissions/permissions.json b/modules-available/systemstatus/permissions/permissions.json index 29e26b5e..a116fd56 100644 --- a/modules-available/systemstatus/permissions/permissions.json +++ b/modules-available/systemstatus/permissions/permissions.json @@ -5,6 +5,9 @@ "tab.dmsdlog": { "location-aware": false }, + "tab.dnbd3log": { + "location-aware": false + }, "tab.netstat": { "location-aware": false }, @@ -31,5 +34,14 @@ }, "show.overview.systeminfo": { "location-aware": false + }, + "restart.dnbd3-server": { + "location-aware": false + }, + "restart.ldadp": { + "location-aware": false + }, + "restart.dmsd": { + "location-aware": false } } \ No newline at end of file diff --git a/modules-available/systemstatus/templates/ajax-journal.html b/modules-available/systemstatus/templates/ajax-journal.html index 0405fe93..5b476d9c 100644 --- a/modules-available/systemstatus/templates/ajax-journal.html +++ b/modules-available/systemstatus/templates/ajax-journal.html @@ -4,7 +4,8 @@ {{#modules}}
- -- cgit v1.2.3-55-g7522