/[smecontribs]/rpms/smeserver-dhcpmanager/contribs10/smeserver-dhcpmanager-2.0.4-Yet-more-changes-for-SM2-panels.patch
ViewVC logotype

Diff of /rpms/smeserver-dhcpmanager/contribs10/smeserver-dhcpmanager-2.0.4-Yet-more-changes-for-SM2-panels.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

Revision 1.5 by brianr, Sat Jan 20 17:11:30 2024 UTC Revision 1.8 by brianr, Tue Jan 23 10:54:38 2024 UTC
# Line 1  Line 1 
1  diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm  diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm
2  --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm     2023-12-19 09:44:56.678590486 +0000  --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm     2023-12-19 09:44:56.678590486 +0000
3  +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm 2024-01-20 17:01:00.000000000 +0000  +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm 2024-01-23 10:14:00.000000000 +0000
4  @@ -140,12 +140,12 @@  @@ -140,12 +140,12 @@
5          my $c = shift;          my $c = shift;
6       my $title = $c->l("dhcpd_SCANNING_NETWORK_TITLE");       my $title = $c->l("dhcpd_SCANNING_NETWORK_TITLE");
# Line 31  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 31  diff -urN smeserver-dhcpmanager-2.0.4.ol
31       return ;       return ;
32   }   }
33    
34  @@ -352,17 +352,17 @@  @@ -350,19 +350,19 @@
35         # delete it
36         # If deletion not ok return message
37       # else return "ok"       # else return "ok"
38       my $ret = delete_lease($c);  -    my $ret = delete_lease($c);
39    +    my $ret = delete_one_lease($c);
40          if ($ret == 'ok') {          if ($ret == 'ok') {
41  -               dhcp_data{"success"}="dhcpd_SUCCESSFULLY_SAVED_SETTINGS";  -               dhcp_data{"success"}="dhcpd_SUCCESSFULLY_SAVED_SETTINGS";
42  +               $dhcp_data{"success"}="dhcpd_SUCCESSFULLY_SAVED_SETTINGS";  +               $dhcp_data{"success"}="dhcpd_SUCCESSFULLY_SAVED_SETTINGS";
# Line 68  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 71  diff -urN smeserver-dhcpmanager-2.0.4.ol
71       return "ok";       return "ok";
72   }   }
73    
74  @@ -391,6 +391,118 @@  @@ -391,6 +391,171 @@
75       return @leases;       return @leases;
76   }   }
77    
# Line 93  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 96  diff -urN smeserver-dhcpmanager-2.0.4.ol
96  +    ###Pull CGI object from parameters array  +    ###Pull CGI object from parameters array
97  +    my $c = shift;  +    my $c = shift;
98  +  +
99    +#my $fred = 1/0;
100    +
101  +    ###Pull entry to delete  +    ###Pull entry to delete
102  +    my $ip = $c->param('host');  +    my $ip = $c->param('ip');
103  +    my $name = $c->param('name');  +    my $name = $c->param('name');
104  +       my $name_in_file = '/var/lib/dhcpd/dhcpd.leases'  ;  +       my $name_in_file = '/var/lib/dhcpd/dhcpd.leases'  ;
105  +       my $name_tmp_file = '/var/lib/dhcpd/dhcpd.leases.tmp'  ;  +       my $name_tmp_file = '/var/lib/dhcpd/dhcpd.leases.tmp'  ;
# Line 144  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 149  diff -urN smeserver-dhcpmanager-2.0.4.ol
149  +      $binoct = dec2bin($_);  +      $binoct = dec2bin($_);
150  +      $binmask = $binmask . substr $binoct, -8;  +      $binmask = $binmask . substr $binoct, -8;
151  +    }  +    }
152  +  +
153  +    # let's count the 1s  +    # let's count the 1s
154  +    @bits = split (//,$binmask);  +    @bits = split (//,$binmask);
155  +    foreach (@bits) {  +    foreach (@bits) {
# Line 152  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 157  diff -urN smeserver-dhcpmanager-2.0.4.ol
157  +        $bitcount++;  +        $bitcount++;
158  +      }  +      }
159  +    }  +    }
 +  
