mirror of
https://github.com/webmin/webmin.git
synced 2026-02-04 14:42:15 +00:00
Compare commits
7 Commits
2.102
...
dev/cache-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
18f3e1273f | ||
|
|
8ced23d027 | ||
|
|
d834bb6da0 | ||
|
|
cc560b00e5 | ||
|
|
3e4668715a | ||
|
|
053e8dcf22 | ||
|
|
2d7e57c7e1 |
@@ -120,7 +120,7 @@ if (@filters || &get_global_spamassassin()) {
|
||||
# Work out nice condition and action descriptions
|
||||
local $cond;
|
||||
($cond, $lastalways) = &describe_condition($f);
|
||||
$cond = &ui_link("edit.cgi?idx=$f->{'index'}", &html_escape($cond));
|
||||
$cond = &ui_link("edit.cgi?idx=$f->{'index'}", $cond);
|
||||
local $action = &describe_action($f, \@folders);
|
||||
|
||||
# Create mover links
|
||||
|
||||
@@ -371,7 +371,7 @@ return &get_system_hostname();
|
||||
sub save_hostname
|
||||
{
|
||||
&system_logged("hostname $_[0] >/dev/null 2>&1");
|
||||
undef(@main::get_system_hostname); # clear cache
|
||||
&get_system_hostname(undef, undef, 2); # clear cache
|
||||
}
|
||||
|
||||
# get_domainname()
|
||||
|
||||
@@ -583,7 +583,7 @@ if (&has_command("hostnamectl")) {
|
||||
" >/dev/null 2>&1");
|
||||
}
|
||||
|
||||
undef(@main::get_system_hostname); # 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");
|
||||
undef(@main::get_system_hostname); # 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);
|
||||
undef(@main::get_system_hostname); # 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");
|
||||
}
|
||||
|
||||
undef(@main::get_system_hostname); # clear cache
|
||||
&get_system_hostname(undef, undef, 2); # clear cache
|
||||
}
|
||||
|
||||
# get_domainname()
|
||||
|
||||
@@ -334,7 +334,7 @@ if (&has_command("hostnamectl")) {
|
||||
" >/dev/null 2>&1");
|
||||
}
|
||||
|
||||
undef(@main::get_system_hostname); # 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);
|
||||
undef(@main::get_system_hostname); # 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);
|
||||
undef(@main::get_system_hostname); # 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");
|
||||
}
|
||||
|
||||
undef(@main::get_system_hostname); # 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);
|
||||
undef(@main::get_system_hostname); # 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);
|
||||
undef(@main::get_system_hostname); # 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);
|
||||
}
|
||||
undef(@main::get_system_hostname); # 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);
|
||||
undef(@main::get_system_hostname); # 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);
|
||||
undef(@main::get_system_hostname); # 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");
|
||||
|
||||
undef(@main::get_system_hostname); # 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);
|
||||
undef(@main::get_system_hostname); # 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");
|
||||
undef(@main::get_system_hostname); # clear cache
|
||||
&get_system_hostname(undef, undef, 2); # clear cache
|
||||
}
|
||||
|
||||
# get_domainname()
|
||||
|
||||
@@ -4237,19 +4237,36 @@ 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,
|
||||
then the domain name is not prepended - otherwise, Webmin will attempt to get
|
||||
the fully qualified hostname, like foo.example.com.
|
||||
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 = int($_[0]);
|
||||
my $skipfile = $_[1];
|
||||
if (!$main::get_system_hostname[$m]) {
|
||||
my ($m , $skipfile, $nocache) = @_;
|
||||
$m = int($m);
|
||||
state @system_hostname;
|
||||
undef(@system_hostname) if ($nocache);
|
||||
return if ($nocache == 2);
|
||||
if (!$system_hostname[$m]) {
|
||||
if ($gconfig{'os_type'} ne 'windows') {
|
||||
# Try hostnamectl command on Linux
|
||||
if (&has_command("hostnamectl")) {
|
||||
my $hostname =
|
||||
&backquote_command("hostnamectl --static");
|
||||
chop($hostname);
|
||||
if ($? == 0 && $hostname =~ /\./) {
|
||||
$hostname =~ s/\..*$// if ($m);
|
||||
$system_hostname[$m] = $hostname;
|
||||
return $hostname;
|
||||
}
|
||||
}
|
||||
# Try some common Linux hostname files first
|
||||
my $fromfile;
|
||||
if ($skipfile) {
|
||||
@@ -4330,24 +4347,24 @@ if (!$main::get_system_hostname[$m]) {
|
||||
if ($m) {
|
||||
$fromfile =~ s/\..*$//;
|
||||
}
|
||||
$main::get_system_hostname[$m] = $fromfile;
|
||||
$system_hostname[$m] = $fromfile;
|
||||
return $fromfile;
|
||||
}
|
||||
|
||||
# Can use hostname command on Unix
|
||||
&execute_command("hostname", undef,
|
||||
\$main::get_system_hostname[$m], undef, 0, 1);
|
||||
chop($main::get_system_hostname[$m]);
|
||||
\$system_hostname[$m], undef, 0, 1);
|
||||
chop($system_hostname[$m]);
|
||||
if ($?) {
|
||||
eval "use Sys::Hostname";
|
||||
if (!$@) {
|
||||
$main::get_system_hostname[$m] = eval "hostname()";
|
||||
$system_hostname[$m] = eval "hostname()";
|
||||
}
|
||||
if ($@ || !$main::get_system_hostname[$m]) {
|
||||
$main::get_system_hostname[$m] = "UNKNOWN";
|
||||
if ($@ || !$system_hostname[$m]) {
|
||||
$system_hostname[$m] = "UNKNOWN";
|
||||
}
|
||||
}
|
||||
elsif ($main::get_system_hostname[$m] !~ /\./ &&
|
||||
elsif ($system_hostname[$m] !~ /\./ &&
|
||||
$gconfig{'os_type'} =~ /linux$/ &&
|
||||
!$gconfig{'no_hostname_f'} && !$_[0]) {
|
||||
# Try with -f flag to get fully qualified name
|
||||
@@ -4356,7 +4373,7 @@ if (!$main::get_system_hostname[$m]) {
|
||||
undef, 0, 1);
|
||||
chop($flag);
|
||||
if (!$ex && $flag ne "") {
|
||||
$main::get_system_hostname[$m] = $flag;
|
||||
$system_hostname[$m] = $flag;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4368,14 +4385,14 @@ if (!$main::get_system_hostname[$m]) {
|
||||
# Fall back to net name command
|
||||
my $out = `net name 2>&1`;
|
||||
if ($out =~ /\-+\r?\n(\S+)/) {
|
||||
$main::get_system_hostname[$m] = $1;
|
||||
$system_hostname[$m] = $1;
|
||||
}
|
||||
else {
|
||||
$main::get_system_hostname[$m] = "windows";
|
||||
$system_hostname[$m] = "windows";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $main::get_system_hostname[$m];
|
||||
return $system_hostname[$m];
|
||||
}
|
||||
|
||||
=head2 get_webmin_version
|
||||
|
||||
Reference in New Issue
Block a user