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

Remove duplicate mib directories #9148

Merged
merged 1 commit into from
Sep 4, 2018
Merged
Changes from all 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
28 changes: 12 additions & 16 deletions includes/snmp.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,28 +84,24 @@ function get_mib_dir($device)
* If $mibdir is empty '', return an empty string
*
* @param string $mibdir should be the name of the directory within $config['mib_dir']
* @param string $device
* @param array $device
* @return string The option string starting with -M
*/
function mibdir($mibdir = null, $device = array())
function mibdir($mibdir = null, $device = [])
{
global $config;

$extra_dir = implode(':', get_mib_dir($device));
if (!empty($extra_dir)) {
$extra_dir = ":".$extra_dir;
}
$base = Config::get('mib_dir');
$dirs = get_mib_dir($device);
$dirs[] = "$base/$mibdir";

if (is_null($mibdir)) {
return " -M ${config['mib_dir']}$extra_dir";
}
// make sure base directory is included first
array_unshift($dirs, $base);

if (empty($mibdir)) {
// use system mibs
return '';
}
// remove trailing /, remove empty dirs, and remove duplicates
$dirs = array_unique(array_filter(array_map(function ($dir) {
return rtrim($dir, '/');
}, $dirs)));

return " -M ${config['mib_dir']}$extra_dir:${config['mib_dir']}/$mibdir";
return " -M " . implode(':', $dirs);
}//end mibdir()

/**
Expand Down