OpenNetAdmin

Track. Automate. Configure.

Home About Features Community Develop
Download this project as a tar.gz file

dcm.pl bug and possible fix. " ERROR => Invalid connector UR

jtan163

21-06-2012 22:42:55

Hi folks,
I'm new to the forums, so I hope I am not raising an issue that is well known and I hope that this is an appropriate place to report a bug - as far as I can see the general public can't raise bugs here: https://github.com/opennetadmin/ona/iss ... state=open

I think I have found a bug in dcm.pl and a partial/possible fix.
The bug is whenever I try and run dcm.pl I always get: ERROR => Invalid connector URL: https://cesa-internal-ona.icesa.catholic.edu.au/dcm.php.


I am running OSX 10.6.8 on a MacBook
Darwin ceo09320.cenet.edu 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386
perl -v output available at the bottom of my post.
However I do not believe the problem is unique to mac as I also get the same problem when I run the dcm.pl on the same server ONA is insalled on, which is a linux VM.

How to Reproduce:[/size:i5pxo4b5]
I want to run dcm.pl on my MacBook against an install of ONA on a linux server.
First off I've downloaded
http://opennetadmin.com/docs/_media/dow ... .tar.gz,to my MacBook untarrted it, created /opt/ona/bin and copied dcm.pl into that dir.


When I run dcm.pl I always get an error like this.
ceo09320:.dcm a1155344$ /opt/ona/bin/dcm.pl -c dcm.conf -r subnet_display subnet=10.2.25.0
cat: /etc/onabase: No such file or directory
Jun 22 13:28:35 ceo09320 dcm.pl[6059]: ERROR => Invalid connector URL: https://cesa-internal-ona.icesa.catholic.edu.au/dcm.php



To test the possible fix:
Copy the orignal dcm.pl aside to dcm-bad.pl and edit dcm.pl.
ceo09320:bin root# cp dcm.pl dcm-bad.pl
ceo09320:bin root# vi dcm.pl

The edit I make to dcm.pl is to change line 1374 from this:

