* Fri Sep 26 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-3.sme

- fix smanager caching issue [SME: 13098]
- fix Disabled functions displays [SME: 12347]
- add ErrorReporting and DisplayErrors  [SME: 11692]
This commit is contained in:
2025-09-26 01:22:54 -04:00
parent bc2aeabe99
commit 4c9669b732
4 changed files with 157 additions and 118 deletions

View File

@@ -24,34 +24,19 @@ use esmith::ConfigDB;
use esmith::DomainsDB;
use esmith::php;
our $adb = esmith::AccountsDB->open() || die "Couldn't open accounts db";
our $cdb = esmith::ConfigDB->open() || die "Couldn't open config db";
#TODO those 3 variables should be exported from esmith::php
our $defaultdisabledfunc='system,show_source,' .
'symlink,exec,dl,shell_exec,' .
'passthru,phpinfo,' .
'escapeshellarg,escapeshellcmd';
our $BASEPHP = 54;
our %defaultproperties = (
MemoryLimit => '128M',
MaxExecutionTime => '30',
MaxInputTime => '60',
AllowUrlFopen => 'disabled',
PostMaxSize => '20M',
UploadMaxFilesize => '10M',
FileUpload => 'enabled',
PHPBaseDir => '/home/e-smith/files/ibays/$key:/var/lib/php/$key',
DisabledFunctions => $defaultdisabledfunc,
MailForceSender => "admin@".$cdb->get_value('DomainName'),
AllowPHTML => 'disabled',
my ($adb,$cdb);
# those 3 variables should be exported from esmith::php
our $BASEPHP = esmith::php::PHPbase();
our $defaultdisabledfunc = $esmith::php::defaultdisabledfunc;
# this one we add some locally
our %defaultproperties = (%esmith::php::defaultPHPproperties,
ModDav => "disabled",
AllowOverride => "None",
FollowSymLinks => "disabled",
Indexes => "enabled",
DisplayErrors => 'disabled',
ErrorReporting => 'E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT'
);
# those are ok to be defined here and not in core.
@@ -89,10 +74,15 @@ our %optionsproperties =(
},
FollowSymLinks => {%binary},
Indexes => {%binary},
DisplayErrors => {%binary},
ErrorReporting => $defaultproperties{ErrorReporting}
);
sub main {
$adb = esmith::AccountsDB->open() || die "Couldn't open accounts db";
$cdb = esmith::ConfigDB->open() || die "Couldn't open config db";
my $c = shift;
$c->app->log->info($c->log_req);
@@ -111,6 +101,9 @@ sub main {
sub do_display {
$adb = esmith::AccountsDB->open() || die "Couldn't open accounts db";
$cdb = esmith::ConfigDB->open() || die "Couldn't open config db";
my $c = shift;
$c->app->log->info($c->log_req);
@@ -142,11 +135,13 @@ sub do_display {
$wh_datas{fileupload} = get_current_value($c, $ibay, 'FileUpload');
$wh_datas{allowphtml} = get_current_value($c, $ibay, 'AllowPHTML');
$wh_datas{mailforcesender} = $rec->prop('MailForceSender');
my $df = ($rec->prop('DisabledFunctions'))? $rec->prop('DisabledFunctions') : $defaultdisabledfunc;
my $df = (defined $rec->prop('DisabledFunctions'))? $rec->prop('DisabledFunctions') : $defaultdisabledfunc;
$wh_datas{disabledfunctions} = $df; # yes we want todo this one this way.
$wh_datas{phpbasedir} = $rec->prop('PHPBaseDir'); # yes we keep this one simple
$wh_datas{moddav} = get_current_value($c, $ibay, 'ModDav');
$wh_datas{phpversion} = get_current_php_value($c, $ibay, 'PHPVersion');
$wh_datas{DisplayErrors} = get_current_value($c, $ibay, 'DisplayErrors');
$wh_datas{ErrorReporting} = (defined $rec->prop('ErrorReporting') ) ? $rec->prop('ErrorReporting') : $defaultproperties{ErrorReporting};
# we set phpversion using function called by cgi file
}
@@ -217,6 +212,9 @@ sub do_action {
sub modify_ibay {
$adb = esmith::AccountsDB->open() || die "Couldn't open accounts db";
$cdb = esmith::ConfigDB->open() || die "Couldn't open config db";
my ($c, $name) = @_;
my $msg;
@@ -242,10 +240,12 @@ sub modify_ibay {
MailForceSender => 'mailforcesender',
DisabledFunctions => 'disabledfunctions',
PHPBaseDir => 'phpbasedir',
DisplayErrors => 'DisplayErrors',
ErrorReporting => 'ErrorReporting',
);
foreach my $prop (keys %doing) {
my $value = $c->param($doing{$prop});
$value = "" if ( $value eq "$BASEPHP" && $prop eq 'PHPVersion');
$value = "" if ( $value eq $BASEPHP && $prop eq 'PHPVersion');
my $default = $defaultproperties{$prop} || "";
# exceptions to handle
# DisabledFunctions if equal def delprop
@@ -253,6 +253,14 @@ sub modify_ibay {
$acct->delete_prop($prop) ;
next;
}
if ($prop eq 'DisplayErrors' && $value eq $default) {
$acct->delete_prop($prop) ;
next;
}
if ($prop eq 'ErrorReporting' && $value eq $default) {
$acct->delete_prop($prop) ;
next;
}
# MailForceSender if empty delprop
if ($prop eq 'MailForceSender' && $value eq "" ) {
$acct->delete_prop($prop) ;
@@ -288,12 +296,14 @@ sub modify_ibay {
sub get_current_value{
$adb = esmith::AccountsDB->open() || die "Couldn't open accounts db";
$cdb = esmith::ConfigDB->open() || die "Couldn't open config db";
my ($c, $name, $property) = @_;
my $ibay = $adb->get($name);
my $key = $ibay->key;
my $default = $defaultproperties{$property} || "";
$default =~ s/\$key/$key/g if $property eq "PHPBaseDir";
my $value = ($ibay->prop($property))? $ibay->prop($property) : "default" ;
my $value = (defined $ibay->prop($property))? $ibay->prop($property) : "default" ;
return $value;
}
@@ -329,6 +339,7 @@ sub validate_up_post{
sub get_current_php_value {
$adb = esmith::AccountsDB->open() || die "Couldn't open accounts db";
my ($c, $name) = @_;
my $ibay= $adb->get($name);
return "default" unless defined $ibay->prop('PHPVersion');
@@ -356,6 +367,8 @@ sub get_php_options {
sub print_options {
$adb = esmith::AccountsDB->open() || die "Couldn't open accounts db";
my ($c, $property) = @_;
my $translate = $c->l('wh_DEFAULT');
@@ -380,6 +393,8 @@ sub print_options {
sub print_disabledfunctions {
$adb = esmith::AccountsDB->open() || die "Couldn't open accounts db";
my ($c) = @_;
my $translate = $c->l('wh_DESC_DISABLEDFUNCTIONS');
my $name = $c->param('ibay');
@@ -391,6 +406,8 @@ sub print_disabledfunctions {
sub print_phpbasedir {
$adb = esmith::AccountsDB->open() || die "Couldn't open accounts db";
my ($c) = @_;
my $translate = $c->l('wh_DESC_PHPBASEDIR');
my $name = $c->param('ibay');

View File

@@ -83,3 +83,5 @@
'wh_MAILFORCESENDER' => 'Force an email sender address for the script in this I-bay.',
'wh_DISABLEDFUNCTIONS' => 'List of php disabled functions (disable_functions)',
'wh_DESC_DISABLEDFUNCTIONS' => 'Leave empty or with a random string to disable. Copy and paste the following default list to reset to default',
'wh_DisplayErrors' => 'PHP Display Errors (DisplayErrors)',
'wh_ErrorReporting' => 'PHP Error Reporting (ErrorReporting)'

View File

@@ -112,6 +112,21 @@
%= select_field 'allowphtml' => $c->print_options('AllowPHTML'), class => 'input'
<br></span></p>
<p><span class=label>
%=l 'wh_DisplayErrors'
</span><span class=data>
% param 'DisplayErrors' => $wh_datas->{DisplayErrors} unless param 'DisplayErrors';
%= select_field 'DisplayErrors' => $c->print_options('DisplayErrors'), class => 'input'
<br></span></p>
<p><span class=label>
%=l 'wh_ErrorReporting'
</span><span class=data>
% param 'ErrorReporting' => $wh_datas->{ErrorReporting} unless param 'ErrorReporting';
%=text_field 'ErrorReporting' => size => '60', class => 'input'
<br></span></p>
<p><span class=label>
%=l 'wh_MAILFORCESENDER'
</span><span class=data>

View File

@@ -1,6 +1,6 @@
%define name smeserver-webhosting
%define version 11.0.0
%define release 2
%define release 3
Name: %{name}
Version: %{version}
@@ -54,6 +54,11 @@ fi
%defattr(-,root,root)
%changelog
* Fri Sep 26 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-3.sme
- fix smanager caching issue [SME: 13098]
- fix Disabled functions displays [SME: 12347]
- add ErrorReporting and DisplayErrors [SME: 11692]
* Thu Apr 17 2025 Brian Read <brianr@koozali.org> 11.0.0-2.sme
- Alter call to config as required for newer mojo [SME: 12908]