Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch clog to cat in status_tinc.php #691

Merged
merged 9 commits into from
Nov 6, 2019
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion security/pfSense-pkg-tinc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

PORTNAME= pfSense-pkg-tinc
PORTVERSION= 1.0.35
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= security
MASTER_SITES= # empty
DISTFILES= # empty
Expand Down
18 changes: 16 additions & 2 deletions security/pfSense-pkg-tinc/files/usr/local/www/status_tinc.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,15 @@ function tinc_status_usr1() {
usleep(500000);
$clog_path = "/usr/local/sbin/clog";
$result = array();
$logfile = "/var/log/tinc.log";
$firmware = host_firmware_version();

exec("{$clog_path} /var/log/tinc.log | /usr/bin/sed -e 's/.*tinc\[.*\]: //'", $result);
if ($firmware['config_version'] >= 19.7) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a proper version test. The config revision is not a reliable indicator of the pfSense version. It should be based on $g['product_version'] or similar to test the actual version directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in case of $g['product_version'] we need to enumerate all supported versions
better to use kernel version number

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it is not. That does not necessarily determine the pfSense version either. It must use product_version. If you need to compare, there are convenience functions like pfs_version_compare() that facilitate a proper comparison.

exec(system_log_get_cat() . ' ' . $logfile . "| /usr/bin/sed -e 's/.*tinc\[.*\]: //'", $result);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than $logfile here, it should use sort_related_log_files() like the other example.

} else {
exec("{$clog_path} /var/log/tinc.log | /usr/bin/sed -e 's/.*tinc\[.*\]: //'", $result);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use the full hardcoded path to the log here, rather than {$logfile} which is populated above?

}

$i = 0;
foreach ($result as $line) {
jim-p marked this conversation as resolved.
Show resolved Hide resolved
if (preg_match("/Connections:/", $line)) {
Expand Down Expand Up @@ -56,8 +63,15 @@ function tinc_status_usr2() {
usleep(500000);
$clog_path = "/usr/local/sbin/clog";
$result = array();
$logfile = "/var/log/tinc.log";
$firmware = host_firmware_version();

exec("{$clog_path} /var/log/tinc.log | sed -e 's/.*tinc\[.*\]: //'",$result);
if ($firmware['config_version'] >= 19.7) {
exec(system_log_get_cat() . ' ' . $logfile . "| /usr/bin/sed -e 's/.*tinc\[.*\]: //'", $result);
} else {
exec("{$clog_path} /var/log/tinc.log | /usr/bin/sed -e 's/.*tinc\[.*\]: //'", $result);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments above which also apply to this similar block.
(And since they are practically identical, I have to wonder if this could be simplified significantly, though that's likely out of scope for this particular PR)

$i = 0;
foreach ($result as $line) {
if (preg_match("/Statistics for Generic BSD (tun|tap) device/",$line)) {
Expand Down