# Parse inputs
if ($p eq 'mysql' || $p eq 'postgresql' || $p eq 'ldap') {
- gethostbyname($in{$p."_host"}) ||
- $in{$p."_host"} =~ /^(\S+):(\d+)$/ && gethostbyname($1) ||
+ &to_ipaddress($in{$p."_host"}) ||
+ $in{$p."_host"} =~ /^(\S+):(\d+)$/ && &to_ipaddress("$1") ||
&error($text{'sql_ehost'});
$in{$p."_user"} =~ /^\S+$/ || &error($text{'sql_euser'});
$in{$p."_pass"} =~ /^\S*$/ || &error($text{'sql_epass'});
}
else {
foreach $a (split(/\s+/, $in{'addr'})) {
- gethostbyname($a) || &check_ipaddress($a) ||
- &check_ip6address($a) ||
+ &to_ipaddress($a) || &to_ip6address($a) ||
&error(&text('cvirt_eaddr2', $a));
push(@addrs, &check_ip6address($a) ? "[$a]" : $a);
}
local $ac = $a;
$ac =~ s/:(\d+)$//;
$ac eq '*' || $ac eq '_default_' ||
- gethostbyname($ac) ||
- $ac =~ /^\[(\S+)\]$/ && &check_ip6address("$1") ||
+ &to_ipaddress($ac) ||
+ $ac =~ /^\[(\S+)\]$/ && &to_ip6address("$1") ||
&error(&text('vserv_eaddr2', $ac));
}
$addr = join(" ", @addrs);
elsif ($in{'addr'} !~ /\S/) {
&error($text{'vserv_eaddr1'});
}
- elsif (!gethostbyname($in{'addr'}) &&
- !&check_ipaddress($in{'addr'}) &&
- !&check_ip6address($in{'addr'})) {
+ elsif (!&to_ipaddress($in{'addr'}) &&
+ !&to_ip6address($in{'addr'})) {
&error(&text('vserv_eaddr2', $in{'addr'}));
}
elsif (&check_ip6address($in{'addr'})) {
$conconf = &get_bconsole_config();
$condir = &find("Director", $conconf);
$addr = &get_system_hostname();
-if (!gethostbyname($addr)) {
+if (!&to_ipaddress($addr) && !&to_ip6address($addr)) {
$addr = "localhost";
}
&save_directive($conconf, $condir, "Address", $addr, 1);
$conconf = &get_bconsole_config();
$condir = &find("Director", $conconf);
$conaddr = &find_value("Address", $condir->{'members'});
- if (!gethostbyname($conaddr)) {
+ if (!&to_ipaddress($conaddr) && !&to_ip6address($conaddr)) {
# Offer to fix hostname
print &text('index_econsole2',
"<tt>$console_cmd</tt>", "<tt>$conaddr</tt>"),"<p>\n";
$in{'pass'} || &error($text{'client_epass'});
&save_directive($conf, $client, "Password", $in{'pass'}, 1);
- gethostbyname($in{'address'}) || &error($text{'client_eaddress'});
+ &to_ipaddress($in{'address'}) || &to_ip6address($in{'address'}) ||
+ &error($text{'client_eaddress'});
&save_directive($conf, $client, "Address", $in{'address'}, 1);
$in{'port'} =~ /^\d+$/ && $in{'port'} > 0 && $in{'port'} < 65536 ||
$in{'pass'} || &error($text{'storage_epass'});
&save_directive($conf, $storage, "Password", $in{'pass'}, 1);
- gethostbyname($in{'address'}) || &error($text{'storage_eaddress'});
+ &to_ipaddress($in{'address'}) || &to_ip6address($in{'address'}) ||
+ &error($text{'storage_eaddress'});
&save_directive($conf, $storage, "Address", $in{'address'}, 1);
$in{'port'} =~ /^\d+$/ && $in{'port'} > 0 && $in{'port'} < 65536 ||
@hl || &error($text{'save_ehosts'});
$exp{'hosts'} = \@hl;
foreach $h (@hl) {
- $ip = gethostbyname($h);
+ $ip = &to_ipaddress($h) || &to_ip6address($h);
if ($ip) { push(@iplist, $ip); }
}
}
}
next if (!$samefs);
foreach $h (@{$exps[$i]->{'hosts'}}) {
- $ip = gethostbyname($h);
+ $ip = &to_ipaddress($h) || &to_ip6address($h);
if ($ip && &indexof($ip, @iplist) >= 0) {
# Another export on this filesystem is to the same host
&error(&text('save_esame1', $samefs, $h));
--- /dev/null
+#!/usr/local/bin/perl
+# Update scheduled checking
+
+require './cluster-shutdown-lib.pl';
+&ReadParse();
+&error_setup($text{'sched_err'});
+
+# Validate and store inputs
+$job = &find_cron_job();
+if ($in{'sched'}) {
+ $in{'email'} =~ /\S/ || &error($text{'sched_eemail'});
+ $config{'email'} = $in{'email'};
+ if ($in{'smtp_def'}) {
+ delete($config{'smtp'});
+ }
+ else {
+ &to_ipaddress($in{'smtp'}) || &to_ip6address($in{'smtp'}) ||
+ &error($text{'sched_esmtp'});
+ $config{'smtp'} = $in{'smtp'};
+ }
+ &save_module_config();
+ }
+
+# Create or delete cron job
+&cron::create_wrapper($cron_cmd, $module_name, "check.pl");
+if ($in{'sched'} && !$job) {
+ $job = { 'command' => $cron_cmd,
+ 'user' => 'root',
+ 'active' => 1,
+ 'mins' => '*/5',
+ 'hours' => '*',
+ 'days' => '*',
+ 'months' => '*',
+ 'weekdays' => '*',
+ };
+ &cron::create_cron_job($job);
+ }
+elsif (!$in{'sched'} && $job) {
+ &cron::delete_cron_job($job);
+ }
+
+# Tell the user
+&ui_print_header(undef, $text{'sched_title'}, "");
+
+if ($in{'sched'}) {
+ print $text{'sched_enabled'},"<p>\n";
+ }
+else {
+ print $text{'sched_disabled'},"<p>\n";
+ }
+
+&ui_print_footer("", $text{'index_return'});
+
delete($cmd->{'host'});
}
else {
- gethostbyname($in{'host'}) || &error($text{'sql_ehost'});
+ &to_ipaddress($in{'host'}) ||
+ &error($text{'sql_ehost'});
$cmd->{'host'} = $in{'host'};
}
&parse_params_inputs($cmd);
local $h;
if ($gconfig{'os_version'} < 7) {
foreach $h (@_) {
- gethostbyname($h) || &error(&text('save_ehost', $h));
+ &to_ipaddress($h) || &to_ip6address($h) ||
+ &error(&text('save_ehost', $h));
}
}
}
local $nv = $in{$_[0]};
local @nv = split(/\s+/, $nv);
if ($_[1] == 0) {
- gethostbyname($nv) || &check_ipaddress($nv) ||
+ &to_ipaddress($nv) ||
&error("$_[0] '$nv' $text{'sopt_invalidip'}");
}
elsif ($_[1] == 1) {
elsif ($_[1] == 2) {
local $ip;
foreach $ip (@nv) {
- gethostbyname($ip) || &check_ipaddress($ip) ||
+ &to_ipaddress($ip) ||
&error("'$ip' $text{'sopt_invalidip'}");
}
$nv = join(", ", @nv);
else {
&error_setup($text{'ssub_failsave'});
# Validate and save inputs
- gethostbyname($in{'network'}) || &check_ipaddress($in{'network'}) ||
+ &to_ipaddress($in{'network'}) ||
&error("'$in{'network'}' $text{'ssub_invalidsubaddr'}");
&check_ipaddress($in{'netmask'}) ||
&error("'$in{'netmask'}' $text{'ssub_invalidnmask'}");
}
elsif ($in{'mode'} == 3) { $exp{'host'} = ""; }
else {
- $in{'host'} =~ /\*/ || gethostbyname($in{'host'}) ||
+ $in{'host'} =~ /\*/ || &to_ipaddress($in{'host'}) ||
&error(&text('save_ehost', $in{'host'}));
$exp{'host'} = $in{'host'};
}
sub poll_lines
{
local @rv;
+local $name = $_[0]->{'poll'};
+$name = "\"$name\"" if ($name =~ /[\s:;,]/);
if ($_[0]->{'skip'}) {
- push(@rv, "skip $_[0]->{'poll'}");
+ push(@rv, "skip $name");
}
elsif ($_[0]->{'defaults'}) {
- push(@rv, "defaults $_[0]->{'poll'}");
+ push(@rv, "defaults $name");
}
else {
- push(@rv, "poll $_[0]->{'poll'}");
+ push(@rv, "poll $name");
}
push(@rv, "\tproto $_[0]->{'proto'}") if ($_[0]->{'proto'});
push(@rv, "\tauth $_[0]->{'auth'}") if ($_[0]->{'auth'});
sub check_host
{
-return 1 if (gethostbyname($_[0]));
-return 0 if (gethostbyname("www.webmin.com")); # only fail if we are online
+return 1 if (&to_ipaddress($_[0]) || &to_ip6address($_[0]));
+return 0 if (&to_ipaddress("www.webmin.com")); # only fail if we are online
return 1;
}