diff options
-rwxr-xr-x | dhcp_wizard/Dhcp.pm | 67 | ||||
-rwxr-xr-x | nfs_wizard/NFS.pm | 16 |
2 files changed, 51 insertions, 32 deletions
diff --git a/dhcp_wizard/Dhcp.pm b/dhcp_wizard/Dhcp.pm index 122a389c..e2066353 100755 --- a/dhcp_wizard/Dhcp.pm +++ b/dhcp_wizard/Dhcp.pm @@ -66,14 +66,14 @@ $o->{pages} = { $o->{var}{ip1} ||= compute_range(); $o->{var}{ip2} ||= compute_range2(); }, - post => \&check, data => [ { label => N("Lowest IP address:"), val => \$o->{var}{ip1} }, { label => N("Highest IP address:"), val => \$o->{var}{ip2} }, { label => N("Gateway IP address:"), val => \$o->{var}{gateway} }, { label => N("Enable PXE:"), type => 'bool', val => \$o->{var}{pxe} }, ], - next => 'summary' + complete => \&check, + post => sub { return keys %{$wiz->{net}{itf}} > 1 ? 'interface' : 'summary' }, }, interface => { name => N("Interface the dhcp server must listen to"), @@ -90,21 +90,11 @@ $o->{pages} = { ignore => 1, next => 'ip_range' }, - ip_range_error => { - name => N("Error") . "\n\n" . N("The IP range specified is not correct."), - ignore => 1, - next => 'ip_range' - }, ip_range_warning => { name => N("Warning") . "\n\n" . N("The IP range specified is not in server address range."), ignore => 1, next => 'summary' }, - server_in_range => { - name => N("Error") . "\n\n" . N("The IP of the server must not be in range."), - ignore => 1, - next => 'ip_range' - }, summary => { name => N("Configuring the DHCP server") . "\n\n" . N("The wizard collected the following parameters needed to configure your DHCP service:"), pre => sub { @@ -153,23 +143,56 @@ sub compute_range2 { sub check { my $check_ip = sub { return $_[0] < 0 || $_[0] > 255 ? 0 : 1 }; my $r1_trunc = "$1.$2.$3" if $o->{var}{ip1} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; - foreach ($1, $2, $3, $4) { $check_ip->($_) or return 'ip_range_error' } + foreach ($1, $2, $3, $4) { + if (!$check_ip->($_)) { + $::in->ask_warn(N("Error"), N("The IP specified is not correct: %s", $o->{var}{ip1})); + return 1; + } + } my $r2_trunc = "$1.$2.$3" if $o->{var}{ip2} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; - foreach ($1, $2, $3, $4) { $check_ip->($_) or return 'ip_range_error' } + foreach ($1, $2, $3, $4) { + if (!$check_ip->($_)) { + $::in->ask_warn(N("Error"), N("The IP specified is not correct: %s", $o->{var}{ip2})); + return 1; + } + } my $d1 = $4 if $o->{var}{ip1} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; my $d2 = $4 if $o->{var}{ip2} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; my $s_trunc = "$1.$2.$3" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; my $ds = $4 if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; - if (!$r1_trunc) { standalone::explanations("DHCP wizard : incorrect adress range 1"); return 'ip_range_error' } - if (!$r2_trunc) { standalone::explanations("DHCP wizard : incorrect adress range 2"); return 'ip_range_error' } + if (!$r1_trunc) { + standalone::explanations("DHCP wizard : incorrect adress range 1"); + return 1; + } + if (!$r2_trunc) { + standalone::explanations("DHCP wizard : incorrect adress range 2"); + $::in->ask_warn(N("Error"), N("The IP specified is not correct: %s", $o->{var}{ip2})); + ip_range_error($r2_trunc); + return 1; + } if ($r1_trunc ne $s_trunc || $r2_trunc ne $s_trunc) { - standalone::explanations("DHCP wizard : range not in network"); - return 'ip_range_warning'; + standalone::explanations("DHCP wizard : range not in network"); + $::in->ask_warn(N("Error"), N("The IP range specified is not correct since it's not in the network")); + return 1; + } + if (!$d1 || !$d2) { + standalone::explanations("DHCP wizard : bad range"); + $::in->ask_warn(N("Error"), N("The IP range specified is not correct")); + return 1; + } + if ($d1 > $d2) { + standalone::explanations("DHCP wizard : bad range"); + $::in->ask_warn(N("Error"), N("The IP range specified is not correct: the end IP is below the first IP")); + return 1; + } + if ($ds >= $d1 && $ds <= $d2) { + standalone::explanations("DHCP wizard : server in range"); + $::in->ask_warn(N("Error"), N("The IP range specified is not correct since the server IP is in: +%s is included in %s-%s whereas the IP of the server must not be in range.", + $wiz_ip_server, $o->{var}{ip1}, $o->{var}{ip2})); + return 1; } - if (!$d1 || !$d2 || $d1 > $d2) { standalone::explanations("DHCP wizard : bad range"); return 'ip_range_error' } - if ($ds >= $d1 && $ds <= $d2) { standalone::explanations("DHCP wizard : server in range"); return 'server_in_range' } - return 'interface' if keys %{$wiz->{net}{itf}} > 1; - 0 + return 0 } sub do_it { diff --git a/nfs_wizard/NFS.pm b/nfs_wizard/NFS.pm index df33d359..bd4072f5 100755 --- a/nfs_wizard/NFS.pm +++ b/nfs_wizard/NFS.pm @@ -54,10 +54,15 @@ $o->{pages} = { }, nfs => { name => N("NFS server") . "\n\n" .N("Directory which will be exported to NFS clients. This directory will be exported in read only mode. It denies any request which requires changes to the filesystem."), - post => \&check, data => [ { label => N("Directory:"), val => \$o->{var}{wiz_nfs_dir} }, ], + complete => sub { + if (! -d $o->{var}{wiz_nfs_dir}) { + $::in->ask_warn(N("Error"), N("The path you entered does not exist.")); + return 1; + } + }, next => 'ask_level' }, ask_level => { @@ -79,11 +84,6 @@ $o->{pages} = { next => 'summary' }, - error_dir => { - name => N("Error.") . "\n\n" . N("The path you entered does not exist."), - ignore => 1, - next => 'nfs' - }, summary => { name => N("The wizard collected the following parameters."), pre => sub { @@ -120,10 +120,6 @@ sub new { }, $class; } -sub check { - -d $o->{var}{wiz_nfs_dir} or return 'error_dir' -} - sub network_mask { my $wiz_ip_server = $wiz->{net}->itf_get("IPADDR"); my $mask = $wiz->{net}->itf_get("NETMASK"); |