Compare commits

...

21 Commits

Author SHA1 Message Date
Ilia Ross
18f3e1273f Fix to use a new param to clear cache 2023-08-27 01:27:05 +03:00
Ilia Ross
8ced23d027 Fix to use a new way for clearing hostname cache 2023-08-26 21:26:03 +03:00
Ilia Ross
d834bb6da0 Fix to use state instead of globals in get_system_hostname sub 2023-08-26 21:17:57 +03:00
Jamie Cameron
cc560b00e5 Merge pull request #1990 from webmin/dev/hostname-detection-with-hostnamectl
Add hostname detection using `hostnamectl` command
2023-08-25 13:59:47 -07:00
Jamie Cameron
3e4668715a Merge branch 'master' of github.com:webmin/webmin 2023-08-25 11:25:51 -07:00
Jamie Cameron
053e8dcf22 Remove double HTML escape https://github.com/webmin/usermin/issues/105 2023-08-25 11:25:25 -07:00
Ilia Ross
2d7e57c7e1 Add hostname detection using hostnamectl command 2023-08-25 18:59:03 +03:00
Ilia Ross
30e6360fa2 Update CHANGELOG.md 2023-08-24 00:58:40 +03:00
Jamie Cameron
dda9290ff5 minor version bump 2023-08-23 11:53:53 -07:00
Jamie Cameron
15a00d8119 Remove perl module dependency and just use glob instead 2023-08-23 11:49:00 -07:00
Jamie Cameron
9289083171 No need for BEGIN block 2023-08-23 10:54:20 -07:00
Jamie Cameron
3d482d2bf5 Support CF-Connecting-IPv6 header 2023-08-22 18:46:43 -07:00
Jamie Cameron
318150e6b0 Merge branch 'master' of github.com:webmin/webmin 2023-08-21 17:18:53 -07:00
Jamie Cameron
8939b060b4 Clean up diff dirs so they don't get package up https://forum.virtualmin.com/t/debian-upgrade-nwe-directories-in-root-and-orig-directories-left-after-upgrade-completed/122241/8 2023-08-21 17:18:46 -07:00
Ilia Ross
4709ff6adf Add support for odd Amazon Linux interface names 2023-08-22 01:52:22 +03:00
Jamie Cameron
31af9f996c Also support CF-Connecting-IP https://github.com/webmin/webmin/issues/1956 2023-08-21 10:04:16 -07:00
Jamie Cameron
c716443737 Merge branch 'master' of github.com:webmin/webmin 2023-08-20 21:22:15 -07:00
Jamie Cameron
fd06605f51 Add support for True-Client-IP header as used by Cloudflare https://github.com/webmin/webmin/issues/1956 2023-08-20 21:22:08 -07:00
Ilia Ross
c8f6b05987 Add Config::IniFiles to vendor_perl [build]
* Amazon Linux doesn't have it available anywhere
2023-08-20 15:24:12 +03:00
Ilia Ross
a90dbc5f33 Fix not to print HTML in stdout 2023-08-20 14:08:31 +03:00
Ilia Ross
7fc16f8948 Update CHANGELOG.md 2023-08-19 18:22:16 +03:00
27 changed files with 3516 additions and 57 deletions

View File

