record all dhcp request options in audit log
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 19 Aug 2009 10:56:04 +0000 (10:56 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 19 Aug 2009 10:56:04 +0000 (10:56 +0000)
lib/PXElator/dhcpd.pm

index 809913a..279aee2 100644 (file)
@@ -95,17 +95,24 @@ sub process_packet {
        return unless $buf;
 
        my $dhcp = Net::DHCP::Packet->new($buf);
-       $dhcp->comment( $transaction++ );
 
        warn "recv: ", $dhcp->toString if $debug;
 
+       $dhcp->comment( $transaction++ );
+
        my $mac = substr($dhcp->chaddr(),0,$dhcp->hlen()*2);
        my $ip = client_mac_ip($mac, $dhcp->ciaddr);
 
        my $hostname = $dhcp->getOptionValue(DHO_HOST_NAME);
        print "$ip ", client::conf( $ip => 'hostname', default => $hostname ), " >> /etc/hosts\n";
 
-       my $audit = { mac => format::mac($mac), ip => $ip, hostname => $hostname };
+       my $audit = { mac => format::mac($mac), ip => $ip, hostname => $hostname,
+               options => {
+                       map {
+                               ( $_ => $dhcp->getOptionValue( $_ ) )
+                       } @{ $dhcp->{options_order} }
+               },
+       };
 
 =for later