xref: /PHP-8.1/sapi/fpm/tests/socket-uds-acl.phpt (revision d679f022)
1--TEST--
2FPM: Unix Domain Socket with Posix ACL
3--SKIPIF--
4<?php
5include "skipif.inc";
6FPM\Tester::skipIfAnyFileDoesNotExist(['/usr/bin/getfacl', '/etc/passwd', '/etc/group']);
7$config = <<<EOT
8[global]
9error_log = /dev/null
10[unconfined]
11listen = {{ADDR}}
12listen.acl_users = nobody
13listen.acl_groups = nobody
14listen.mode = 0600
15pm = dynamic
16pm.max_children = 5
17pm.start_servers = 2
18pm.min_spare_servers = 1
19pm.max_spare_servers = 3
20EOT;
21FPM\Tester::skipIfConfigFails($config);
22?>
23--FILE--
24<?php
25
26require_once "tester.inc";
27
28// Select 3 users and 2 groups known by system (avoid root)
29$users = $groups = [];
30$tmp = file('/etc/passwd');
31for ($i=1 ; $i <= 3 ; $i++) {
32    $tab = explode(':', $tmp[$i]);
33    $users[] = $tab[0];
34}
35$users = implode(',', $users);
36$tmp = file('/etc/group');
37for ($i=1 ; $i <= 2 ; $i++) {
38    $tab = explode(':', $tmp[$i]);
39    $groups[] = $tab[0];
40}
41$groups = implode(',', $groups);
42
43$cfg = <<<EOT
44[global]
45error_log = {{FILE:LOG}}
46[unconfined]
47listen = {{ADDR:UDS}}
48listen.acl_users = $users
49listen.acl_groups = $groups
50listen.mode = 0600
51ping.path = /ping
52ping.response = pong
53pm = dynamic
54pm.max_children = 5
55pm.start_servers = 2
56pm.min_spare_servers = 1
57pm.max_spare_servers = 3
58EOT;
59
60$tester = new FPM\Tester($cfg);
61$tester->start();
62$tester->expectLogStartNotices();
63$tester->ping('{{ADDR:UDS}}');
64passthru("/usr/bin/getfacl -cp " . $tester->getListen('{{ADDR:UDS}}'));
65$tester->terminate();
66$tester->expectLogTerminatingNotices();
67$tester->close();
68
69?>
70Done
71--EXPECTF--
72user::rw-
73user:%s:rw-
74user:%s:rw-
75user:%s:rw-
76group::---
77group:%s:rw-
78group:%s:rw-
79mask::rw-
80other::---
81
82Done
83--CLEAN--
84<?php
85require_once "tester.inc";
86FPM\Tester::clean();
87?>
88