@@ -1,7 +1,12 @@
## Changelog
#### 2.102 (August, 2023)
#### 2.102 (August 23, 2023)
* Add support for Amazon Linux 2023
* Fix a bug in Network Configuration module when parsing network size [sourceforge.net/discussion#55377]( https://sourceforge.net/p/webadmin/discussion/55377/thread/78e5aa05f3)
* Fix Netplan related bugs in Network Configuration module
* Fix Terminal focus bug
* Fix to correctly compare Webmin semantic versions
* Fix to suppress output from `monitor.pl` command [#1984](https://github.com/webmin/webmin/issues/1984)
#### 2.101 (August 5, 2023)
* Add support for reading gzipped email messages

View File

@@ -2,7 +2,7 @@
# Returns a list of files and directories under some directory
$trust_unknown_referers = 1;
BEGIN { require './bacula-backup-lib.pl'; }
require './bacula-backup-lib.pl';
&ReadParse();
# Input sanitization

View File

@@ -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

View File

@@ -501,18 +501,7 @@ return $? ? $out : undef;
sub get_config_files
{
my $conf_dir = $config{'config_dir'} || '/etc/firewalld';
my @conf_files;
my @dirpath = ($conf_dir);
eval "use File::Find;";
if (!$@) {
find(sub {
my $file = $File::Find::name;
push(@conf_files, $file)
if (-f $file && $file =~ /\.(conf|xml)$/);
}, @dirpath);
}
push(@conf_files, "$conf_dir/direct.xml");
return @conf_files;
return (glob("$conf_dir/*.xml"), glob("$conf_dir/*/*.xml"));
}
1;

View File

@@ -458,7 +458,6 @@ foreach my $deb ("deb", "newkey/deb") {
# Run the actual build command
system("fakeroot dpkg --build $tmp_dir $deb/${product}_${ver}${rel}_all.deb") &&
die "dpkg failed";
#system("rm -rf $tmp_dir");
print "Wrote $deb/${product}_${ver}${rel}_all.deb\n";
$md5 = `md5sum $tarfile`;
$md5 =~ s/\s+.*\n//g;
@@ -521,6 +520,8 @@ EOF
unlink("sigs/${product}_${ver}${rel}_all.deb-sig.asc");
system("gpg --armor --output sigs/${product}_${ver}${rel}_all.deb-sig.asc --default-key $key --detach-sig $deb/${product}_${ver}${rel}_all.deb");
print "Wrote sigs/${product}_${ver}${rel}_all.deb-sig.asc\n";
system("rm -rf $diff_orig_dir $diff_new_dir");
}
# read_file(file, &assoc, [&order], [lowercase])

View File

@@ -1450,7 +1450,10 @@ alarm(0);
# If a remote IP is given in a header (such as via a proxy), only use it
# for logging unless trust_real_ip is set
local $headerhost = $header{'x-forwarded-for'} ||
$header{'x-real-ip'};
$header{'x-real-ip'} ||
$header{'true-client-ip'} ||
$header{'cf-connecting-ip'} ||
$header{'cf-connecting-ip6'};
if ($headerhost) {
# Only real IPs are allowed
$headerhost = undef if (!&check_ipaddress($headerhost) &&

View File

@@ -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()

View File

@@ -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()

View File

@@ -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

View File

@@ -525,7 +525,7 @@ return &has_command("ifup") &&
$gconfig{'os_version'} >= 5 ||
$gconfig{'os_type'} eq 'redhat-linux' &&
$gconfig{'os_version'} >= 13) &&
($iface->{'name'} !~ /^(eth|em|eno|ens|enp|enx|lo|br)/ ||
($iface->{'name'} !~ /^(eth|em|eno|ens|enp|enx|enX|lo|br)/ ||
$iface->{'name'} =~ /^(\S+)\.(\d+)/) &&
$iface->{'virtual'} eq '';
}
@@ -541,7 +541,7 @@ if ($name =~ /^(.*)\.(\d+)$/) {
return "PPP" if ($name =~ /^ppp/);
return "SLIP" if ($name =~ /^sl/);
return "PLIP" if ($name =~ /^plip/);
return "Ethernet" if ($name =~ /^eth|em|eno|ens|enp|enx|p\d+p\d+|vtnet/);
return "Ethernet" if ($name =~ /^eth|em|eno|ens|enp|enx|enX|p\d+p\d+|vtnet/);
return "Wireless Ethernet" if ($name =~ /^(wlan|ath)/);
return "Arcnet" if ($name =~ /^arc/);
return "Token Ring" if ($name =~ /^tr/);
@@ -803,7 +803,7 @@ return $? ? $out : undef;
# Does some interface have an editable hardware address
sub iface_hardware
{
return $_[0] =~ /^(eth|em|eno|ens|enp|enx)/;
return $_[0] =~ /^(eth|em|eno|ens|enp|enx|enX)/;
}
# allow_interface_clash()

View File

@@ -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

View File

@@ -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()

View File

@@ -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()

View File

@@ -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()

View File

@@ -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 {

View File

@@ -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()

View File

@@ -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

View File

@@ -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

View File

@@ -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()

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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()

View File

@@ -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()

File diff suppressed because it is too large Load Diff

View File

@@ -1 +1 @@
2.101
2.102

View File

@@ -1698,7 +1698,9 @@ $err_caller = "$stack[1]->[1] (line $stack[1]->[2])"
if ($stack[1]->[1] && $stack[1]->[2]);
if ($err_caller) {
$err_caller =~ s/$root_directory\///;
my $err_caller_ = &ui_help($err_caller);
my $err_caller_ =
$main::webmin_script_type =~ /^(cmd|cron)$/ ?
$err_caller : &ui_help($err_caller);
$msg = $msg ? "$msg $err_caller_" : $err_caller_;
push(@msg, $err_caller_);
}
@@ -4235,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) {
@@ -4328,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
@@ -4354,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;
}
}
}
@@ -4366,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