Skip to content

Commit

Permalink
Bugfix for nextcloud#168: basedir restriction and handling speed=-1 r…
Browse files Browse the repository at this point in the history
…esult
  • Loading branch information
sausix committed Nov 26, 2020
1 parent 2ed82f2 commit 95e984e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/OperatingSystems/DefaultOs.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,19 @@ public function getNetworkInfo() {
* @return string
*/
public function getNetworkInterfaces() {
$interfaces = glob('/sys/class/net/*');
$interfaces = array_diff(scandir("/sys/class/net"), array('.', '..')); // remove dot directories
$result = [];

foreach ($interfaces as $interface) {
$iface = [];
$iface['interface'] = basename($interface);
$iface['interface'] = $interface;
$iface['mac'] = shell_exec('ip addr show dev ' . $iface['interface'] . ' | grep "link/ether " | cut -d \' \' -f 6 | cut -f 1 -d \'/\'');
$iface['ipv4'] = shell_exec('ip addr show dev ' . $iface['interface'] . ' | grep "inet " | cut -d \' \' -f 6 | cut -f 1 -d \'/\'');
$iface['ipv6'] = shell_exec('ip -o -6 addr show ' . $iface['interface'] . ' | sed -e \'s/^.*inet6 \([^ ]\+\).*/\1/\'');
if ($iface['interface'] !== 'lo') {
$iface['status'] = shell_exec('cat /sys/class/net/' . $iface['interface'] . '/operstate');
$iface['speed'] = shell_exec('cat /sys/class/net/' . $iface['interface'] . '/speed');
if ($iface['speed'] !== '') {
if ($iface['speed'] !== '' and substr($iface['speed'], 0, 1) != "-") {
$iface['speed'] = $iface['speed'] . 'Mbps';
} else {
$iface['speed'] = 'unknown';
Expand Down

0 comments on commit 95e984e

Please sign in to comment.