diff -Nur --no-dereference smeserver-phplist-0.2.1.old/createlinks smeserver-phplist-0.2.1/createlinks
--- smeserver-phplist-0.2.1.old/createlinks 2020-03-18 13:12:54.000000000 -0400
+++ smeserver-phplist-0.2.1/createlinks 2022-08-02 22:34:17.079000000 -0400
@@ -6,7 +6,7 @@
templates2events("/etc/phplist/config.php", qw/webapps-update bootstrap-console-save/);
safe_symlink("/var/qmail/bin/qmail-newu", "root/etc/e-smith/events/webapps-update/S55phplist-qmail-assign");
-foreach my $event (qw/webapps-update ipasserelle-update bootstrap-ldap-save/){
+foreach my $event (qw/webapps-update bootstrap-ldap-save/){
event_link("phplist-create-pseudo", "$event", "55");
}
@@ -15,13 +15,37 @@
safe_symlink("/var/qmail/alias/.qmail-phplistbounces", "root/var/qmail/alias/.qmail-phplistbounces-default");
-safe_symlink("../daemontools" , 'root/etc/rc.d/init.d/supervise/phplist');
-safe_symlink("/var/service/phplist" , 'root/service/phplist');
-safe_touch("root/var/service/phplist/down");
safe_symlink("restart", "root/etc/e-smith/events/webapps-update/services2adjust/phplist");
-service_link_enhanced('phplist', 'S98', '7');
-service_link_enhanced('phplist', 'K12', '6');
-service_link_enhanced('phplist', 'K12', '0');
safe_touch("root/var/lib/phplist/bounces.mbox");
+
+my $event="smeserver-phplist-update";
+event_templates($event, qw(
+/etc/httpd/conf/httpd.conf
+/etc/opt/remi/php80/php-fpm.d/www.conf
+/etc/e-smith/sql/init/phplistdb
+/etc/phplist/config.php
+/etc/e-smith/sql/init/phplistdb
+));
+
+event_services($event, qw(
+ php80-php-fpm restart
+ httpd-e-smith restart
+ phplist restart
+ mysql.init restart
+));
+safe_symlink("/var/qmail/bin/qmail-newu", "root/etc/e-smith/events/$event/S93phplist-qmail-assign");
+
+event_actions($event, qw(
+ phplist-initialise 92
+ phplist-create-pseudo 93
+ systemd-default 88
+ systemd-reload 89
+));
+
+use esmith::Build::Backup qw(:all);
+backup_includes("smeserver-phplist-udpdate", qw(
+/var/lib/phplist
+/var/log/phplist
+));
diff -Nur --no-dereference smeserver-phplist-0.2.1.old/root/etc/e-smith/db/configuration/defaults/phplist/type smeserver-phplist-0.2.1/root/etc/e-smith/db/configuration/defaults/phplist/type
--- smeserver-phplist-0.2.1.old/root/etc/e-smith/db/configuration/defaults/phplist/type 2020-03-18 13:12:54.000000000 -0400
+++ smeserver-phplist-0.2.1/root/etc/e-smith/db/configuration/defaults/phplist/type 2022-08-02 22:37:07.129000000 -0400
@@ -1 +1 @@
-webapp
+service
diff -Nur --no-dereference smeserver-phplist-0.2.1.old/root/etc/e-smith/db/configuration/migrate/phplist-database smeserver-phplist-0.2.1/root/etc/e-smith/db/configuration/migrate/phplist-database
--- smeserver-phplist-0.2.1.old/root/etc/e-smith/db/configuration/migrate/phplist-database 2020-03-18 13:12:54.000000000 -0400
+++ smeserver-phplist-0.2.1/root/etc/e-smith/db/configuration/migrate/phplist-database 2022-08-03 01:38:38.247000000 -0400
@@ -24,4 +24,29 @@
}
$rec->set_prop('DbPassword', $pw);
}
+ my $apw = $rec->prop('AdminPass');
+ if (not $apw or length($apw) < 20){
+ use MIME::Base64 qw(encode_base64);
+ $apw = "not set due to error";
+ if ( open( RANDOM, "/dev/urandom" ) ){
+ my $buf;
+ # 57 bytes is a full line of Base64 coding, and contains
+ # 456 bits of randomness - given a perfectly random /dev/random
+ if ( read( RANDOM, $buf, 20 ) != 20 ){
+ warn("Short read from /dev/random: $!");
+ }
+ else{
+ $apw = encode_base64($buf);
+ chomp $apw;
+ }
+ close RANDOM;
+ }
+ else{
+ warn "Could not open /dev/urandom: $!";
+ }
+ $rec->set_prop('AdminPass', $apw);
+ }
+ my $type = $rec->prop("type");
+ $rec->set_prop("type","service") unless ($type eq "service");
+
}
diff -Nur --no-dereference smeserver-phplist-0.2.1.old/root/etc/e-smith/events/actions/phplist-initialise smeserver-phplist-0.2.1/root/etc/e-smith/events/actions/phplist-initialise
--- smeserver-phplist-0.2.1.old/root/etc/e-smith/events/actions/phplist-initialise 1969-12-31 19:00:00.000000000 -0500
+++ smeserver-phplist-0.2.1/root/etc/e-smith/events/actions/phplist-initialise 2022-08-03 01:38:37.976000000 -0400
@@ -0,0 +1,6 @@
+#!/bin/bash
+password=$(config getprop phplist AdminPass)
+domain=$(config get DomainName)
+ADMIN_PASSWORD=$password ADMIN_EMAIL=admin@$domain phplist -pinitialise
+phplist -pdbcheck
+phplist -pupgrade
diff -Nur --no-dereference smeserver-phplist-0.2.1.old/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98phplist smeserver-phplist-0.2.1/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98phplist
--- smeserver-phplist-0.2.1.old/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98phplist 2020-03-18 13:12:54.000000000 -0400
+++ smeserver-phplist-0.2.1/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98phplist 2022-08-03 01:38:38.772000000 -0400
@@ -6,11 +6,12 @@
my $alias = $phplist{'AliasOnPrimary'} || 'enabled';
my $ver = $sysconfig{'ReleaseVersion'} || '8.1';
-my $allow = ( $access eq 'public' ) ? 'all' : "$localAccess $externalSSLAccess";
+my $allow = ( $access eq 'public' ) ? 'all granted' : "ip $localAccess $externalSSLAccess";
$alias = ($alias ne 'enabled') ? '' : 'Alias /lists /usr/share/phplist/www/';
$auth = ( $auth eq 'http' ) ? 'AuthName "phplist"' . "\n" .
" AuthType Basic\n" .
- " AuthExternal pwauth\n" . (($ver =~ m/^9/) ? " AuthBasicProvider external\n":'') .
+ " AuthBasicProvider external\n".
+ " AuthExternal pwauth\n".
" require valid-user\n" : '';
if ($status eq 'enabled') {
@@ -22,44 +23,45 @@
Options None +FollowSymLinks
AllowOverride None
DirectoryIndex index.php
- AddType application/x-httpd-php .php .php3
- php_admin_value openbase_dir /usr/share/phplist:/var/lib/phplist:/tmp:/etc/phplist
- php_admin_flag file_uploads on
- php_admin_value upload_max_filesize 5M
- php_admin_value post_max_size 6M
- php_admin_value memory_limit 128M
- php_admin_value session.save_path /var/lib/phplist/tmp
- php_admin_value upload_tmp_dir /var/lib/phplist/tmp
+ AddType application/x-httpd-php .php
- Order allow,deny
- deny from all
+ Require all denied
- Order allow,deny
- allow from all
+ Require all granted
+ SetHandler "proxy:unix:/var/run/php-fpm/php80-phplist.sock|fcgi://localhost"
- Order deny,allow
- deny from all
- allow from $allow
+ Require $allow
# Admin section
SSLRequireSSL on
- Order allow,deny
- Deny from all
+ Require all denied
- Order allow,deny
- allow from all
+ SetHandler "proxy:unix:/var/run/php-fpm/php80-phplist.sock|fcgi://localhost"
+ Require all granted
- order deny,allow
- deny from all
- allow from $allow
- $auth
+ SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=\$1
+
+ Require $allow
+ $auth
+
+
+
+ Require $allow
+
+
+
+
+
+ Require $allow
+
+
EOF
}
diff -Nur --no-dereference smeserver-phplist-0.2.1.old/root/etc/e-smith/templates/etc/php-fpm.d/www.conf/15phplist smeserver-phplist-0.2.1/root/etc/e-smith/templates/etc/php-fpm.d/www.conf/15phplist
--- smeserver-phplist-0.2.1.old/root/etc/e-smith/templates/etc/php-fpm.d/www.conf/15phplist 1969-12-31 19:00:00.000000000 -0500
+++ smeserver-phplist-0.2.1/root/etc/e-smith/templates/etc/php-fpm.d/www.conf/15phplist 2022-08-03 01:38:39.035000000 -0400
@@ -0,0 +1,66 @@
+{
+
+if ($PHP_VERSION eq '80'){
+ if (($phplist{'status'} || 'disabled') eq 'enabled'){
+ my $max_upload_size = ($phplist{MaxUploadSize} || '6M');
+ $max_upload_size .= 'M' if ($max_upload_size =~ m/^\d+$/);
+ my $memory_limit = ($phplist{MemoryLimit} || '128M');
+ $memory_limit .= 'M' if ($memory_limit =~ m/^\d+$/);
+ my $open_basedir= $phplist{PHPBaseDir} || '';
+ $open_basedir = "/usr/share/phplist:/var/lib/phplist:/tmp:/etc/phplist:/var/log/phplist:/usr/share/php/auth_translation.php:$open_basedir";
+ my $id = 'phplist';
+ my $max_children = $phplist{'PHPmaxChildren'} || 20;
+ my $min_spare_servers = $phplist{'PHPminServers'} || 4;
+ my $start_servers = $phplist{'PHPstartServers'} || 6;
+ my $max_spare_servers = $phplist{'PHPmaxServers'} || 8;
+ my $max_requests = $phplist{'PHPmaxRequests'} || 1000;
+ $min_spare_servers = ( $min_spare_servers > $max_spare_servers ) ? printf("%.0f",$max_spare_servers/2) : $min_spare_servers;
+ $start_servers = ( $start_servers > $max_spare_servers ) ? printf("%.0f", $max_spare_servers /2 + $min_spare_servers/2 ) : $start_servers;
+
+ $OUT .=<<_EOF;
+
+[php$PHP_VERSION-$id]
+user = www
+group = www
+listen.owner = root
+listen.group = www
+listen.mode = 0660
+listen = /var/run/php-fpm/php$PHP_VERSION-$id.sock
+pm = dynamic
+pm.max_children = $max_children
+pm.start_servers = $start_servers
+pm.min_spare_servers = $min_spare_servers
+pm.max_spare_servers = $max_spare_servers
+pm.max_requests = $max_requests
+php_admin_value[auto_prepend_file] = /usr/share/php/auth_translation.php
+php_admin_value[session.save_path] = /var/lib/php/$id/session
+php_admin_value[session.gc_maxlifetime] = 86400
+php_admin_value[opcache.file_cache] = /var/lib/php/$id/opcache
+php_admin_value[upload_tmp_dir] = /var/lib/php/$id/tmp
+php_admin_value[error_log] = /var/log/php/$id/error.log
+slowlog = /var/log/php/phplist/slow.log
+php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f php@{ $DomainName }
+php_admin_flag[display_errors] = off
+php_admin_flag[log_errors] = on
+php_admin_value[error_log] = syslog
+php_admin_value[memory_limit] = $memory_limit
+php_admin_value[max_execution_time] = 3600
+php_admin_value[post_max_size] = $max_upload_size
+php_admin_value[upload_max_filesize] = $max_upload_size
+php_admin_value[disable_functions] = system, show_source, symlink, dl, passthru, phpinfo, escapeshellarg, escapeshellcmd
+php_admin_value[open_basedir] = $open_basedir
+php_admin_flag[allow_url_fopen] = on
+php_admin_flag[file_uploads] = on
+php_admin_flag[session.cookie_httponly] = on
+php_admin_flag[allow_url_include] = off
+php_admin_value[session.save_handler] = files
+php_admin_flag[output_buffering] = off
+
+_EOF
+
+ }
+ else{
+ $OUT .= '; phplist is disabled';
+ }
+}
+}
diff -Nur --no-dereference smeserver-phplist-0.2.1.old/root/usr/lib/systemd/system/phplist.service smeserver-phplist-0.2.1/root/usr/lib/systemd/system/phplist.service
--- smeserver-phplist-0.2.1.old/root/usr/lib/systemd/system/phplist.service 1969-12-31 19:00:00.000000000 -0500
+++ smeserver-phplist-0.2.1/root/usr/lib/systemd/system/phplist.service 2022-08-02 22:37:29.174000000 -0400
@@ -0,0 +1,13 @@
+[Unit]
+Description=phplist process queues
+After=network-online.target
+
+[Service]
+ExecStartPre=-/sbin/e-smith/service-status phplist
+ExecStart=/usr/sbin/e-smith/systemd/phplist
+Restart=always
+Restartsec=10s
+RemainAfterExit=yes
+
+[Install]
+WantedBy=sme-server.target
diff -Nur --no-dereference smeserver-phplist-0.2.1.old/root/usr/local/bin/phplist smeserver-phplist-0.2.1/root/usr/local/bin/phplist
--- smeserver-phplist-0.2.1.old/root/usr/local/bin/phplist 1969-12-31 19:00:00.000000000 -0500
+++ smeserver-phplist-0.2.1/root/usr/local/bin/phplist 2022-08-03 01:38:37.727000000 -0400
@@ -0,0 +1,2 @@
+#!/bin/bash
+/usr/bin/php80 /usr/share/phplist/www/admin/index.php -c /etc/phplist/config.php $*
diff -Nur --no-dereference smeserver-phplist-0.2.1.old/root/usr/sbin/e-smith/systemd/phplist smeserver-phplist-0.2.1/root/usr/sbin/e-smith/systemd/phplist
--- smeserver-phplist-0.2.1.old/root/usr/sbin/e-smith/systemd/phplist 1969-12-31 19:00:00.000000000 -0500
+++ smeserver-phplist-0.2.1/root/usr/sbin/e-smith/systemd/phplist 2022-08-03 01:38:38.509000000 -0400
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+exec 2>&1
+
+cd /usr/local/bin/
+while true; do
+ /usr/local/bin/setuidgid www ./phplist -pprocessbounces
+ /usr/local/bin/setuidgid www ./phplist -pprocessqueue
+ sleep 120
+done
diff -Nur --no-dereference smeserver-phplist-0.2.1.old/root/var/service/phplist/run smeserver-phplist-0.2.1/root/var/service/phplist/run
--- smeserver-phplist-0.2.1.old/root/var/service/phplist/run 2020-03-18 13:12:54.000000000 -0400
+++ smeserver-phplist-0.2.1/root/var/service/phplist/run 1969-12-31 19:00:00.000000000 -0500
@@ -1,10 +0,0 @@
-#!/bin/sh
-
-exec 2>&1
-
-cd /usr/share/phplist/bin
-while true; do
- /usr/local/bin/setuidgid www ./phplist -pprocessbounces
- /usr/local/bin/setuidgid www ./phplist -pprocessqueue
- sleep 120
-done