From 944f1a020d9cfd25047ecdd149b89e5df975c144 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Wed, 11 Sep 2024 21:55:23 -0700 Subject: [PATCH 1/2] Use formal param --- proftpd/install_check.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/proftpd/install_check.pl b/proftpd/install_check.pl index b2c926355..583d86773 100755 --- a/proftpd/install_check.pl +++ b/proftpd/install_check.pl @@ -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; From 5463547e7a9919ee58ee1d8b39546f3d60eed25a Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Wed, 11 Sep 2024 22:08:42 -0700 Subject: [PATCH 2/2] Update version collected in the module lib, rather than from the UI --- proftpd/index.cgi | 62 +++++++++++------------------------------- proftpd/proftpd-lib.pl | 34 +++++++++++++++++++++++ 2 files changed, 50 insertions(+), 46 deletions(-) diff --git a/proftpd/index.cgi b/proftpd/index.cgi index 6df19122f..36e3d867b 100755 --- a/proftpd/index.cgi +++ b/proftpd/index.cgi @@ -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', "$config{'proftpd_path'}", @@ -18,7 +17,20 @@ if (!@st) { print $lnk,"

\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', + "$config{'proftpd_path'}", + "@{[&get_webprefix()]}/config.cgi?$module_name", + "$config{'proftpd_path'} -v", + "

$out
"),"

\n"; + &ui_print_footer("/", $text{'index'}); + return; } # Check if the config file exists @@ -29,49 +41,7 @@ if (!@$conf) { print &text('index_econf', "$config{'proftpd_conf'}", "@{[&get_webprefix()]}/config.cgi?$module_name"),"

\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', - "$config{'proftpd_path'}", - "@{[&get_webprefix()]}/config.cgi?$module_name", - "$config{'proftpd_path'} -v", - "

$out
"),"

\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', - "$config{'proftpd_path'}", - "@{[&get_webprefix()]}/config.cgi?$module_name"),"

\n"; - &ui_print_footer("/", $text{'index'}); - exit; - } - - # Get the list of modules - local @mods; - open(MODS, "$config{'proftpd_path'} -vv |"); - while() { - s/\r|\n//g; - if (/^\s*(?\S+)\.c$|\s*(?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, diff --git a/proftpd/proftpd-lib.pl b/proftpd/proftpd-lib.pl index a689c2f44..ed37754d5 100755 --- a/proftpd/proftpd-lib.pl +++ b/proftpd/proftpd-lib.pl @@ -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() { + s/\r|\n//g; + if (/^\s*(?\S+)\.c$|\s*(?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'});