From 0cc57b5184beb399450a9d760564c6960cbce776 Mon Sep 17 00:00:00 2001 From: Jesse Norell Date: Tue, 15 Sep 2020 14:36:16 -0600 Subject: [PATCH] allow sendmail_path php directive to work --- server/conf/php_fpm_pool.conf.master | 2 ++ server/conf/vhost.conf.master | 2 ++ server/plugins-available/apache2_plugin.inc.php | 15 ++++++++++++++- server/plugins-available/nginx_plugin.inc.php | 3 +++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/server/conf/php_fpm_pool.conf.master b/server/conf/php_fpm_pool.conf.master index 88b9e2b639..f2417e87bb 100644 --- a/server/conf/php_fpm_pool.conf.master +++ b/server/conf/php_fpm_pool.conf.master @@ -44,8 +44,10 @@ env[PATH] = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin php_admin_value[session.save_path] = /tmp php_admin_value[upload_tmp_dir] = /tmp + php_admin_value[sendmail_path] = "/usr/sbin/sendmail -t -i -f webmaster@" + diff --git a/server/conf/vhost.conf.master b/server/conf/vhost.conf.master index 692257848c..aafb3fcb5a 100644 --- a/server/conf/vhost.conf.master +++ b/server/conf/vhost.conf.master @@ -252,7 +252,9 @@ SetEnv TMP /tmp SetEnv TMPDIR /tmp SetEnv TEMP /tmp + php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -fwebmaster@" + php_admin_value upload_tmp_dir /tmp php_admin_value session.save_path /tmp # PHPIniDir diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php index f6403b7969..882b39903a 100644 --- a/server/plugins-available/apache2_plugin.inc.php +++ b/server/plugins-available/apache2_plugin.inc.php @@ -1176,6 +1176,7 @@ class apache2_plugin { //* Create custom php.ini if(trim($data['new']['custom_php_ini']) != '') { $has_custom_php_ini = true; + $custom_sendmail_path = false; if(!is_dir($custom_php_ini_dir)) $app->system->mkdirpath($custom_php_ini_dir); $php_ini_content = $this->get_master_php_ini_content($data['new']); @@ -1200,6 +1201,13 @@ class apache2_plugin { } } + $custom_sendmail_path = false; + $line = strtok($php_ini_content, '\n'); + while ($line !== false) { + if (strpos($line, 'sendmail_path') === 0) $custom_sendmail_path = true; + $line = strtok('\n'); + } + $app->system->file_put_contents($custom_php_ini_dir.'/php.ini', $php_ini_content); } else { $has_custom_php_ini = false; @@ -1244,7 +1252,7 @@ class apache2_plugin { $trans = array( '{DOCROOT}' => $vhost_data['web_document_root_www'], '{DOCROOT_CLIENT}' => $vhost_data['web_document_root'], - '{DOMAIN}' => $vhost_data['domain'] + '{DOMAIN}' => $vhost_data['domain'] ); $vhost_data['apache_directives'] = strtr($vhost_data['apache_directives'], $trans); @@ -1309,6 +1317,8 @@ class apache2_plugin { $vhost_data['seo_redirect_enabled'] = 0; } + $vhost_data['custom_sendmail_path'] = (isset($custom_sendmail_path) && $custom_sendmail_path) ? 'y' : 'n'; + $tpl->setVar($vhost_data); $tpl->setVar('apache_version', $app->system->getapacheversion()); @@ -3366,6 +3376,7 @@ class apache2_plugin { } $custom_session_save_path = false; + $custom_sendmail_path = false; if($custom_php_ini_settings != ''){ // Make sure we only have Unix linebreaks $custom_php_ini_settings = str_replace("\r\n", "\n", $custom_php_ini_settings); @@ -3383,6 +3394,7 @@ class apache2_plugin { if($value != ''){ $key = trim($key); if($key == 'session.save_path') $custom_session_save_path = true; + if($key == 'sendmail_path') $custom_sendmail_path = true; switch (strtolower($value)) { case '0': // PHP-FPM might complain about invalid boolean value if you use 0 @@ -3405,6 +3417,7 @@ class apache2_plugin { } $tpl->setVar('custom_session_save_path', ($custom_session_save_path ? 'y' : 'n')); + $tpl->setVar('custom_sendmail_path', ($custom_sendmail_path ? 'y' : 'n')); $tpl->setLoop('custom_php_ini_settings', $final_php_ini_settings); diff --git a/server/plugins-available/nginx_plugin.inc.php b/server/plugins-available/nginx_plugin.inc.php index 590e5baf3e..28611ce178 100644 --- a/server/plugins-available/nginx_plugin.inc.php +++ b/server/plugins-available/nginx_plugin.inc.php @@ -2954,6 +2954,7 @@ class nginx_plugin { } $custom_session_save_path = false; + $custom_sendmail_path = false; if($custom_php_ini_settings != ''){ // Make sure we only have Unix linebreaks $custom_php_ini_settings = str_replace("\r\n", "\n", $custom_php_ini_settings); @@ -2971,6 +2972,7 @@ class nginx_plugin { if($value != ''){ $key = trim($key); if($key == 'session.save_path') $custom_session_save_path = true; + if($key == 'sendmail_path') $custom_sendmail_path = true; switch (strtolower($value)) { case '0': // PHP-FPM might complain about invalid boolean value if you use 0 @@ -2993,6 +2995,7 @@ class nginx_plugin { } $tpl->setVar('custom_session_save_path', ($custom_session_save_path ? 'y' : 'n')); + $tpl->setVar('custom_sendmail_path', ($custom_sendmail_path ? 'y' : 'n')); $tpl->setLoop('custom_php_ini_settings', $final_php_ini_settings); -- GitLab