![](https://secure.gravatar.com/avatar/6f49b60caf1cb1d942f12302c0334b7d.jpg?s=120&d=mm&r=g)
Hi,
to get the RANCID mode working on my Debian wheezy I needed to tweak the code a bit. If anyone is interested in the diff, here goes: -(snip)- --- a/html/pages/device/showconfig.inc.php +++ b/html/pages/device/showconfig.inc.php @@ -39,7 +39,9 @@ if ($_SESSION['userlevel'] >= 5) if (!$rev['count'] && is_executable($config['git'])) { $cmd_dir = escapeshellarg(dirname($device_config_file)); - $gitlogs = external_exec($config['git'].' --git-dir='.$cmd_dir.' log --pretty=format:"%h %ci" '.$cmd_file); + $git_file = escapeshellarg(basename($device_config_file)); + $git_dir = escapeshellarg(dirname($device_config_file) . '/.git'); + $gitlogs = external_exec($config['git'].' --git-dir='.$git_dir.' log --pretty=format:"%h %ci" -- '.$git_file); foreach (explode("\n", $gitlogs) as $line) { // b6989b9 2014-11-10 00:16:53 +0100 @@ -109,8 +111,10 @@ if ($_SESSION['userlevel'] >= 5) $prev_name = 'r'.$rev['prev']; break; case 'git': - $cmd_cat = $config['git'].' --git-dir='.$cmd_dir.' show '.$rev['curr'].':'.escapeshellarg(basename($device_config_file)); - $cmd_diff = $config['git'].' --git-dir='.$cmd_dir.' diff '.$rev['prev'].' '.$rev['curr'].' '.$cmd_file; + $git_file = escapeshellarg(basename($device_config_file)); + $git_dir = escapeshellarg(dirname($device_config_file) . '/.git'); + $cmd_cat = $config['git'].' --git-dir='.$git_dir.' show '.$rev['curr'].':'.$git_file; + $cmd_diff = $config['git'].' --git-dir='.$git_dir.' diff '.$rev['prev'].' '.$rev['curr'].' -- '.$git_file; $prev_name = $rev['prev']; } $device_config = external_exec($cmd_cat); -(snip)-
If I didn't work around that, I'd just get the last version and no history/diff. Running the relevant git commands, I was receiving both: "fatal: Not a git repository:" and "fatal: ambiguous argument '...': unknown revision or path not in the working tree."
...and since we don't use RANCID itself, but some script that does store our configs with a *.cfg extension, I've also needed to patch: -(snip)- --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -1308,7 +1308,7 @@ function get_rancid_filename($hostname, { global $config;
- $hostnames = array($hostname); + $hostnames = array($hostname . '.cfg');
if ($rdebug) { echo("Hostname: $hostname<br />"); }
@@ -1319,6 +1319,8 @@ function get_rancid_filename($hostname,
if ($shortname != $hostname) { + // FIXME: as long as RUS nmm does store with .cfg extension + $hostnames[] = $shortname . '.cfg'; $hostnames[] = $shortname; if ($rdebug) { echo("Hostname different from short hostname, looking for both<br />"); } } @@ -1326,6 +1328,8 @@ function get_rancid_filename($hostname, // Addition of a domain suffix for non-FQDN device names. if (isset($config['rancid_suffix']) && $config['rancid_suffix'] !== '') { + // FIXME: as long as RUS nmm does store with .cfg extension + $hostnames[] = $hostname . '.' . trim($config['rancid_suffix'] . '.cfg', ' .'); $hostnames[] = $hostname . '.' . trim($config['rancid_suffix'], ' .'); if ($rdebug) { echo("RANCID suffix configured, also looking for " . $hostname . '.' . trim($config['rancid_suffix'], ' .') . "<br />"); } } -(snip)-
The reason is that we have a config with and without ACLs and I'm still pondering whether it'd not be better for our admins to be able to select both variants from the WebUI too.
Best regards, Kilian