Skip to content

Commit 0b3abd8

Browse files
author
Till Brehm
committed
Fixed #4828 Wrong group owner of FPM Socket on Centos with NGINX
1 parent aad778e commit 0b3abd8

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

server/plugins-available/nginx_plugin.inc.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2589,6 +2589,8 @@ private function hhvm_update($data, $web_config) {
25892589
private function php_fpm_pool_update ($data, $web_config, $pool_dir, $pool_name, $socket_dir) {
25902590
global $app, $conf;
25912591
$pool_dir = trim($pool_dir);
2592+
$rh_releasefiles = array('/etc/centos-release', '/etc/redhat-release');
2593+
25922594
// HHVM => PHP-FPM-Fallback
25932595
if($data['new']['php'] == 'php-fpm' || $data['new']['php'] == 'hhvm'){
25942596
if(trim($data['new']['fastcgi_php_version']) != ''){
@@ -2649,7 +2651,25 @@ private function php_fpm_pool_update ($data, $web_config, $pool_dir, $pool_name,
26492651
$tpl->setVar('fpm_pool', $pool_name);
26502652
$tpl->setVar('fpm_port', $web_config['php_fpm_start_port'] + $data['new']['domain_id'] - 1);
26512653
$tpl->setVar('fpm_user', $data['new']['system_user']);
2652-
$tpl->setVar('fpm_group', $data['new']['system_group']);
2654+
2655+
//Red Hat workaround for group ownership of socket files
2656+
foreach($rh_releasefiles as $rh_file) {
2657+
if(file_exists($rh_file) && (filesize($rh_file) > 0)) {
2658+
$tmp = file_get_contents($rh_file);
2659+
if(preg_match('/[67]+\.[0-9]+/m', $tmp)) {
2660+
$tpl->setVar('fpm_group', $data['new']['system_group']);
2661+
$tpl->setVar('fpm_listen_group', $data['new']['system_group']);
2662+
}
2663+
unset($tmp);
2664+
} elseif(!file_exists($rh_file)) {
2665+
//OS seems to be not Red Hat'ish
2666+
$tpl->setVar('fpm_group', $web_config['group']);
2667+
$tpl->setVar('fpm_listen_group', $web_config['group']);
2668+
}
2669+
break;
2670+
}
2671+
2672+
// $tpl->setVar('fpm_group', $web_config['group']);
26532673
$tpl->setVar('fpm_listen_user', $data['new']['system_user']);
26542674
$tpl->setVar('fpm_listen_group', $web_config['group']);
26552675
$tpl->setVar('fpm_domain', $data['new']['domain']);

0 commit comments

Comments
 (0)