Mon, Oct 11, 2021 at 06:28:39PM -0700, Michael Ducharme:
> Hello,
> 
> I just wanted to let you know - on the MikroTik forum I am seeing reports
> that RANCID is no longer working to back up RouterOS versions 6.49 and
> 7.1rc3 and 7.1rc4. The commands still run and there were no documented
> changes to the console or SSH on the MikroTik side recently, so I'm not
> sure why this is happening suddenly. I was trying to go through the code to
> see what the problem might be, but could not find anything.
> 
> Please see this post for details on the error:
> https://forum.mikrotik.com/viewtopic.php?p=885246#p885246

Care to the attached patch?  

> I also tried loading up the output of the working 6.48.4 vs non-working
> 6.49 into a hex editor to see if there were any unexpected characters being
> added that might be confusing RANCID but did not find anything of note. It
> looks pretty much the same to me.

I have access to only one Mikrotik and its running an older O/S.  I've
tested the patch against it.
diff --git a/etc/rancid.types.base b/etc/rancid.types.base
index a4e40a3d..09143adf 100644
--- a/etc/rancid.types.base
+++ b/etc/rancid.types.base
@@ -745,6 +745,7 @@ routeros;inloop;routeros::inloop
 routeros;command;routeros::SystemPackagePrintDetail;system package print detail without-paging
 routeros;command;routeros::SystemRouterboardPrint;system routerboard print
 routeros;command;routeros::SystemLicensePrint;system license print
+routeros;command;routeros::Export;export show-sensitive
 routeros;command;routeros::Export;export
 #
 mrtd;script;mrancid
diff --git a/lib/routeros.pm.in b/lib/routeros.pm.in
index 3b1b7dae..b4a16cb4 100644
--- a/lib/routeros.pm.in
+++ b/lib/routeros.pm.in
@@ -18,6 +18,9 @@ our @ISA = qw(Exporter);
 
 use rancid @VERSION@;
 
+our $Export;				# Only run Export() once
+
+
 @ISA = qw(Exporter rancid main);
 #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands);
 
@@ -163,12 +166,15 @@ sub Export {
 
     while (<$INPUT>) {
 	tr/\015//d;
-	if (/$prompt/) { $found_end=1; $clean_run=1; return 0};
+	if (/$prompt/) { $found_end = 1; $clean_run = 1; return 0};
 	next if(/^(\s*|\s*$cmd\s*)$/);
 	next if(/^#/);
+	return(1) if /(expected end of command )/;	# aka unknown argument
 	return(1) if /(bad command name )/;
 	s/^\s+//g;
 
+	return(0) if ($routeros::Export);
+
 	# RouterOS splits long lines with backslashes - this re-joins them
 	if (/\\\n$/) {
 	    s/\s*\\\n$//;
@@ -191,6 +197,7 @@ sub Export {
 	    $buffer = "";
 	}
     }
+    $routeros::Export = 1;
 }
 
 1;
_______________________________________________
Rancid-discuss mailing list
Rancid-discuss@www.shrubbery.net
https://www.shrubbery.net/mailman/listinfo/rancid-discuss

Reply via email to