[Netpass-devel] NetPass/lib NetPass.pm,1.18,1.19 RUNONCE.pm,1.1.1.1,1.2
Brought to you by:
jeffmurphy
From: jeff m. <jef...@us...> - 2005-08-04 20:41:26
|
Update of /cvsroot/netpass/NetPass/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10393/lib Modified Files: NetPass.pm RUNONCE.pm Log Message: bug fixes to npsvc watcher, added some additional client logging Index: RUNONCE.pm =================================================================== RCS file: /cvsroot/netpass/NetPass/lib/RUNONCE.pm,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- RUNONCE.pm 24 Sep 2004 01:05:20 -0000 1.1.1.1 +++ RUNONCE.pm 4 Aug 2005 20:41:18 -0000 1.2 @@ -10,6 +10,9 @@ # to read them. # # $Log$ +# Revision 1.2 2005/08/04 20:41:18 jeffmurphy +# bug fixes to npsvc watcher, added some additional client logging +# # Revision 1.1.1.1 2004/09/24 01:05:20 jeffmurphy # Initial import. # @@ -28,6 +31,7 @@ use Fcntl; my $listen = undef; $RUNONCE::VERSION = "1.0"; +$RUNONCE::SANITY = 1; sub D { 0; } @@ -56,13 +60,15 @@ sub alreadyRunning { my ($ps, $rt, $lq) = (shift, shift, shift); + my $psO = $ps; + if(defined($ps)) { if($ps !~ /^\d+$/) { my $portNum = getservbyname($ps, 'tcp'); if(!defined($portNum)) { die "$$ RUNONCE::alreadyRunning() : unknown port <$ps>"; } - $portNum = $ps; + $ps = $portNum; } } else { @@ -81,7 +87,7 @@ print "\n\n$$ alreadyRunning try #$i\n" if &RUNONCE::D; - $pid = RUNONCE::alreadyRunning2($ps, $lq); + $pid = RUNONCE::alreadyRunning2($ps, $lq, $psO); print "\n$$ alreadyRunning2 returned $pid\n" if &RUNONCE::D; return $pid if($pid != -1); @@ -90,8 +96,8 @@ return $pid; } -sub alreadyRunning2($$) { - my ($ps, $lq) = (shift, shift); +sub alreadyRunning2($$$) { + my ($ps, $lq, $psO) = (shift, shift, shift); my $mn = $0; if($mn =~ /([^\/]+)$/) { $mn = $1; @@ -124,7 +130,7 @@ if(defined($c)) { print "$$ reading from remote\n" if &RUNONCE::D; my $l = $c->getline(); - print "$$ read ", length($l), " from remote\n" if &RUNONCE::D; + print "$$ read ", (defined($l)?length($l):"UNDEF"), " from remote\n" if &RUNONCE::D; if(!defined($l)) { # remote end closed cnx on us @@ -134,8 +140,10 @@ } chomp($l); - print "$$ remote sent \"$l\"\n" - if &RUNONCE::D; + if (&RUNONCE::D) { + print qq{$$ remote sent "$l" (expecting /^$psO/)\n} if !$RUNONCE::SANITY; + print qq{$$ remote sent "$l" (expecting "$mn")\n} if $RUNONCE::SANITY; + } if($l =~ /(\d+)\s(.*)/) { $remoteName = $2; @@ -146,8 +154,12 @@ # basename. this is a sanity check and # we punt if it fails. - if($remoteName ne $mn) { - warn "$$ remoteName isnt what i expected.\nexpected=\"$mn\" got=\"$remoteName\""; + if($RUNONCE::SANITY && ($remoteName ne $mn)) { + warn qq{$$ remoteName isnt what i expected.\nexpected="$mn" got="$remoteName" (sanity on)}; + return -1; + } + elsif (!$RUNONCE::SANITY && ($remoteName !~ /^$psO/)) { + warn qq{$$ remoteName isnt what i expected.\nexpected=/^$psO/ got="$remoteName" (sanity off)}; return -1; } } else { Index: NetPass.pm =================================================================== RCS file: /cvsroot/netpass/NetPass/lib/NetPass.pm,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- NetPass.pm 8 May 2005 02:35:45 -0000 1.18 +++ NetPass.pm 4 Aug 2005 20:41:17 -0000 1.19 @@ -716,6 +716,7 @@ } _log "DEBUG", "$mac $ip could not find us on the network!\n"; + $self->db->audit(-mac => $mac, -ip => $ip, -msg => [ "could not find us on the network! is our switch/port configured?" ]); return (undef, undef, undef, undef); } |