Skip to content

Commit

Permalink
Enable a usable CGI mode by default https://forum.virtualmin.com/t/fa…
Browse files Browse the repository at this point in the history
  • Loading branch information
jcameron committed Apr 4, 2024
1 parent 354f1a0 commit 504bb35
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions config
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,4 @@ letsencrypt_retry=1
bind_spf=yes
bind_spfall=1
web_http2=0
cgimode=suexec

This comment has been minimized.

Copy link
@iliajie

iliajie Apr 5, 2024

Collaborator

I think it should be safer to use FCGIWrap as default, as suEXEC not available in RHEL and derivatives.

This comment has been minimized.

Copy link
@jcameron

jcameron Apr 5, 2024

Author Collaborator

The code in postinstall.pl will switch the default to fcgiwrap if suexec isn't available.

This comment has been minimized.

Copy link
@iliajie

iliajie Apr 5, 2024

Collaborator

The user earlier mentioned restoring from a backup, which could have replaced the correct template settings with incorrect ones (from a backup where suEXEC was supported). What's the best way to handle this situation?

This comment has been minimized.

Copy link
@jcameron

jcameron Apr 6, 2024

Author Collaborator

OK that's a tricky one ... we don't currently update templates on restore to match the local system.

1 change: 1 addition & 0 deletions config-freebsd
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,4 @@ web_http2=0
php_fpm_cmd=php-fpm
php_fpm_init=php-fpm
php_fpm_pool=/usr/local/etc/php-fpm.d
cgimode=suexec
8 changes: 7 additions & 1 deletion postinstall.pl
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,10 @@ sub module_install
&save_module_config();
}

# If the default template uses a PHP mode that isn't supported, change it
# If the default template uses a PHP or CGI mode that isn't supported, change it
my $mmap = &php_mode_numbers_map();
my @supp = &supported_php_modes();
my @cgimodes = &has_cgi_support();
foreach my $tmpl (grep { $_->{'standard'} } &list_templates()) {
my %cannums = map { $mmap->{$_}, 1 } @supp;
if ($tmpl->{'web_php_suexec'} ne '' &&
Expand All @@ -314,6 +315,11 @@ sub module_install
$tmpl->{'web_php_suexec'} = $mmap->{$goodsupp[0]};
&save_template($tmpl);
}
if ($tmpl->{'web_cgimode'} &&
&indexof($tmpl->{'web_cgimode'}, @cgimodes) < 0) {
$tmpl->{'web_cgimode'} = $cgimodes[0];

This comment has been minimized.

Copy link
@iliajie

iliajie May 10, 2024

Collaborator

I think it's better to have some CGI mode rather than none at all. Why don't we try that first before we consider disabling it completely?

This comment has been minimized.

Copy link
@jcameron

jcameron May 10, 2024

Author Collaborator

What do you mean? We do enable whatever CGI mode is supported..

This comment has been minimized.

Copy link
@iliajie

iliajie May 10, 2024

Collaborator

What I mean is, what if $tmpl->{'web_cgimode'} is set to suexec, but suexec isn't supported on this given system, while fcgiwrap is?

This comment has been minimized.

Copy link
@jcameron

jcameron May 10, 2024

Author Collaborator

Then the subsequent code in this block will switch to fcgiwrap mode.

This comment has been minimized.

Copy link
@iliajie

iliajie May 10, 2024

Collaborator

Oh, wait,$cgimodes[0] is fcgiwrap not disabled, right?

.. I'm sorry, I just read the code, I didn't run it ..

This comment has been minimized.

Copy link
@jcameron

jcameron May 10, 2024

Author Collaborator

Correct!

This comment has been minimized.

Copy link
@iliajie

iliajie May 10, 2024

Collaborator

Ah, thanks!

&save_template($tmpl);
}
}

# Cache current PHP modes and error log files
Expand Down

0 comments on commit 504bb35

Please sign in to comment.