xref: /PHP-7.0/sapi/fpm/tests/apparmor.phpt (revision a7ec000f)
1--TEST--
2FPM: Apparmor Test
3--DESCRIPTION--
4This test tries to launches a pool which tries to change to non existing
5apparmor hat a. Test succeeds if apparmor is not running or hat is non
6existent.
7--SKIPIF--
8<?php
9include "skipif.inc";
10include "skipapparmor.inc";
11
12?>
13--FILE--
14<?php
15
16include "include.inc";
17
18$logfile = dirname(__FILE__).'/php-fpm.log.tmp';
19
20$cfg = <<<EOT
21[global]
22error_log = $logfile
23[a]
24listen = 127.0.0.1:9001
25pm = dynamic
26pm.max_children = 5
27pm.start_servers = 2
28pm.min_spare_servers = 1
29pm.max_spare_servers = 3
30apparmor_hat = a
31EOT;
32
33/* libapparmor has a bug which can cause SIGSEGV till Version 2.8.0-0ubuntu28
34   See https://bugs.launchpad.net/apparmor/+bug/1196880
35   Possible outcomes:
36
37   - SIGSEGV|failed to query apparmor confinement
38     apparmor not running
39   - failed to change to new confinement
40     something in apparmor went wrong
41   - exited with code 70
42     Change to successful; Hat not existent (Process gets killed by apparmor)
43 */
44var_dump(run_fpm_till('/(SIGSEGV|failed to query apparmor confinement|failed to change to new confinement|exited with code 70)/', $cfg));
45
46?>
47--EXPECTF--
48string(%d) "%s
49"
50--CLEAN--
51<?php
52    $logfile = dirname(__FILE__).'/php-fpm.log.tmp';
53    @unlink($logfile);
54?>
55