Merge branch 'webmin:master' into master

This commit is contained in:
liAnGjiA
2024-09-12 15:13:13 +08:00
committed by GitHub
3 changed files with 52 additions and 47 deletions

View File

@@ -5,8 +5,7 @@
require './proftpd-lib.pl';
# Check if proftpd is installed
@st = stat($config{'proftpd_path'});
if (!@st) {
if (&has_command($config{'proftpd_path'})) {
&ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0,
&help_search_link("proftpd", "man", "doc", "google"));
print &text('index_eproftpd', "<tt>$config{'proftpd_path'}</tt>",
@@ -18,7 +17,20 @@ if (!@st) {
print $lnk,"<p>\n" if ($lnk);
&ui_print_footer("/", $text{'index'});
exit;
return;
}
# Check that the command is actually proftpd
if (!$site{'version'}) {
&ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0,
&help_search_link("proftpd", "man", "doc", "google"));
print &text('index_eproftpd2',
"<tt>$config{'proftpd_path'}</tt>",
"@{[&get_webprefix()]}/config.cgi?$module_name",
"<tt>$config{'proftpd_path'} -v</tt>",
"<pre>$out</pre>"),"<p>\n";
&ui_print_footer("/", $text{'index'});
return;
}
# Check if the config file exists
@@ -29,49 +41,7 @@ if (!@$conf) {
print &text('index_econf', "<tt>$config{'proftpd_conf'}</tt>",
"@{[&get_webprefix()]}/config.cgi?$module_name"),"<p>\n";
&ui_print_footer("/", $text{'index'});
exit;
}
# Check if the executable has changed ..
if ($site{'size'} != $st[7] || !$site{'version'} || !$site{'fullversion'}) {
# Check if it really is proftpd and the right version
$site{'size'} = $st[7];
($ver, $fullver) = &get_proftpd_version(\$out);
if (!$ver) {
&ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0,
&help_search_link("proftpd", "man", "doc", "google"));
print &text('index_eproftpd2',
"<tt>$config{'proftpd_path'}</tt>",
"@{[&get_webprefix()]}/config.cgi?$module_name",
"<tt>$config{'proftpd_path'} -v</tt>",
"<pre>$out</pre>"),"<p>\n";
&ui_print_footer("/", $text{'index'});
exit;
}
$site{'version'} = $ver;
$site{'fullversion'} = $fullver;
if ($site{'version'} < 0.99) {
&ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0,
&help_search_link("proftpd", "man", "doc", "google"));
print &text('index_eversion',
"<tt>$config{'proftpd_path'}</tt>",
"@{[&get_webprefix()]}/config.cgi?$module_name"),"<p>\n";
&ui_print_footer("/", $text{'index'});
exit;
}
# Get the list of modules
local @mods;
open(MODS, "$config{'proftpd_path'} -vv |");
while(<MODS>) {
s/\r|\n//g;
if (/^\s*(?<mod_built_in>\S+)\.c$|\s*(?<mod_loaded>mod_[a-zA-Z0-9_]+)\//) {
push(@mods, $+{mod_loaded} || $+{mod_built_in});
}
}
close(MODS);
$site{'modules'} = join(" ", @mods);
&write_file("$module_config_directory/site", \%site);
return;
}
&ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0,

View File

@@ -8,8 +8,9 @@ do 'proftpd-lib.pl';
# For mode 0, returns 1 if installed, 0 if not
sub is_installed
{
my ($mode) = @_;
return 0 if (!-x $config{'proftpd_path'} || !-r $config{'proftpd_conf'});
if ($_[0]) {
if ($mode) {
return 2 if ($site{'version'} || &get_proftpd_version());
}
return 1;

View File

@@ -5,6 +5,40 @@ BEGIN { push(@INC, ".."); };
use WebminCore;
&init_config();
# Check if a list of supported modules needs to be built. This is done
# if the ProFTPd binary changes, when Webmin is upgraded
my @st = stat($config{'proftpd_path'});
my %oldsite;
&read_file("$module_config_directory/site", \%site);
if ($oldsite{'size'} != $st[7] ||
!$oldsite{'version'} ||
!$oldsite{'fullversion'} ||
$oldsite{'webmin'} != &get_webmin_version()) {
# Check if it really is proftpd and the right version
my ($ver, $fullver) = &get_proftpd_version(\$out);
if ($ver) {
# Store the detected versions
my %site;
$site{'size'} = $st[7];
$site{'version'} = $ver;
$site{'fullversion'} = $fullver;
$site{'webmin'} = &get_webmin_version();
# Get the list of modules
my @mods;
open(MODS, "$config{'proftpd_path'} -vv |");
while(<MODS>) {
s/\r|\n//g;
if (/^\s*(?<mod_built_in>\S+)\.c$|\s*(?<mod_loaded>mod_[a-zA-Z0-9_]+)\//) {
push(@mods, $+{mod_loaded} || $+{mod_built_in});
}
}
close(MODS);
$site{'modules'} = join(" ", @mods);
&write_file("$module_config_directory/site", \%site);
}
}
# Load the site-specific information on the server executable
&read_file("$module_config_directory/site", \%site);
@ftpaccess_files = split(/\s+/, $site{'ftpaccess'});