mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 14:13:29 +00:00
Fix to use a new param to clear cache
This commit is contained in:
@@ -371,7 +371,7 @@ return &get_system_hostname();
|
||||
sub save_hostname
|
||||
{
|
||||
&system_logged("hostname $_[0] >/dev/null 2>&1");
|
||||
&get_system_hostname(-2); # clear cache
|
||||
&get_system_hostname(undef, undef, 2); # clear cache
|
||||
}
|
||||
|
||||
# get_domainname()
|
||||
|
||||
@@ -583,7 +583,7 @@ if (&has_command("hostnamectl")) {
|
||||
" >/dev/null 2>&1");
|
||||
}
|
||||
|
||||
&get_system_hostname(-2); # clear cache
|
||||
&get_system_hostname(undef, undef, 2); # clear cache
|
||||
}
|
||||
|
||||
# get_domainname()
|
||||
|
||||
@@ -583,7 +583,7 @@ my ($hostname) = @_;
|
||||
&system_logged("hostname ".quotemeta($hostname)." >/dev/null 2>&1");
|
||||
&save_rc_conf('hostname', $_[0]);
|
||||
&unlock_file("/etc/rc.conf");
|
||||
&get_system_hostname(-2); # clear cache
|
||||
&get_system_hostname(undef, undef, 2); # clear cache
|
||||
}
|
||||
|
||||
sub routing_config_files
|
||||
|
||||
@@ -396,7 +396,7 @@ my ($hostname) = @_;
|
||||
&lock_file($hostconfig);
|
||||
&set_hostconfig("HOSTNAME", $hostname);
|
||||
&unlock_file($hostconfig);
|
||||
&get_system_hostname(-2); # clear cache
|
||||
&get_system_hostname(undef, undef, 2); # clear cache
|
||||
}
|
||||
|
||||
sub routing_config_files
|
||||
|
||||
@@ -437,7 +437,7 @@ if (&has_command("hostnamectl")) {
|
||||
" >/dev/null 2>&1");
|
||||
}
|
||||
|
||||
&get_system_hostname(-2); # clear cache
|
||||
&get_system_hostname(undef, undef, 2); # clear cache
|
||||
}
|
||||
|
||||
# get_domainname()
|
||||
|
||||
@@ -334,7 +334,7 @@ if (&has_command("hostnamectl")) {
|
||||
" >/dev/null 2>&1");
|
||||
}
|
||||
|
||||
&get_system_hostname(-2); # clear cache
|
||||
&get_system_hostname(undef, undef, 2); # clear cache
|
||||
}
|
||||
|
||||
# get_domainname()
|
||||
|
||||
@@ -131,7 +131,7 @@ local %conf;
|
||||
$conf{'HOSTNAME'} = $_[0];
|
||||
&write_file($network_config, \%conf);
|
||||
&unlock_file($network_config);
|
||||
&get_system_hostname(-2); # clear cache
|
||||
&get_system_hostname(undef, undef, 2); # clear cache
|
||||
}
|
||||
|
||||
# get_domainname()
|
||||
|
||||
@@ -417,7 +417,7 @@ my ($hostname) = @_;
|
||||
&open_lock_tempfile(MYNAME, ">/etc/myname");
|
||||
&print_tempfile(MYNAME, $hostname,"\n");
|
||||
&close_tempfile(MYNAME);
|
||||
&get_system_hostname(-2); # clear cache
|
||||
&get_system_hostname(undef, undef, 2); # clear cache
|
||||
}
|
||||
|
||||
sub set_line {
|
||||
|
||||
@@ -506,7 +506,7 @@ if (&has_command("hostnamectl")) {
|
||||
" >/dev/null 2>&1");
|
||||
}
|
||||
|
||||
&get_system_hostname(-2); # clear cache
|
||||
&get_system_hostname(undef, undef, 2); # clear cache
|
||||
}
|
||||
|
||||
# get_domainname()
|
||||
|
||||
@@ -274,7 +274,7 @@ sub save_hostname
|
||||
&open_lock_tempfile(HOST, ">/etc/HOSTNAME");
|
||||
&print_tempfile(HOST, $_[0],"\n");
|
||||
&close_tempfile(HOST);
|
||||
&get_system_hostname(-2); # clear cache
|
||||
&get_system_hostname(undef, undef, 2); # clear cache
|
||||
}
|
||||
|
||||
sub routing_config_files
|
||||
|
||||
@@ -236,7 +236,7 @@ sub save_hostname
|
||||
&open_lock_tempfile(HOST, ">/etc/HOSTNAME");
|
||||
&print_tempfile(HOST, $_[0],"\n");
|
||||
&close_tempfile(HOST);
|
||||
&get_system_hostname(-2); # clear cache
|
||||
&get_system_hostname(undef, undef, 2); # clear cache
|
||||
}
|
||||
|
||||
sub routing_config_files
|
||||
|
||||
@@ -442,7 +442,7 @@ if (-r "/etc/nodename") {
|
||||
&print_tempfile(NODENAME, $_[0],"\n");
|
||||
&close_tempfile(NODENAME);
|
||||
}
|
||||
&get_system_hostname(-2); # clear cache
|
||||
&get_system_hostname(undef, undef, 2); # clear cache
|
||||
}
|
||||
|
||||
# get_domainname()
|
||||
|
||||
@@ -172,7 +172,7 @@ local %conf;
|
||||
&open_lock_tempfile(HOST, ">/etc/HOSTNAME");
|
||||
&print_tempfile(HOST, $_[0],"\n");
|
||||
&close_tempfile(HOST);
|
||||
&get_system_hostname(-2); # clear cache
|
||||
&get_system_hostname(undef, undef, 2); # clear cache
|
||||
}
|
||||
|
||||
sub routing_config_files
|
||||
|
||||
@@ -258,7 +258,7 @@ local %conf;
|
||||
&open_lock_tempfile(HOST, ">/etc/HOSTNAME");
|
||||
&print_tempfile(HOST, $_[0],"\n");
|
||||
&close_tempfile(HOST);
|
||||
&get_system_hostname(-2); # clear cache
|
||||
&get_system_hostname(undef, undef, 2); # clear cache
|
||||
}
|
||||
|
||||
sub routing_config_files
|
||||
|
||||
@@ -200,7 +200,7 @@ local $rc = &parse_rc_config();
|
||||
# run SuSEconfig, as this function is called last
|
||||
&system_logged("SuSEconfig -quick >/dev/null 2>&1");
|
||||
|
||||
&get_system_hostname(-2); # clear cache
|
||||
&get_system_hostname(undef, undef, 2); # clear cache
|
||||
}
|
||||
|
||||
sub routing_config_files
|
||||
|
||||
@@ -136,7 +136,7 @@ local %conf;
|
||||
$conf{'HOSTNAME'} = $_[0];
|
||||
&write_env_file($network_config, \%conf);
|
||||
&unlock_file($network_config);
|
||||
&get_system_hostname(-2); # clear cache
|
||||
&get_system_hostname(undef, undef, 2); # clear cache
|
||||
}
|
||||
|
||||
# get_domainname()
|
||||
|
||||
@@ -314,7 +314,7 @@ return &get_system_hostname();
|
||||
sub save_hostname
|
||||
{
|
||||
&system_logged("hostname $_[0] >/dev/null 2>&1");
|
||||
&get_system_hostname(-2); # clear cache
|
||||
&get_system_hostname(undef, undef, 2); # clear cache
|
||||
}
|
||||
|
||||
# get_domainname()
|
||||
|
||||
@@ -4237,24 +4237,23 @@ my $func = "${pkg}::${sub}";
|
||||
return defined(&$func);
|
||||
}
|
||||
|
||||
=head2 get_system_hostname([short], [skip-file])
|
||||
=head2 get_system_hostname([short], [skip-file], [nocache])
|
||||
|
||||
Returns the hostname of this system. If the short parameter is set to 1 or -1,
|
||||
then the domain name is not prepended - otherwise, Webmin will attempt to get
|
||||
the fully qualified hostname, like foo.example.com.
|
||||
If the short parameter is set to -1 it will flush the cache and re-read the
|
||||
hostname from the system. If the short parameter is set to -2 it will flush the
|
||||
cache and exit.
|
||||
Returns the hostname of this system. If the short parameter is set to 1 then
|
||||
the domain name is not prepended - otherwise, Webmin will attempt to get the
|
||||
fully qualified hostname, like foo.example.com.
|
||||
If the nocache parameter is set to 1 it will flush the cache and re-read the
|
||||
hostname from the system. If the nocache parameter is set to 2 it will flush
|
||||
the cache and exit.
|
||||
|
||||
=cut
|
||||
sub get_system_hostname
|
||||
{
|
||||
my ($m , $skipfile) = @_;
|
||||
my $nocache = $m <= -1 ? $m : 0;
|
||||
$m = $m =~ /-?1/ ? 1 : 0;
|
||||
my ($m , $skipfile, $nocache) = @_;
|
||||
$m = int($m);
|
||||
state @system_hostname;
|
||||
undef(@system_hostname) if ($nocache);
|
||||
return if ($nocache == -2);
|
||||
return if ($nocache == 2);
|
||||
if (!$system_hostname[$m]) {
|
||||
if ($gconfig{'os_type'} ne 'windows') {
|
||||
# Try hostnamectl command on Linux
|
||||
|
||||
Reference in New Issue
Block a user