diff options
Diffstat (limited to 'client_wizard')
-rwxr-xr-x | client_wizard/Bind_client.pm | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/client_wizard/Bind_client.pm b/client_wizard/Bind_client.pm index fc7996f3..799d38f7 100755 --- a/client_wizard/Bind_client.pm +++ b/client_wizard/Bind_client.pm @@ -24,6 +24,8 @@ use lib qw(/usr/lib/libDrakX); use strict; use common; +use services; +use MDK::Wizard::Varspaceval; use MDK::Wizard::Wizcommon; my $wiz = new MDK::Wizard::Wizcommon; @@ -32,7 +34,7 @@ my $wiz_domain_name = $wiz->{net}->network_get("DOMAINNAME"); my $o = { name => N('DNS Client Wizard'), - var => { + var => { client_ip => '', client_name => '' }, @@ -53,7 +55,6 @@ $o->{pages} = { $o->{var}{client_ip} = ip(); $o->{var}{client_name} = name(); }, - post => \&check, data => [ { label => N('Name of the machine:'), val => \$o->{var}{client_name} }, { label => N('IP number of the machine:'), val => \$o->{var}{client_ip} }, @@ -107,7 +108,7 @@ sub ip { sub get_root { my $file = "/etc/sysconfig/named"; if (-f $file) { - my %mdk = Vareqval->get($file); + my %mdk = MDK::Wizard::Varspaceval->get($file); return $mdk{ROOTDIR}; } ""; @@ -135,12 +136,12 @@ sub up_serial { } sub test { - !$o->{client_name} and return 1; - !$o->{client_ip} and return 1; + !$o->{client_name} and return 'error'; + !$o->{client_ip} and return 'error'; 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})/; - my $dc = "$4" if $ENV{wiz_client_ip} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; - my $sc_trunc = "$1.$2.$3" if $ENV{wiz_client_ip} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; + my $dc = "$4" if $o->{var}{client_ip} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; + my $sc_trunc = "$1.$2.$3" if $o->{var}{client_ip} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; (!$sc_trunc || !$dc || !$ds || !$s_trunc || ($s_trunc != $sc_trunc) || ($dc == $ds || $dc < 0 || $dc > 255)) and return 'error'; } @@ -151,22 +152,26 @@ sub do_it { my $wiz_ip_net = "$1.$2.$3.0" if $wiz_ip_server =~ /(\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})/; - my $dc = "$4" if $ENV{wiz_client_ip} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; + my $dc = "$4" if $o->{var}{client_ip} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; my $file="/var/named/$wiz_domain_name.db"; MDK::Common::cp_af($file, $file.".orig"); open(NEW, ">> $file") or die "can not open $file"; - print NEW "\n$ENV{wiz_client_name} IN A $ENV{wiz_client_ip} ; $date"; + print NEW "\n$o->{var}{client_name} IN A $o->{var}{client_ip} ; $date\n\n"; close(NEW) or die "can not close $file"; up_serial($file); my $file="/var/named/$s_trunc.rev"; MDK::Common::cp_af($file, $file.".orig"); open(NEW, ">> $file") or die "can not open $file"; - print NEW "\n$dc IN PTR $ENV{wiz_client_name}. ; $date"; + print NEW "\n$dc IN PTR $o->{var}{client_name}. ; $date\n\n"; close(NEW) or die "can not close $file"; up_serial($file); - system("/etc/rc.d/init.d/named restart"); + if (services::is_service_running('named')) { + services::restart('named') + } else { + services::start('named') + } } sub new { |