1--TEST-- 2FPM: Test Unix Domain Socket with Posix ACL 3--SKIPIF-- 4<?php 5include "skipif.inc"; 6if (!(file_exists('/usr/bin/getfacl') && file_exists('/etc/passwd') && file_exists('/etc/group'))) die ("skip missing getfacl command"); 7?> 8--XFAIL-- 9Mark as XFAIL because --with-fpm-acl is not enabled in default build 10--FILE-- 11<?php 12 13include "include.inc"; 14 15$logfile = dirname(__FILE__).'/php-fpm.log.tmp'; 16$socket = dirname(__FILE__).'/php-fpm.sock'; 17 18// Select 3 users and 2 groups known by system (avoid root) 19$users = $groups = []; 20$tmp = file('/etc/passwd'); 21for ($i=1 ; $i<=3 ; $i++) { 22 $tab = explode(':', $tmp[$i]); 23 $users[] = $tab[0]; 24} 25$users = implode(',', $users); 26$tmp = file('/etc/group'); 27for ($i=1 ; $i<=2 ; $i++) { 28 $tab = explode(':', $tmp[$i]); 29 $groups[] = $tab[0]; 30} 31$groups = implode(',', $groups); 32 33$cfg = <<<EOT 34[global] 35error_log = $logfile 36[unconfined] 37listen = $socket 38listen.acl_users = $users 39listen.acl_groups = $groups 40listen.mode = 0600 41ping.path = /ping 42ping.response = pong 43pm = dynamic 44pm.max_children = 5 45pm.start_servers = 2 46pm.min_spare_servers = 1 47pm.max_spare_servers = 3 48EOT; 49 50$fpm = run_fpm($cfg, $tail); 51if (is_resource($fpm)) { 52 fpm_display_log($tail, 2); 53 try { 54 var_dump(strpos(run_request('unix://'.$socket, -1), 'pong')); 55 echo "UDS ok\n"; 56 } catch (Exception $e) { 57 echo "UDS error\n"; 58 } 59 passthru("/usr/bin/getfacl -cp $socket"); 60 61 proc_terminate($fpm); 62 echo stream_get_contents($tail); 63 fclose($tail); 64 proc_close($fpm); 65} 66 67?> 68--EXPECTF-- 69[%s] NOTICE: fpm is running, pid %d 70[%s] NOTICE: ready to handle connections 71int(%d) 72UDS ok 73user::rw- 74user:%s:rw- 75user:%s:rw- 76user:%s:rw- 77group::--- 78group:%s:rw- 79group:%s:rw- 80mask::rw- 81other::--- 82 83[%s] NOTICE: Terminating ... 84[%s] NOTICE: exiting, bye-bye! 85--CLEAN-- 86<?php 87 $logfile = dirname(__FILE__).'/php-fpm.log.tmp'; 88 @unlink($logfile); 89?> 90