mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 06:03:28 +00:00
More IPv6 friendly function conversions
This commit is contained in:
@@ -10,8 +10,8 @@ $p = $in{'proto'};
|
||||
|
||||
# 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'});
|
||||
|
||||
@@ -30,8 +30,7 @@ elsif ($in{'addr'} !~ /\S/) {
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -47,8 +47,8 @@ else {
|
||||
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);
|
||||
@@ -66,9 +66,8 @@ else {
|
||||
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'})) {
|
||||
|
||||
@@ -7,7 +7,7 @@ require './bacula-backup-lib.pl';
|
||||
$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);
|
||||
|
||||
@@ -59,7 +59,7 @@ if (&is_bacula_running("bacula-dir")) {
|
||||
$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";
|
||||
|
||||
@@ -45,7 +45,8 @@ else {
|
||||
$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 ||
|
||||
|
||||
@@ -45,7 +45,8 @@ else {
|
||||
$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 ||
|
||||
|
||||
@@ -68,7 +68,7 @@ if ($in{'cmode'} == 0) {
|
||||
@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); }
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,7 @@ for($i=0; $i<@exps; $i++) {
|
||||
}
|
||||
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));
|
||||
|
||||
53
cluster-shutdown/save_sched.cgi
Executable file
53
cluster-shutdown/save_sched.cgi
Executable file
@@ -0,0 +1,53 @@
|
||||
#!/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'});
|
||||
|
||||
@@ -40,7 +40,8 @@ else {
|
||||
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);
|
||||
|
||||
@@ -141,7 +141,8 @@ sub check_hosts
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ else {
|
||||
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) {
|
||||
@@ -229,7 +229,7 @@ else {
|
||||
elsif ($_[1] == 2) {
|
||||
local $ip;
|
||||
foreach $ip (@nv) {
|
||||
gethostbyname($ip) || &check_ipaddress($ip) ||
|
||||
&to_ipaddress($ip) ||
|
||||
&error("'$ip' $text{'sopt_invalidip'}");
|
||||
}
|
||||
$nv = join(", ", @nv);
|
||||
|
||||
@@ -63,7 +63,7 @@ else {
|
||||
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'}");
|
||||
|
||||
@@ -42,7 +42,7 @@ else {
|
||||
}
|
||||
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'};
|
||||
}
|
||||
|
||||
@@ -197,14 +197,16 @@ splice(@$lref, $_[0]->{'line'}, $_[0]->{'eline'} - $_[0]->{'line'} + 1,
|
||||
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'});
|
||||
|
||||
@@ -112,8 +112,8 @@ else {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user