From 4c9669b732db933a367b3c17ce52dc6022305a27 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Pialasse Date: Fri, 26 Sep 2025 01:22:54 -0400 Subject: [PATCH] * Fri Sep 26 2025 Jean-Philippe Pialasse 11.0.0-3.sme - fix smanager caching issue [SME: 13098] - fix Disabled functions displays [SME: 12347] - add ErrorReporting and DisplayErrors [SME: 11692] --- .../lib/SrvMngr/Controller/Webhosting.pm | 251 ++++++++++-------- .../I18N/Modules/Webhosting/webhosting_en.lex | 2 + .../templates/partials/_wh_upd.html.ep | 15 ++ smeserver-webhosting.spec | 7 +- 4 files changed, 157 insertions(+), 118 deletions(-) diff --git a/root/usr/share/smanager/lib/SrvMngr/Controller/Webhosting.pm b/root/usr/share/smanager/lib/SrvMngr/Controller/Webhosting.pm index 975ad35..d47a86d 100644 --- a/root/usr/share/smanager/lib/SrvMngr/Controller/Webhosting.pm +++ b/root/usr/share/smanager/lib/SrvMngr/Controller/Webhosting.pm @@ -24,35 +24,20 @@ 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"; +my ($adb,$cdb); -#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', - - ModDav => "disabled", - AllowOverride => "None", - FollowSymLinks => "disabled", - Indexes => "enabled", - ); +# 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. our %sizehash = ('20M' => 'S0020MB', '30M' => 'S0030MB', '40M' => 'S0040MB', '50M' => 'S0050MB', @@ -79,20 +64,25 @@ our %optionsproperties =( DisabledFunctions => $defaultdisabledfunc, AllowPHTML => {%binary}, ModDav => {%binary}, - AllowOverride => { None =>'None' , - All => 'All', - AuthConfig => 'AuthConfig', - FileInfo => 'FileInfo', - Indexes => 'Indexes', - Limit => 'Limit', - 'FileInfo Indexes' => 'FileInfo Indexes', - }, + AllowOverride => { None =>'None' , + All => 'All', + AuthConfig => 'AuthConfig', + FileInfo => 'FileInfo', + Indexes => 'Indexes', + Limit => 'Limit', + 'FileInfo Indexes' => 'FileInfo Indexes', + }, 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); @@ -126,36 +119,38 @@ sub do_display { if ( $trt eq 'UPD' ) { - my $rec = $adb->get($ibay); - if ($rec and $rec->prop('type') eq 'ibay') { - $wh_datas{ibay} = $ibay; - $wh_datas{description} = $rec->prop('Name'); - $wh_datas{indexes} = get_current_value($c, $ibay, 'Indexes'); - $wh_datas{followsymLinks} = get_current_value($c, $ibay, 'FollowSymLinks'); - $wh_datas{allowoverride} = get_current_value($c, $ibay, 'AllowOverride'); - $wh_datas{allowurlfopen} = get_current_value($c, $ibay, 'AllowUrlFopen'); - $wh_datas{memorylimit} = get_current_value($c, $ibay, 'MemoryLimit'); - $wh_datas{uploadmaxfilesize} = get_current_value($c, $ibay, 'UploadMaxFilesize'); - $wh_datas{postmaxsize} = get_current_value($c, $ibay, 'PostMaxSize'); - $wh_datas{maxexecutiontime} = get_current_value($c, $ibay, 'MaxExecutionTime'); - $wh_datas{maxinputtime} = get_current_value($c, $ibay, 'MaxInputTime'); - $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; - $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'); - # we set phpversion using function called by cgi file - } + my $rec = $adb->get($ibay); + if ($rec and $rec->prop('type') eq 'ibay') { + $wh_datas{ibay} = $ibay; + $wh_datas{description} = $rec->prop('Name'); + $wh_datas{indexes} = get_current_value($c, $ibay, 'Indexes'); + $wh_datas{followsymLinks} = get_current_value($c, $ibay, 'FollowSymLinks'); + $wh_datas{allowoverride} = get_current_value($c, $ibay, 'AllowOverride'); + $wh_datas{allowurlfopen} = get_current_value($c, $ibay, 'AllowUrlFopen'); + $wh_datas{memorylimit} = get_current_value($c, $ibay, 'MemoryLimit'); + $wh_datas{uploadmaxfilesize} = get_current_value($c, $ibay, 'UploadMaxFilesize'); + $wh_datas{postmaxsize} = get_current_value($c, $ibay, 'PostMaxSize'); + $wh_datas{maxexecutiontime} = get_current_value($c, $ibay, 'MaxExecutionTime'); + $wh_datas{maxinputtime} = get_current_value($c, $ibay, 'MaxInputTime'); + $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 = (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 + } } if ( $trt eq 'LIST' ) { - my @ibays = $adb->ibays(); + my @ibays = $adb->ibays(); $c->stash( ibays => \@ibays ); - } + } $c->stash( title => $title, modul => $modul, wh_datas => \%wh_datas ); $c->render( template => 'webhosting' ); @@ -182,29 +177,29 @@ sub do_action { if ( $trt eq 'UPD' ) { - my $name = ($c->param('ibay') || ''); + my $name = ($c->param('ibay') || ''); - # controls - $res = validate_up_post( $c ); - $result .= $res unless $res eq 'OK'; + # controls + $res = validate_up_post( $c ); + $result .= $res unless $res eq 'OK'; - if ( ! $result ) { - $res = modify_ibay( $c, $name ); - $result .= $res unless $res eq 'OK'; - if ( ! $result ) { - $result = $c->l('wh_SUCCESSFULLY_MODIFIED_IBAY') . ' ' . $name; - $wh_datas{trt} = 'LST'; - } - } + if ( ! $result ) { + $res = modify_ibay( $c, $name ); + $result .= $res unless $res eq 'OK'; + if ( ! $result ) { + $result = $c->l('wh_SUCCESSFULLY_MODIFIED_IBAY') . ' ' . $name; + $wh_datas{trt} = 'LST'; + } + } } # common parts if ($res ne 'OK') { - $c->stash( error => $result ); - $c->stash( title => $title, wh_datas => \%wh_datas ); - return $c->render('webhosting'); + $c->stash( error => $result ); + $c->stash( title => $title, wh_datas => \%wh_datas ); + return $c->render('webhosting'); } my $message = "'Ibays' updates ($trt) DONE"; @@ -217,12 +212,15 @@ 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; my $acct = $adb->get($name); if ( ! $acct or $acct->prop('type') ne 'ibay') { - return $c->l('wh_CANT_FIND_IBAY') if $msg ne 'OK'; + return $c->l('wh_CANT_FIND_IBAY') if $msg ne 'OK'; } # real & current ibay @@ -242,34 +240,44 @@ 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'); - my $default = $defaultproperties{$prop} || ""; - # exceptions to handle - # DisabledFunctions if equal def delprop - if ($prop eq 'DisabledFunctions' && $value eq $default) { - $acct->delete_prop($prop) ; - next; - } - # MailForceSender if empty delprop - if ($prop eq 'MailForceSender' && $value eq "" ) { - $acct->delete_prop($prop) ; - next - } - # PHPBaseDir if empty delprop - if ($prop eq 'PHPBaseDir' && $value eq "" ) { + my $value = $c->param($doing{$prop}); + $value = "" if ( $value eq $BASEPHP && $prop eq 'PHPVersion'); + my $default = $defaultproperties{$prop} || ""; + # exceptions to handle + # DisabledFunctions if equal def delprop + if ($prop eq 'DisabledFunctions' && $value eq $default) { + $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) ; next - } - # others if == default delprop - if ($value eq "default") { - $acct->delete_prop($prop) ; - next; - } - $acct->merge_props($prop => $value); - #TODO store them in a hash and call merge_props once + } + # PHPBaseDir if empty delprop + if ($prop eq 'PHPBaseDir' && $value eq "" ) { + $acct->delete_prop($prop) ; + next + } + # others if == default delprop + if ($value eq "default") { + $acct->delete_prop($prop) ; + next; + } + $acct->merge_props($prop => $value); + #TODO store them in a hash and call merge_props once } # Untaint $name before use in system() @@ -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; } @@ -310,25 +320,26 @@ sub validate_up_post{ my $c = shift; my $upmaxfilesize = $c->param('uploadmaxfilesize'); my $postmaxsizeform = $c->param('postmaxsize'); -##set value to "0M" if disabled in order to compare uploadmaxfilesize and postmaxsize - $upmaxfilesize = "0M" if $upmaxfilesize eq 'disabled'; - $upmaxfilesize = $defaultproperties{'UploadMaxFilesize'} if $upmaxfilesize eq 'default'; - $postmaxsizeform = "0M" if $postmaxsizeform eq 'disabled'; - $postmaxsizeform =$defaultproperties{'PostMaxSize'} if $postmaxsizeform eq 'default'; -##remove the 'M' unit + ##set value to "0M" if disabled in order to compare uploadmaxfilesize and postmaxsize + $upmaxfilesize = "0M" if $upmaxfilesize eq 'disabled'; + $upmaxfilesize = $defaultproperties{'UploadMaxFilesize'} if $upmaxfilesize eq 'default'; + $postmaxsizeform = "0M" if $postmaxsizeform eq 'disabled'; + $postmaxsizeform =$defaultproperties{'PostMaxSize'} if $postmaxsizeform eq 'default'; + ##remove the 'M' unit my $upmaxfilesizechop = chop($upmaxfilesize); my $postmaxsizeformchop = chop($postmaxsizeform); -##test the condition - if ( $upmaxfilesize > $postmaxsizeform ) { - return $c->l('wh_UPLOADMAXFILESIZE_IS_GREATER_THAN_POSTMAXSIZE'); - } else { - return "OK"; - } + ##test the condition + if ( $upmaxfilesize > $postmaxsizeform ) { + return $c->l('wh_UPLOADMAXFILESIZE_IS_GREATER_THAN_POSTMAXSIZE'); + } else { + return "OK"; + } } 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'); @@ -345,7 +356,7 @@ sub get_php_options { # transform options list my @opts = [ "$translate: ".PHPdefault(), 'default' ]; foreach my $key ( sort keys %opts ) { - push @opts, [ $opts{$key}, $key ]; + push @opts, [ $opts{$key}, $key ]; } # push @opts, [ "$translate: ".PHPdefault(), 'default' ]; @@ -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'); @@ -369,7 +382,7 @@ sub print_options { # transform options list my @opts; foreach my $key ( sort keys %{$optionsproperties{$property}} ) { - push @opts, [ $c->l($optionsproperties{$property}{$key}), $key ]; + push @opts, [ $c->l($optionsproperties{$property}{$key}), $key ]; } push @opts, ["$translate: ".$default => 'default']; @@ -380,10 +393,12 @@ 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'); - my $ibay= $adb->get($name); # ?? + my $ibay= $adb->get($name); # ?? return "$translate : ". $defaultdisabledfunc ; } @@ -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'); diff --git a/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Webhosting/webhosting_en.lex b/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Webhosting/webhosting_en.lex index 67d8678..55ab2c6 100644 --- a/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Webhosting/webhosting_en.lex +++ b/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Webhosting/webhosting_en.lex @@ -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)' diff --git a/root/usr/share/smanager/themes/default/templates/partials/_wh_upd.html.ep b/root/usr/share/smanager/themes/default/templates/partials/_wh_upd.html.ep index 031ce8d..6399b80 100644 --- a/root/usr/share/smanager/themes/default/templates/partials/_wh_upd.html.ep +++ b/root/usr/share/smanager/themes/default/templates/partials/_wh_upd.html.ep @@ -112,6 +112,21 @@ %= select_field 'allowphtml' => $c->print_options('AllowPHTML'), class => 'input'

+

+ %=l 'wh_DisplayErrors' + + % param 'DisplayErrors' => $wh_datas->{DisplayErrors} unless param 'DisplayErrors'; + %= select_field 'DisplayErrors' => $c->print_options('DisplayErrors'), class => 'input' +

+ +

+ %=l 'wh_ErrorReporting' + + % param 'ErrorReporting' => $wh_datas->{ErrorReporting} unless param 'ErrorReporting'; + %=text_field 'ErrorReporting' => size => '60', class => 'input' +

+ +

%=l 'wh_MAILFORCESENDER' diff --git a/smeserver-webhosting.spec b/smeserver-webhosting.spec index 78abd84..59b3f51 100644 --- a/smeserver-webhosting.spec +++ b/smeserver-webhosting.spec @@ -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 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 11.0.0-2.sme - Alter call to config as required for newer mojo [SME: 12908]