160  +    my $cidr = $network . "/" . $bitcount;  +    my $cidr = $network . "/" . $bitcount;
161  +    return $cidr;  +    return $cidr;
162  +}  +}
163  +  +
164    +sub get_mac_address {
165    +       # From the leases file
166    +    my ($ip, $file) = @_;
167    +    open(my $fh, '<', $file) or die "Could not open file '$file' $!";
168    +    my $mac_address = undef;
169    +    my $lease_block;
170    +    while(my $line = <$fh>) {
171    +        if($line =~ /lease $ip {/ .. $line =~ /}/) {
172    +            $lease_block .= $line;
173    +            if($line =~ /}/) {
174    +                if($lease_block =~ /hardware ethernet (\S+);/) {
175    +                    $mac_address = $1;
176    +                    last;
177    +                } else {
178    +                    $lease_block = '';
179    +                }
180    +            }
181    +        }
182    +    }
183    +    close $fh;
184    +    return $mac_address;
185    +}
186    +
187    +sub  trim { my $s = shift; $s =~ s/^\s+|\s+$//g; return $s };
188    +
189    +sub get_mac_address_by_ping {
190    +    my ($ip) = trim(@_);
191    +    # Ping the IP to ensure it's in the ARP table
192    +    my $ping_result = `ping -c 1 -W 1 $ip`;
193    +    #return $ping_result;
194    +    if($ping_result =~ m/1 packets transmitted, 1 received/) {
195    +        # Fetch the ARP table and find the line with the IP address
196    +        my $mac_result = `nmap -PR -sn $ip`;
197    +        #return "*$arp_result *$ip*";
198    +        # If found, return the MAC address
199    +        #if ($arp_result =~ m/.*at ((?:[0-9a-f]{2}\:){5}[0-9a-f]{2})/) {
200    +               if ($mac_result =~ /MAC Address: (..:..:..:..:..:..) /) {
201    +            return $1;
202    +        } else { return "mac not in nmap result";}
203    +    } else { return "no ping";}
204    +    return undef;
205    +}
206    +
207    +
208    +
209  +sub Scan_Local_Network ($) {            +sub Scan_Local_Network ($) {          
210  +      +  
211  +        my $nmap_sme = esmith::ConfigDB->open('/home/e-smith/db/configuration');  +        my $nmap_sme = esmith::ConfigDB->open('/home/e-smith/db/configuration');
212  +        my $mask = $nmap_sme->get_value('LocalNetmask');  +        my $mask = $nmap_sme->get_value('LocalNetmask');
213  +        my $network = $nmap_sme->get_prop('InternalInterface','Network');  +        my $network = $nmap_sme->get_prop('InternalInterface','Network');
# Line 173  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 222  diff -urN smeserver-dhcpmanager-2.0.4.ol
222  +                               /bin/sed -e 's/Nmap//g'|/bin/sed -e 's/|/  /g'`;  +                               /bin/sed -e 's/Nmap//g'|/bin/sed -e 's/|/  /g'`;
223  +        +      
224  +    my @extracted_output;  +    my @extracted_output;
225    +    my $leasefile = "/var/lib/dhcpd/dhcpd.leases";
226  +    foreach my $line (@nmap_output) {  +    foreach my $line (@nmap_output) {
227  +        if ($line =~ m/Scan report for ([\w\.-]+) \(([\d\.\:]+)\)/) {  +        if ($line =~ m/Scan report for ([\w\.-]+) \(([\d\.\:]+)\)/) {
228  +            my %pair = ('Network' => $1, 'ip' => $2);  # $1 => PC Name, $2 => IP Address  +                       my $ip = $2;
229  +            push @extracted_output, \%pair;  +                       my $mac = get_mac_address($ip,$leasefile);
230  +        }  +                       if (!$mac){
231    +                               $mac = get_mac_address_by_ping($ip);
232    +                       }
233    +#                      if (!$mac) {$mac = "unknown";}
234    +                       my %pair = ('Network' => $1, 'ip' => $ip, 'mac' => $mac);  # $1 => PC Name, $2 => IP Address
235    +                       push @extracted_output, \%pair;
236    +       }
237  +    }  +    }
238  +    return \@extracted_output;  +    return \@extracted_output;
239  +}  +}
# Line 187  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 243  diff -urN smeserver-dhcpmanager-2.0.4.ol
243   #=========================================================================   #=========================================================================
244   # Procedure qui charge le dhcpd.conf   # Procedure qui charge le dhcpd.conf
245   # retourne un tableau contenant les informations   # retourne un tableau contenant les informations
246  @@ -536,4 +648,4 @@  @@ -536,4 +701,4 @@
247    
248   1;   1;
249    
# Line 381  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 437  diff -urN smeserver-dhcpmanager-2.0.4.ol
437  +1;  +1;
438  diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep  diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep
439  --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep     2023-12-19 09:44:56.681590497 +0000  --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep     2023-12-19 09:44:56.681590497 +0000
440  +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep 2024-01-20 11:29:00.000000000 +0000  +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep 2024-01-23 10:12:00.000000000 +0000
441  @@ -1,17 +1,17 @@  @@ -1,17 +1,17 @@
442   <div id='dhcpd-leases'>   <div id='dhcpd-leases'>
443          <table><tr><td>          <table><tr><td>
# Line 429  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 485  diff -urN smeserver-dhcpmanager-2.0.4.ol
485           % foreach my $ip (@$leases) {           % foreach my $ip (@$leases) {
486           <tr>           <tr>
487                          %= t td => (class => 'sme-border') => $ip->{ip}                          %= t td => (class => 'sme-border') => $ip->{ip}
488  @@ -66,9 +68,12 @@  @@ -65,9 +67,7 @@
489                            %= t td => (class => 'sme-border') => $ip->{end}
490                          %= t td => (class => 'sme-border') => $ip->{mac}                          %= t td => (class => 'sme-border') => $ip->{mac}
491                          <td class = 'sme-border'>                                        <td class = 'sme-border'>              
492                                  <a href="/smanager/dhcpd6?trt=DEL&ip=<%= $ip->{ip}%>" onclick="Remove_lease_confirm(event,'<%=$c->l('dhcpd_REMOVE_A_DHCP_LEASE_ACTION')%>',this);"><center><%=l 'dhcpd_REMOVE'%></center></a>  -                               <a href="/smanager/dhcpd6?trt=DEL&ip=<%= $ip->{ip}%>" onclick="Remove_lease_confirm(event,'<%=$c->l('dhcpd_REMOVE_A_DHCP_LEASE_ACTION')%>',this);"><center><%=l 'dhcpd_REMOVE'%></center></a>
493  -                       </td><td class = 'sme-border'>  -                       </td><td class = 'sme-border'>
494  +                       </td>  -                               <a href="/smanager/dhcpd8?trt=WIN&ip=<%= $ip->{ip}%>" onclick="Winpop_confirm(event,'<%=$c->l('dhcpd_SENDING_A_WINPOPUP')%>',this);"><center><%=l 'dhcpd_WINPOPUP_ACTION'%></center></a>
495  +                       <!--  +                               <a href="/smanager/dhcpd6?trt=DEL&ip=<%= $ip->{ip}%>&name=<%= $ip->{name}%>" onclick="Remove_lease_confirm(event,'<%=$c->l('dhcpd_REMOVE_A_DHCP_LEASE_ACTION')%>',this);"><center><%=l 'dhcpd_REMOVE'%></center></a>
 +                       <td class = 'sme-border'>  
                                 <a href="/smanager/dhcpd8?trt=WIN&ip=<%= $ip->{ip}%>" onclick="Winpop_confirm(event,'<%=$c->l('dhcpd_SENDING_A_WINPOPUP')%>',this);"><center><%=l 'dhcpd_WINPOPUP_ACTION'%></center></a>  
496                          </td>                          </td>
 +                       -->  
497                  </tr>                  </tr>
498                  %}                  %}
499                  </tbody>  @@ -102,7 +102,7 @@
500  @@ -110,4 +115,4 @@                  function Remove_lease_confirm(event,msg,current){
501                            const getIP = /.*ip\=(.*)/;
502                            var IP = current.href.match(getIP)[1];
503    -                       if (prompt(msg+" IP: "+IP))
504    +                       if (confirm(msg+" IP: "+IP))
505                            { return true;}
506                            else {event.preventDefault();return false;}
507                    }
508    @@ -110,4 +110,4 @@
509          %end          %end
510    
511    
# Line 452  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 514  diff -urN smeserver-dhcpmanager-2.0.4.ol
514  +</div>  +</div>
515  diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep  diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep
516  --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep       1970-01-01 01:00:00.000000000 +0100  --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep       1970-01-01 01:00:00.000000000 +0100
517  +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep   2024-01-20 17:08:00.000000000 +0000  +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep   2024-01-20 17:30:00.000000000 +0000
518  @@ -0,0 +1,58 @@  @@ -0,0 +1,63 @@
519  +<div id='dhcpd-scan'>  +<div id='dhcpd-scan'>
520  +       <table><tr><td>  +       <table><tr><td>
521  +       %= button_to $c->l('dhcpd_REFRESH') => '/dhcpd3', onclick=>"showSpinnerNetwork1()", id=>"scanNetwork1"  +       %= button_to $c->l('dhcpd_REFRESH') => '/dhcpd3', onclick=>"showSpinnerNetwork1()", id=>"scanNetwork1"
# Line 474  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 536  diff -urN smeserver-dhcpmanager-2.0.4.ol
536  +                       <th class='sme-border'>  +                       <th class='sme-border'>
537  +                               %=l 'dhcpd_IP'  +                               %=l 'dhcpd_IP'
538  +                       </th>  +                       </th>
539    +                       <th class='sme-border'>
540    +                               %=l 'dhcpd_MAC_ADDRESS'
541    +                       </th>
542    +
543  +               </tr>  +               </tr>
544  +               </thead>  +               </thead>
545  +               <tbody>  +               <tbody>
# Line 481  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 547  diff -urN smeserver-dhcpmanager-2.0.4.ol
547  +        <tr>  +        <tr>
548  +                       %= t td => (class => 'sme-border') => $ip->{Network}  +                       %= t td => (class => 'sme-border') => $ip->{Network}
549  +                       %= t td => (class => 'sme-border') => $ip->{ip}  +                       %= t td => (class => 'sme-border') => $ip->{ip}
550    +                       %= t td => (class => 'sme-border') => $ip->{mac}
551  +               </tr>  +               </tr>
552  +               %}  +               %}
553  +               </tbody>  +               </tbody>


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed