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

Annotation 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


Revision 1.1 - (hide annotations) (download)
Sat Dec 30 15:47:19 2023 UTC (4 months, 2 weeks ago) by brianr
Branch: MAIN
* Sat Dec 30 2023 Brian Read <brianr@koozali.org> 2.0.4-15.sme
- And more fixes for SM2 panels [SME: ]

1 brianr 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
2     --- 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 2023-12-30 15:31:00.000000000 +0000
4     @@ -117,22 +117,41 @@
5     $c->render( template => 'dhcpd' );
6     }
7    
8     -
9     -sub do_winpopup {
10     - #
11     - # call to win pop up
12     - #
13     +sub netmask2cidr {
14     my $c = shift;
15     - my $title = $c->l("dhcpd_GLOBAL_WINPOPUP");
16     - my $modul = '';
17     - my $trt = "WINPOPUP";
18     - $dhcp_data{trt} = $trt;
19     - $dhcp_data{"first"} = '';
20     - #..... get winpopup details
21     - $c->stash( title => $title, modul => $modul, dhcp_data => \%dhcp_data );
22     - $c->render( template => 'dhcpd' );
23     + #my ($mask, $network) = @_;
24     + my $nmap_sme = esmith::ConfigDB->open('/home/e-smith/db/configuration');
25     + my $mask = $nmap_sme->get_value('LocalNetmask');
26     + my $network = $nmap_sme->get_prop('InternalInterface','Network');
27     + my @octet = split (/\./, $mask);
28     + my @bits;
29     + my $binmask;
30     + my $binoct;
31     + my $bitcount=0;
32     +
33     + foreach (@octet) {
34     + $binoct = dec2bin($_);
35     + $binmask = $binmask . substr $binoct, -8;
36     + }
37     +
38     + # let's count the 1s
39     + @bits = split (//,$binmask);
40     + foreach (@bits) {
41     + if ($_ eq "1") {
42     + $bitcount++;
43     + }
44     + }
45     +
46     + my $cidr = $network . "/" . $bitcount;
47     + return $cidr;
48     +}
49     +
50     +sub dec2bin {
51     + my $str = unpack("B32", pack("N", shift));
52     + return $str;
53     }
54    
55     +
56     sub do_scan {
57     #
58     # call to show scan results
59     @@ -140,12 +159,13 @@
60     my $c = shift;
61     my $title = $c->l("dhcpd_SCANNING_NETWORK_TITLE");
62     my $modul = '';
63     - my $trt = "NETSCAN";
64     + my $trt = "SCAN";
65     $dhcp_data{trt} = $trt;
66     $dhcp_data{"first"} = '';
67     # ..... get scan results into dhcp_data
68     - dhcp_data{"scanresults"} = get_scan_results($c);
69     - $c->stash( title => $title, modul => $modul, dhcp_data => \%dhcp_data );
70     + $dhcp_data{"cidr"} = netmask2cidr($c);
71     + my @scanresults = get_scan_results($c);
72     + $c->stash( title => $title, modul => $modul, dhcp_data => \%dhcp_data, scanresults => @scanresults );
73     $c->render( template => 'dhcpd' );
74     }
75    
76     @@ -361,8 +381,30 @@
77    
78     sub get_scan_results {
79     my $c = shift;
80     - #...do it
81     - return "results";
82     + my $cidr = netmask2cidr($c);
83     + my $res = execute_nmap($cidr);
84     + return $res;
85     +}
86     +
87     +sub execute_nmap {
88     + my ($ip, $port) = @_;
89     + my @result;
90     + my $nmapcmd = qq(/usr/bin/nmap --script smb-os-discovery.nse -p U:137,T:139 $ip| \
91     + /bin/grep -Ev "MAC|NetBIOS|OS CPE"| /bin/grep -E "scan|done|Computer|OS"| \
92     + /bin/sed -e 's/Nmap scan/-- Scan/g'|/bin/sed -e 's/done/Done/g'| \
93     + /bin/sed -e 's/Nmap//g'|/bin/sed -e 's/|/ /g');
94     +
95     + open my $nmap, '-|', "$nmapcmd" or die "Can't start nmap: $!";
96     +
97     + while (my $line = <$nmap>) {
98     + chomp $line;
99     + my @fields = split /\s+/, $line;
100     + push @result, \@fields;
101     + }
102     +
103     + close $nmap;
104     +
105     + return \@result;
106     }
107    
108    
109     @@ -498,13 +540,6 @@
110     return @results;
111     }
112    
113     -sub winpopup{
114     - my $c = shift;
115     - # Message in $c->param("winpopupmsg")
116     - # .... do it
117     - return TRUE;
118     -}
119     -
120     sub do_wol{
121     my $c = shift;
122     my $retVal = Perform_Wake_Up($c);
123     @@ -536,4 +571,4 @@
124    
125     1;
126    
127     -
128     \ No newline at end of file
129     +
130     diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Dhcpd/en.pm smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Dhcpd/en.pm
131     --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Dhcpd/en.pm 1970-01-01 01:00:00.000000000 +0100
132     +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Dhcpd/en.pm 2023-12-30 11:30:00.000000000 +0000
133     @@ -0,0 +1,109 @@
134     +package SrvMngr::I18N::Modules::Dhcpd::en;
135     +use strict;
136     +use warnings;
137     +use utf8;
138     +use Mojo::Base 'SrvMngr::I18N';
139     +
140     +use SrvMngr::I18N::Modules::General::en;
141     +
142     +my %lexicon = (
143     + 'dhcpd_ACTION' => 'Action',
144     + 'dhcpd_ACTIVE_DEVICE' => 'Active Device',
145     + 'dhcpd_ALL_OF_THEM' => 'All of them',
146     + 'dhcpd_CHECK_CLIENT_STATUS' => 'Always check the status of computers (Disabled is much faster)',
147     + 'dhcpd_CLEAN_ALL_DHCPLEASES' => 'You may want to clean the dhcpd.leases',
148     + 'dhcpd_CLICK_HERE_TO_MAIN_PANEL' => 'Return to the main panel',
149     + 'dhcpd_CONNECTED_IP' => 'Show DHCP Clients',
150     + 'dhcpd_CUSTOM_DNS_STATUS' => 'Custom DNS',
151     + 'dhcpd_CUSTOM_DNS_TITLE' => 'Enable custom DNS servers.',
152     + 'dhcpd_CUSTOM_GATEWAY_ADDRESS' => 'Gateway address',
153     + 'dhcpd_CUSTOM_GATEWAY_STATUS' => 'Custom gateway',
154     + 'dhcpd_CUSTOM_GATEWAY_TITLE' => 'Enable a custom gateway address.',
155     + 'dhcpd_CUSTOM_LEASETIME' => 'Custom lease time',
156     + 'dhcpd_CUSTOM_LEASETIME_TITLE' => 'Set the lease time (default is 86400 seconds).',
157     + 'dhcpd_CUSTOM_WINSERVER_ADDRESS' => 'WINS Server address',
158     + 'dhcpd_CUSTOM_WINSERVER_STATUS' => 'WINS Server',
159     + 'dhcpd_CUSTOM_WINSERVER_TITLE' => 'Enable a WINS Server.',
160     + 'dhcpd_DHCPD_SETTING_ERRORS' => 'DHCPd Settings ERRORS',
161     + 'dhcpd_DHCPD_SETTINGS_TITLE' => 'DHCP server settings',
162     + 'dhcpd_DHCPD_TITLE' => 'DHCP Manager',
163     + 'dhcpd_DHCP_END' => 'DHCP End',
164     + 'dhcpd_DHCP manager' => 'DHCP Manager',
165     + 'dhcpd_DHCP_RANGE_MUST_NOT_INCLUDE_SERVER_IP' =>'Incorrect range of IPs, the range of IP address allocation must not include the server address, Update unsuccessfull',
166     + 'dhcpd_DHCP_RANGE_WITH_BAD_IP' => 'Incorrect IP in the DHCP range, Update unsuccessfull',
167     + 'dhcpd_DHCP_START' => 'DHCP Start',
168     + 'dhcpd_DHCP_START_GREATER_DHCP_END_ERRORS' =>'Incorrect range of IPs, the DHCP Start is greater than the DHCP End , Update unsuccessfull',
169     + 'dhcpd_DISABLED' => 'Disabled',
170     + 'dhcpd_DNS_SERVER_WITH_BAD_IP' => 'Incorrect IP for DNS servers, Update unsuccessfull',
171     + 'dhcpd_DO_YOU_WANT_TO_SENT' => 'Do you want to send this message to',
172     + 'dhcpd_ENABLED' => 'Enabled',
173     + 'dhcpd_END_DATE' => 'End Date',
174     + 'dhcpd_ERROR_WHILE_REMOVING_ALL_LEASES' => 'Error while removing all dhcpd Leases',
175     + 'dhcpd_ERROR_WHILE_SAVING_SETTINGS' => 'Error while saving settings',
176     + 'dhcpd_GATEWAY_BAD_IP' => 'Incorrect IP for Gateway, Update unsuccessfull',
177     + 'dhcpd_GLOBAL_WINPOPUP' => 'Send Global Netsend WinPopup',
178     + 'dhcpd_GLOBAL_WINPOPUP_TITLE' => 'Send a global WinPopup with the Net send protocol',
179     + 'dhcpd_IP' => 'Ip Address',
180     + 'dhcpd_MAC_ADDRESS' => 'MAC Address',
181     + 'dhcpd_MANAGING_DHCP_CLIENT' => 'Managing DHCP clients',
182     + 'dhcpd_NETWORK_NAME' => 'Network Name',
183     + 'dhcpd_NETWORK_VALUES_FOUND' => 'Please wait .... Your subnet and your netmask appear to be :',
184     + 'dhcpd_NO_CONNECTED_COMPUTERS' => 'There are no connected computers',
185     + 'dhcpd_NOT_CHECKED' => 'Not Checked...',
186     + 'dhcpd_PRIMARY_DNS_ADDRESS' => 'Primary DNS',
187     + 'dhcpd_REFRESH_CONNECTED_IP_LIST' => 'You may want to refresh this list ?',
188     + 'dhcpd_REFRESH' => 'Refresh the list',
189     + 'dhcpd_REMOVE_ACTION' => 'Remove...',
190     + 'dhcpd_REMOVE_A_DHCP_LEASE_ACTION' => 'You are about to remove a client from the dhcpd.leases file.',
191     + 'dhcpd_REMOVE_A_DHCP_LEASE' => 'Remove a DHCP lease',
192     + 'dhcpd_ARE_YOU_SURE' => 'are you sure ?',
193     + 'dhcpd_REMOVE_A_DHCP_LEASE_TITLE' => 'Removing a DHCP Lease',
194     + 'dhcpd_REMOVE_ALL_LEASES_ACTION' => 'Remove all dhcpd leases',
195     + 'dhcpd_REMOVE_ALL_LEASES' => 'Remove all leases',
196     + 'dhcpd_REMOVE_DHCP_LEASE_TITLE' => 'Removing all DHCP Lease',
197     + 'dhcpd_REMOVE_DHCP_LEASE_WARNING' => 'Remove all entries in dhcpd.leases may cause issues',
198     + 'dhcpd_REMOVE' => 'Remove',
199     + 'dhcpd_SAVE/RESTART' => 'Save/Restart',
200     + 'dhcpd_SAVE_TITLE' => 'After changing settings above, you must save and restart dhcpd.',
201     + 'dhcpd_SCANNING_NETWORK_TITLE' => 'Scanning your network, the time needed depends on your subnet mask',
202     + 'dhcpd_SCAN_YOUR_NETWORK' => 'Scan your network',
203     + 'dhcpd_SCAN_YOUR_NETWORK_TITLE' => 'Scan your network to show active devices :',
204     + 'dhcpd_SECONDARY_DNS_ADDRESS' => 'Secondary DNS',
205     + 'dhcpd_SENDING_A_WINPOPUP' => 'Sending a WinPopup',
206     + 'dhcpd_SENDING_A_WINPOPUP_TO' => 'You are about to send a WinPopup to ',
207     + 'dhcpd_SEND_WINPOPUP_TO' => 'Send a WinPopup to',
208     + 'dhcpd_SHOW_CONNECTED_IP_TITLE' => 'Show all devices connected to the dhcpd server :',
209     + 'dhcpd_START_DATE' => 'Start Date',
210     + 'dhcpd_STATUS_CLICK_FOR_WOL' => 'Status - click for WOL',
211     + 'dhcpd_STATUS_DHCP_SERVER' => 'State of DHCPD',
212     + 'dhcpd_STATUS_REPORT' => 'Operation status report :',
213     + 'dhcpd_SUCCESSFULLY_CLIENT_WOL_REQUEST' =>'Successfull request to wake up the client. The computer may take time to wake up.',
214     + 'dhcpd_SUCCESSFULLY_DELETED_THE_CLIENT' => 'Successfully deleted the client in dhcpd.leases : ',
215     + 'dhcpd_SUCCESSFULLY_REMOVED_ALL_LEASES' => 'Successfully deleted all leases.',
216     + 'dhcpd_SUCCESSFULLY_SAVED_SETTINGS' => 'Successfully saved settings',
217     + 'dhcpd_SUCCESSFULLY_SENT_MESSAGE' => 'Successfully sent message popup to',
218     + 'dhcpd_TERTIARY_DNS_ADDRESS' => 'Tertiary DNS',
219     + 'dhcpd_WAKE_UP_ACTION' => '<font color="red">Wake-Up...</font>',
220     + 'dhcpd_WAKE_UP' => 'Wake UP',
221     + 'dhcpd_WAKING_A_REMOTE_COMPUTER_ACTION' => 'Are you sure you want to wake on lan the client : ',
222     + 'dhcpd_WAKING_A_REMOTE_COMPUTER_TITLE' => 'Waking Up a remote computer',
223     + 'dhcpd_WAKING_A_REMOTE_COMPUTER' => 'You are about to wake up a remote computer.',
224     + 'dhcpd_WARNING_NO_WINPOPUP_GARANTY' =>'Warning, there is no guarantee that the popup will appear on the remote computer.',
225     + 'dhcpd_WINPOPUP_ACTION' => 'WinPopup...',
226     + 'dhcpd_WINSSERVER_BAD_IP' => 'Incorrect IP for WINS Server, Update unsuccessfull',
227     + 'dhcpd_WRITE_YOUR_MESSAGE' => 'Write your message here',
228     + 'dhcpd_YOUR_MESSAGE' => 'Your message',
229     + 'dhcpd_REMOVE_DHCP_LEASE_WARNING2' => 'The lease file is a log-structured file - whenever a lease changes, the
230     + contents of that lease are written to the end of the file. This means that it is entirely possible for there to be two
231     + or more declarations of the same lease in the lease file at the same
232     + time. In that case, the instance of that particular lease that
233     + appears last in the file is the one that is in effect.',
234     +);
235     +
236     +our %Lexicon = (
237     + %{ SrvMngr::I18N::Modules::General::en::Lexicon },
238     + %lexicon
239     +);
240     +
241     +
242     +1;
243     diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep
244     --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep 2023-12-19 09:44:56.680590493 +0000
245     +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep 2023-12-30 10:10:00.000000000 +0000
246     @@ -49,10 +49,8 @@
247    
248     % if ($dhcp_data->{trt} eq 'LEASES') {
249     %= include 'partials/_dhcpd_leases'
250     - %} elsif ($dhcp_data->{trt} eq 'WINPOPUP') {
251     - %= include 'partials/_dhcpd_winpopup'
252     %} elsif ($dhcp_data->{trt} eq 'SCAN') {
253     - %= include 'partials/_dhcpd_scan'
254     + %= include 'partials/_dhcpd_scanresults'
255     %} else { #PARAMS
256     % my $ip_regex = '^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$';
257     <table><tr><td>
258     @@ -63,9 +61,12 @@
259     </button>
260     </td><td>
261     %= button_to $c->l('dhcpd_SCAN_YOUR_NETWORK') => '/dhcpd3'
262     - </td><td>
263     - %= button_to $c->l('dhcpd_GLOBAL_WINPOPUP') => '/dhcpd2'
264     + </td>
265     + <!--
266     <td>
267     + %= button_to $c->l('dhcpd_GLOBAL_WINPOPUP') => '/dhcpd2'
268     + </td>
269     + -->
270     </tr>
271     </table>
272     <hr />
273     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
274     --- 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
275     +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep 2023-12-29 15:16:00.000000000 +0000
276     @@ -26,7 +26,7 @@
277     %= submit_button "$btn", class => 'action'
278     % end
279     <br>
280     - <table class="sme-border table-sort"><tbody>
281     + <table class="sme-border table-sort"><thead>
282     <tr>
283     <th class='sme-border'>
284     %=l 'dhcpd_IP'
285     @@ -50,6 +50,8 @@
286     %=l 'dhcpd_ACTION'
287     </th>
288     </tr>
289     + </thead>
290     + <tbody>
291     % foreach my $ip (@$leases) {
292     <tr>
293     %= t td => (class => 'sme-border') => $ip->{ip}
294     @@ -66,9 +68,12 @@
295     %= t td => (class => 'sme-border') => $ip->{mac}
296     <td class = 'sme-border'>
297     <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>
298     - </td><td class = 'sme-border'>
299     + </td>
300     + <!-->
301     + <td class = 'sme-border'>
302     <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>
303     </td>
304     + -->
305     </tr>
306     %}
307     </tbody>
308     @@ -110,4 +115,4 @@
309     %end
310    
311    
312     -</div>
313     \ No newline at end of file
314     +</div>
315     diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scanresults.html.ep smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scanresults.html.ep
316     --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scanresults.html.ep 1970-01-01 01:00:00.000000000 +0100
317     +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scanresults.html.ep 2023-12-30 15:30:00.000000000 +0000
318     @@ -0,0 +1,41 @@
319     +<div id='dhcpd-scanresults'>
320     +%#= 1/0
321     + %= $c->l('dhcpd_NETWORK_VALUES_FOUND').$dhcp_data->{"cidr"};
322     + %= form_for '/dhcpd10' => (method => 'POST') => begin
323     + <br />
324     + <table class="sme-border table-sort"><thead>
325     + <tr>
326     + <th class='sme-border'>
327     + %=l 'dhcpd_NETWORK_NAME'
328     + </th>
329     + <th class='sme-border'>
330     + %=l 'dhcpd_IP'
331     + </th>
332     + <th class='sme-border'>
333     + %=l 'dhcpd_MAC_ADDRESS'
334     + </th>
335     + <th class='sme-border'>
336     + %=l 'dhcpd_STATUS_CLICK_FOR_WOL'
337     + </th>
338     + </tr>
339     + </thead>
340     + <tbody>
341     + % foreach my $line (@$scanresults) {
342     + % my @thisline = @$line;
343     + <tr>
344     + <td class='sme-border'>
345     + %= "$thisline[4]";
346     + </td>
347     + <td class='sme-border'>
348     + %= "$thisline[5]";
349     + </td>
350     + <td class='sme-border'>
351     + </td>
352     + <td class='sme-border'>
353     + </td>
354     + </tr>
355     + %}
356     + </table>
357     + % end
358     + %= button_to $c->l('dhcpd_CLICK_HERE_TO_MAIN_PANEL') => '/dhcpd'
359     +</div>

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