There is probably some way to read arbitrary files from the container via some kind of crafted path, but it's their own container so meh. Minimal due diligence has been done to sanitize the path a bit at least. Slightly rearranged the start page as well to make it more logical
36 lines
786 B
PHP
36 lines
786 B
PHP
<?php
|
|
|
|
function list_logs($group) {
|
|
$command = "ls /usr/local/tomcat/logs/";
|
|
$output = array();
|
|
$result = 0;
|
|
exec("sudo pvt-manage connect $group $command", $output, $result);
|
|
if($result === 0) {
|
|
return $output;
|
|
} else {
|
|
throw new Exception('Something went wrong.');
|
|
}
|
|
}
|
|
|
|
$user = explode('@', $_SERVER['REMOTE_USER'])[0];
|
|
|
|
$group = 'none';
|
|
foreach(file('../groups.list') as $line) {
|
|
$line = preg_split("/[\t ]+/", trim($line));
|
|
if($line[0] == $user) {
|
|
$group = $line[1];
|
|
}
|
|
}
|
|
|
|
if($group == 'none') {
|
|
print("You don't seem to belong to a group.");
|
|
exit(0);
|
|
}
|
|
|
|
print("<ul>");
|
|
foreach(list_logs($group) as $logfile) {
|
|
print("<li><a href='./action.php?a=log&file=$logfile'>$logfile</a></li>");
|
|
}
|
|
print("</ul>");
|
|
?>
|