diff -Nur smeserver-php-3.0.0.old/root/etc/e-smith/events/actions/php-pool-customs smeserver-php-3.0.0/root/etc/e-smith/events/actions/php-pool-customs --- smeserver-php-3.0.0.old/root/etc/e-smith/events/actions/php-pool-customs 2021-02-21 00:19:19.175000000 -0500 +++ smeserver-php-3.0.0/root/etc/e-smith/events/actions/php-pool-customs 2021-02-21 00:22:17.981000000 -0500 @@ -4,6 +4,7 @@ use warnings; use File::Path qw(make_path remove_tree); use esmith::ConfigDB; +use esmith::util; my $pool_db = esmith::ConfigDB->open_ro('php') || esmith::ConfigDB->create('php'); @@ -16,9 +17,12 @@ "/var/lib/php/$key/wsdlcache", "/var/lib/php/$key/opcache", "/var/lib/php/$key/tmp" ); - make_path( @dirs, { - owner => 'root', - group => 'www' - }); + for (@dirs){ + esmith::util::chownFile("root", "www", $_) if -e $_; + make_path( $_, { + owner => 'root', + group => 'www' + }) unless -e $_; + } chmod 0770, @dirs; } diff -Nur smeserver-php-3.0.0.old/root/etc/e-smith/events/actions/php-pool-dirs smeserver-php-3.0.0/root/etc/e-smith/events/actions/php-pool-dirs --- smeserver-php-3.0.0.old/root/etc/e-smith/events/actions/php-pool-dirs 2021-02-21 00:19:19.321000000 -0500 +++ smeserver-php-3.0.0/root/etc/e-smith/events/actions/php-pool-dirs 2021-02-21 00:21:57.740000000 -0500 @@ -4,39 +4,49 @@ use warnings; use esmith::AccountsDB; use File::Path qw(make_path remove_tree); +use esmith::util; my $a = esmith::AccountsDB->open_ro || die "Couldn't open the accounts database\n"; my $event = shift; -my $pool = shift; +my $apool = shift; -die "Missing pool name argument" unless $pool; +my @pools = (defined $apool && $a->get($apool) ) ? map { $a->get($_); } $apool : ( $a->get_all_by_prop(type => "ibay" ) , $a->get_all_by_prop(type => "share" ));# unless $acc; -my $acc = $a->get($pool); - -die "$pool not found in the account database\n" unless $acc; -my $type = $acc->prop('type'); -my $dyn = 'disabled'; -if ( $type eq "ibay") { - $dyn = $acc->prop('CgiBin') || 'disabled'; -} -else { - $dyn = $acc->prop('DynamicContent') || 'disabled'; -} - -if ($dyn =~ m/^enabled|on|1|yes$/ && $event ne 'share-delete'){ - my @dirs = ( "/var/log/php/$pool", +foreach my $acc (@pools){ + my $pool = $acc->key; + my $type = $acc->prop('type'); + my $dyn = 'disabled'; + if ( $type eq "ibay") { + $dyn = $acc->prop('CgiBin') || 'disabled'; + } + else { + $dyn = $acc->prop('DynamicContent') || 'disabled'; + } + + if ($dyn =~ m/^enabled|on|1|yes$/ && $event ne 'share-delete' && $event ne 'ibay-delete'){ + my @dirs = ( "/var/log/php/$pool", "/var/lib/php/$pool/session", "/var/lib/php/$pool/wsdlcache", "/var/lib/php/$pool/opcache", "/var/lib/php/$pool/tmp" ); - make_path( @dirs, { - owner => 'root', - group => 'www' - }); - chmod 0770, @dirs; + # create dir if does not exist; set owner and group if create it + # does not change ownership if folder already exists + for (@dirs){ + esmith::util::chownFile("root", "www", $_) if -e $_; + make_path( $_, { + owner => 'root', + group => 'www' + }) unless -e $_; + } + chmod 0770, @dirs; + } } -else{ - remove_tree( ( "/var/log/php/$pool", - " /var/lib/php/$pool/" ) ); + +if ( defined $event && defined $apool && ($event eq 'share-delete' || $event eq 'ibay-delete') ) { + my $acc = $a->get($apool); + die "$apool not found in the account database\n" unless $acc; + remove_tree( "/var/log/php/$apool", + "/var/lib/php/$apool" ); } +