if ($networking{'url'} !~ /(\w+):\/\/([\w.]+)(:\d+)?(\/.*$)/) {

to this:

if ($networking{'url'} !~ /(\w+):\/\/(\w.+)(:\d+)?(\/.*$)/) {

I.e. remove the square brackets "[" and "]".

Do now dcm.pl has no square brackets in line 1374 and dcm-bad.pl does have the original square brackets on line 1374.

diff dcm.pl, which should be fixed and dcm-bad.pl which is the original version from http://opennetadmin.com/docs/_media/dow ... .19.tar.gz.

ceo09320:bin root# diff dcm.pl dcm-bad.pl
1374c1374
< if ($networking{'url'} !~ /(\w+):\/\/(\w.+)(:\d+)?(\/.*$)/) {
---
> if ($networking{'url'} !~ /(\w+):\/\/([\w.]+)(:\d+)?(\/.*$)/) {
ceo09320:bin root#


Re-run with square brackets removed and the command works.
ceo09320:.dcm a1155344$ /opt/ona/bin/dcm.pl -c dcm.conf -r subnet_display subnet=10.2.25.0
Use of uninitialized value in numeric eq (==) at /System/Library/Perl/Extras/5.10.0/IO/Socket/SSL.pm line 1186.
SUBNET RECORD
id 26
subnet_type_id 7
vlan_id 6
ip_addr 10.2.25.0
ip_mask 255.255.255.0 (/24)
name SERVICES

ASSOCIATED VLAN RECORD
id 6
vlan_campus_id 5
name SERVICES
number 1025
vlan_campus_name EFTS
ceo09320:.dcm a1155344$


Conclusion the regex on line 1374 of dcm.pl is not quite right.
The square brackets around the hostname portion of the URL match regex should not be there.

However now that dcm.pl executes, we see another bug related to SSL, which maybe is in the SSL.pm module - I have not investigated that.


Another test to verify the regex is broken is to take the regex and test it with a perl one liner:

Run without the square brackets and the regex matches and we get output.

ceo09320:.dcm a1155344$ perl -e 'if( "https://cesa-dnsmgr.icesa.catholic.edu.au:80/dcm.php" =~ m/(\w+):\/\/(\w.+)(:\d+)?(\/.*$)/){ print "1: $1 2: $2 3:$3 4: $4\n";}'
1: https 2: cesa-dnsmgr.icesa.catholic.edu.au:80 3: 4: /dcm.php


Run with the square brackets and the regex matches and we get no output.

ceo09320:.dcm a1155344$ perl -e 'if( "https://cesa-dnsmgr.icesa.catholic.edu.au:80/dcm.php" =~ m/(\w+):\/\/([\w.]+)(:\d+)?(\/.*$)/){ print "1: $1 2: $2 3:$3 4: $4\n";}'


Same tests again with an optional port number in the URL.
No square brackets, it runs OK:

ceo09320:.dcm a1155344$ perl -e 'if( "https://cesa-dnsmgr.icesa.catholic.edu.au/dcm.php" =~ m/(\w+):\/\/(\w.+)(:\d+)?(\/.*$)/){ print "1: $1 2: $2 3:$3 4: $4\n";}'
1: https 2: cesa-dnsmgr.icesa.catholic.edu.au 3: 4: /dcm.php


With square brackets it fails.

ceo09320:.dcm a1155344$ perl -e 'if( "https://cesa-dnsmgr.icesa.catholic.edu.au/dcm.php" =~ m/(\w+):\/\/([\w].+)(:\d+)?(\/.*$)/){ print "1: $1 2: $2 3:$3 4: $4\n";}'
1: https 2: cesa-dnsmgr.icesa.catholic.edu.au 3: 4: /dcm.php
ceo09320:.dcm a1155344$




Perl info from my MacBook

ceo09320:bin root# perl -v;perl -V

This is perl, v5.10.0 built for darwin-thread-multi-2level
(with 2 registered patches, see perl -V for more detail)

Copyright 1987-2007, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

Summary of my perl5 (revision 5 version 10 subversion 0) configuration:
Platform:
osname=darwin, osvers=10.0, archname=darwin-thread-multi-2level
uname='darwin neige.apple.com 10.0 darwin kernel version 10.0.0d8: tue may 5 19:29:59 pdt 2009; root:xnu-1437.2~2release_i386 i386 '
config_args='-ds -e -Dprefix=/usr -Dccflags=-g -pipe -Dldflags= -Dman3ext=3pm -Duseithreads -Duseshrplib -Dinc_version_list=none -Dcc=gcc-4.2'
hint=recommended, useposix=true, d_sigaction=define
useithreads=define, usemultiplicity=define
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc-4.2', ccflags ='-arch x86_64 -arch i386 -arch ppc -g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -I/usr/local/include',
optimize='-Os',
cppflags='-g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -I/usr/local/include'
ccversion='', gccversion='4.2.1 (Apple Inc. build 5646)', gccosandvers=''
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='gcc-4.2 -mmacosx-version-min=10.6', ldflags ='-arch x86_64 -arch i386 -arch ppc -L/usr/local/lib'
libpth=/usr/local/lib /usr/lib
libs=-ldbm -ldl -lm -lutil -lc
perllibs=-ldl -lm -lutil -lc
libc=/usr/lib/libc.dylib, so=dylib, useshrplib=true, libperl=libperl.dylib
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags='-arch x86_64 -arch i386 -arch ppc -bundle -undefined dynamic_lookup -L/usr/local/lib'


Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV
PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP USE_64_BIT_ALL
USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES
USE_PERLIO USE_REENTRANT_API
Locally applied patches:
/Library/Perl/Updates/<version> comes before system perl directories
installprivlib and installarchlib points to the Updates directory
Built under darwin
Compiled at Jun 24 2009 00:35:27
@INC:
/Library/Perl/Updates/5.10.0
/System/Library/Perl/5.10.0/darwin-thread-multi-2level
/System/Library/Perl/5.10.0
/Library/Perl/5.10.0/darwin-thread-multi-2level
/Library/Perl/5.10.0
/Network/Library/Perl/5.10.0/darwin-thread-multi-2level
/Network/Library/Perl/5.10.0
/Network/Library/Perl
/System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level
/System/Library/Perl/Extras/5.10.0
.
ceo09320:bin root#

Matt

22-06-2012 14:10:16

First off, thank you very much for the extremely detailed description of the problem! Makes my life much easier! :)

So far this has not been a reported issue, and I'm surprised it has not caused more people issues (including myself). Yes, github does require an account for posting issues but thats a good thing because then you can help out with the many other projects hosted on github so I would encourage you to go ahead and set up an account there. Anyway..........

The issue with the regular expression syntax for testing and breaking down the URL is certainly one that needed fixing. I found another issue with it related to defining a port number.

I ended up finding a much better regex definition so I have updated the code to reflect those changes. Here is the DIFF: https://github.com/opennetadmin/dcm/com ... 60f#dcm.pl

You can download the zip/tarball from github or just use the diff to patch your own. It should fix the issues.

The SSL thing does seem to be specific to something on the MAC.. I get the same message. I don't see any obvious fix for it at the moment, but I've not dug very deep on that one.