From: Robert Lowe (Robert.H.Lowe@lawrence.edu)
Date: Fri Sep 05 2003 - 14:51:15 CDT
Well, after looking this over, I think I'll make a few changes. First,
from register.cgi ...
- unless ($alive) {
+ unless ($alive ge 0) {
The 'ge' operator is for strings, and I'm guessing the imap->login()
function really returns an int. Which makes me wonder what is really
fixed. What return value is failing the test that shouldn't be?
Regarding the admin.cgi patch: the kit I'm about to release removes
all kinds of 'bad' characters from usernames, and incorporates a
modified version of the recent fix by John Crowley for dropping domain
names that might have been entered with the username (there is also a
note for Robert Morse of Brown, and anyone else that is unlucky enough
to have usernames with apostrophes, which will require a slight adjustment
and a bit more code elsewhere). I'm thinking I'll leave you to your own
devices if you want to have usernames with periods embedded in them.
The other small regexp changes I can easily add. I'll let the group
weigh in the client hostname search.
-Robert
Jason Rust wrote:
> I've attached two patches which were made against register.cgi and
> admin.cgi from the netreg-cidr.tar.gz archive.
>
> The register.patch fixes the IMAP bug where a user can't log in if they
> have no messages in their inbox and it fixes a bug where a user with a
> period in their username would break dhcpd (i.e. ddns-hostname foo.bar;
> is invalid)
>
> The admin.patch adds the ability to search by computer hostname which is
> very useful on our network since many of our technicians know a computer's
> hostname, but not necessarily their MAC or IP. Note that not all
> computers have the client-hostname entry in dhcpd.leases since some
> computers don't send that information out.
>
> -Jason
>
>
>
> ------------------------------------------------------------------------
>
> --- admin.cgi Thu Aug 22 10:23:36 2002
> +++ /home/vhosts/netreg/cgi-bin/admin/admin.cgi Thu Sep 4 14:09:32 2003
> @@ -224,6 +224,13 @@
> if (/lease ([0-9\.]+).*starts \d+ ([0-9\/: ]+);.*ends \d+ ([0-9\/: ]+);.* binding state (\w+).*hardware ethernet ([0-9A-Fa-f:]+);/s) {
> $testquery = join '#', $1,$5,$2,$3,$4;
> $lease_IP = $1;
> + if (/client-hostname "(.*?)"/s) {
> + $testquery .= '#' . $1;
> + }
> + else {
> + $testquery .= '#' . 'Hostname Not Found';
> + }
> +
> if ($testquery =~ /$FORM{'query'}/i) {
> $key = sprintf( "%d\.%03d\.%03d\.%03d", split(/\./, $lease_IP) );
> $lease_info{$key} = $testquery;
> @@ -240,27 +247,30 @@
> print "<tr><td><img src=$GFX/reddot.gif align=top></td><td>= Active Lease</td></tr></table>";
> print "<P><TABLE CELLPADDING=10>";
> print "<TR><TH></TH><TH>MAC Address</TH><TH>IP Address</TH>";
> + print "<TH>Hostname</TH>";
> print "<TH>Obtained (GMT)</TH><TH>Expires (GMT)</TH></TR>\n";
>
> my $CNT = 0;
> my $ACNT = 0;
> @sortedIP = sort keys(%lease_info);
> foreach $key (@sortedIP) {
> - ($IP,$MAC,$TIMESTART,$TIMEEND,$BINDSTATE) = split /#/, $lease_info{$key};
> + ($IP,$MAC,$TIMESTART,$TIMEEND,$BINDSTATE,$HOSTNAME) = split /#/, $lease_info{$key};
> $MAC=uc($MAC);
> $color = get_color($color);
> print "<tr><td align=center><A HREF=$ADMINPATH/admin.cgi";
> print "\?action=FC\&query=$MAC>";
> print "<img src=/gfx/netreg-user.gif border=0></a></td>";
> - $MAC =~ s/$FORM{'query'}/<b>$FORM{'query'}<\/b>/g;
> - $IP =~ s/$FORM{'query'}/<b>$FORM{'query'}<\/b>/g;
> - $TIMESTART =~ s/$FORM{'query'}/<b>$FORM{'query'}<\/b>/g;
> - $TIMEEND =~ s/$FORM{'query'}/<b>$FORM{'query'}<\/b>/g;
> + $MAC =~ s/($FORM{'query'})/<b>$1<\/b>/gi;
> + $IP =~ s/($FORM{'query'})/<b>$1<\/b>/gi;
> + $TIMESTART =~ s/($FORM{'query'})/<b>$1<\/b>/gi;
> + $TIMEEND =~ s/($FORM{'query'})/<b>$1<\/b>/gi;
> + $HOSTNAME =~ s/($FORM{'query'})/<b>$1<\/b>/gi;
> print "<td bgcolor=$color>$MAC</td><td bgcolor=$color>$IP ";
> if ($BINDSTATE eq "active") {
> print "<img src=$GFX/reddot.gif border=0>";
> }
> print "</td>";
> + print "<td bgcolor=$color>$HOSTNAME</td>";
> print "<td bgcolor=$color>$TIMESTART</td>";
> print "<td bgcolor=$color>$TIMEEND</td></tr>\n";
> $CNT++;
> @@ -282,7 +292,7 @@
> my $action = shift(@_);
> if ($action eq "FL") {
> print "<font size=4>Search Leases</font><br>";
> - print "<font size=2>(IP, MAC, Lease Start, Lease End)</font><P>";
> + print "<font size=2>(IP, MAC, Hostname, Lease Start, Lease End)</font><P>";
> }
> else {
> print "<font size=4>Search Registration Database</font><br>";
>
>
> ------------------------------------------------------------------------
>
> --- register.cgi Mon Aug 19 12:00:45 2002
> +++ register.cgi.new Fri Sep 5 10:54:17 2003
> @@ -115,7 +115,7 @@
> $imap = new Net::IMAP::Simple( "$IMAPSERVER" );
> $alive = $imap->login( $FORM{'user'}, $FORM{'pass'} );
> $imap->quit();
> - unless ($alive) {
> + unless ($alive ge 0) {
> error("Authentication Failed");
> }
> } else {
> @@ -197,7 +197,7 @@
> # Add DHCP option to use derived name in DDNS updates, if desired
> if ($DDNS_USE_HOST_DECL) {
>
> - print DHCPDCONFNEW "ddns-hostname $FORM{'user'}-$SERIAL;";
> + print DHCPDCONFNEW "ddns-hostname \"$FORM{'user'}-$SERIAL\";";
> }
>
> print DHCPDCONFNEW "}\#$ENV{'HTTP_USER_AGENT'}";
**********************************************************************
To unsubscribe from this list, send an e-mail message to
majordomo@southwestern.edu containing a single line with the words:
unsubscribe netreg
Send requests for assistance to: owner-netreg@southwestern.edu
**********************************************************************
This archive was generated by hypermail 2.1.4 : Thu Aug 12 2004 - 12:01:40 CDT