Skip to content

Commit 390f705

Browse files
author
Kristan Kenney
committed
Fix deletion of admin logs from other admin accounts
1 parent b625a67 commit 390f705

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

web/delete/log/index.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,25 @@
1010
exit();
1111
}
1212

13+
// Check if administrator is viewing system log (currently 'admin' user)
14+
if (($_SESSION['userContext'] === "admin") && ($_GET['user']) === 'admin') {
15+
$user=$_GET['user'];
16+
$token=$_SESSION['token'];
17+
}
18+
19+
// Set correct page reload target
20+
if (($_SESSION['userContext'] === "admin") && ($_GET['user']) === 'admin') {
21+
header("Location: /list/log/?user=$user&token=$token");
22+
} else {
23+
header("Location: /list/log/");
24+
}
25+
1326
// Clear log
14-
header("Location: /list/log/");
1527
$v_username = escapeshellarg($user);
1628
exec (HESTIA_CMD."v-delete-user-log ".$v_username." ".$output, $return_var);
1729
check_return_code($return_var,$output);
1830
unset($output);
31+
unset($token);
1932

2033
// Render page
2134
render_page($user, $TAB, 'list_log');

web/list/log/index.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@
77

88
// Data
99
if (($_SESSION['userContext'] === "admin") && ($_GET['user'])) {
10+
// Check token
11+
if ((!isset($_GET['token'])) || ($_SESSION['token'] != $_GET['token'])) {
12+
header('location: /login/');
13+
exit();
14+
}
1015
$user=escapeshellarg($_GET['user']);
1116
}
17+
1218
exec (HESTIA_CMD."v-list-user-log $user json", $output, $return_var);
1319
check_error($return_var);
1420
$data = json_decode(implode('', $output), true);

web/templates/admin/list_log.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
<div class="actions-panel display-inline-block" key-action="js">
2121
<a class="data-controls do_delete ui-button danger cancel">
2222
<i class="do_delete fas fa-times-circle status-icon red"></i><?=_('Delete')?>
23-
<input type="hidden" name="delete_url" value="/delete/log/?token=<?=$_SESSION['token']?>" />
23+
<? if (($_SESSION['userContext'] === 'admin') && ($_GET['user'] === 'admin')) {?>
24+
<input type="hidden" name="delete_url" value="/delete/log/?user=admin&token=<?=$_SESSION['token']?>" />
25+
<? } else { ?>
26+
<input type="hidden" name="delete_url" value="/delete/log/?token=<?=$_SESSION['token']?>" />
27+
<? } ?>
2428
<div class="confirmation-text-delete hidden" title="<?=_('Confirmation')?>">
2529
<p class="confirmation"><?=_('DELETE_LOGS_CONFIRMATION')?></p>
2630
</div>

web/templates/admin/list_services.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<a href="/list/firewall/" class="ui-button cancel" dir="ltr"><i class="fas fa-shield-alt status-icon red"></i><?=_('Firewall')?></a>
99
<?php }?>
1010
<a href="/list/updates/" class="ui-button cancel" dir="ltr"><i class="fas fa-sync status-icon green"></i><?=_('Updates')?></a>
11-
<a href="/list/log/?user=admin" class="ui-button cancel" dir="ltr"><i class="fas fa-book-reader status-icon lightblue"></i><?=_('Logs')?></a>
11+
<a href="/list/log/?user=admin&token=<?=$_SESSION['token']?>" class="ui-button cancel" dir="ltr"><i class="fas fa-book-reader status-icon lightblue"></i><?=_('Logs')?></a>
1212
<div class="actions-panel display-inline-block" key-action="js">
1313
<a class="data-controls do_servicerestart ui-button danger cancel">
1414
<i class="do_servicerestart fas fa-undo status-icon red"></i><?=_('Restart')?>

0 commit comments

Comments
 (0)