[rancid] mtrancid patch

Steven Saner ssaner at hubris.net
Fri Jan 9 21:15:19 UTC 2015


I had an issue with rancid 3.1 (and earlier versions too) tracking
several Mikrotik routers. I'm not sure if this issue affects all
Mikrotik models, but in my case I am using the following:

> system resource print
             uptime: 8w2d22h47m48s
            version: 5.21
        free-memory: 992624KiB
       total-memory: 1555212KiB
                cpu: e500v2
          cpu-count: 2
      cpu-frequency: 1066MHz
           cpu-load: 16%
     free-hdd-space: 68928KiB
    total-hdd-space: 110092KiB
  architecture-name: powerpc
         board-name: RB1100AHx2
           platform: MikroTik


In the config export there is the following:

/interface ovpn-server server
set auth=sha1,md5 certificate=none cipher=blowfish128,aes128
default-profile=\
    default enabled=no keepalive-timeout=60 mac-address=FE:EB:E4:50:DC:E8 \
    max-mtu=1500 mode=ip netmask=24 port=1194 require-client-certificate=no


This is an interface associated with the OpenVPN server, which I am not
using. The thing is, the mac-address attribute seems to be a generated
value and it changes (how often or why, I'm not sure). As a result every
time rancid would run, it would log a config change because this value
was different.

I implemented a quick and dirty patch to mtrancid to simply ignore the
set auth= line inside of the ovpn-server interface so that the config
would not change each run.

Has someone else run in to this? Did they solve the problem in a
different way? It might be better to make this ignore just the
mac-address attribute, rather than the entire config line, but it didn't
matter to me as I'm not using that interface.

Here is my patch:

--- a/bin/mtrancid.in
+++ b/bin/mtrancid.in
@@ -236,10 +236,12 @@ sub SystemLicensePrint {
 sub Export {
        print STDERR "    In Export: $_" if ($debug);
        my $buffer = "";
+       my $ovpn   = 0;

        while (<INPUT>) {
                tr/\015//d;
                if (/$prompt/) { $found_end=1; $clean_run=1; return 0};
+               if (/interface ovpn-server server/) { $ovpn = 1; }
                next if(/^(\s*|\s*$cmd\s*)$/);
                next if(/^#/);
                return(1) if /(bad command name )/;
@@ -259,7 +261,11 @@ sub Export {
                        # Fix quoted strings
                        $buffer =~ s/(\S+)="(\S+)"/$1=$2/g;

-                       ProcessHistory("","","","$buffer");
+                       if ($ovpn && $buffer =~ m/\s*set auth/) {
+                               $ovpn = 0;
+                       } else {
+                               ProcessHistory("","","","$buffer");
+                       }
                        $buffer = "";
                }
        }


-- 
--------------------------------------------------------------------------
Steven Saner <ssaner at hubris.net>                      Voice:  316-858-3000
Director of Network Operations                          Fax:  316-858-3001
Hubris Communications                                http://www.hubris.net


More information about the Rancid-discuss mailing list