summaryrefslogtreecommitdiffstats
path: root/selinux.php
blob: 7443f957dce103faf8024ad8e5b9e39cc9551a28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php declare(strict_types=1);

/** 
 * SElinux test script
 * PoC, only for documentation purpose
 *
 * Copyright (c) 2019 Remi Collet
 * License: CC-BY-SA
 * http://creativecommons.org/licenses/by-sa/4.0/
 */

if (PHP_VERSION_ID < 70400 || !extension_loaded("ffi")) {
	die("PHP 7.4 with FFI required\n");
}
if (PHP_SAPI != "cli") {
	Header('Content-Type: text/plain');
}
printf("PHP version %s\n", PHP_VERSION);

if (PHP_SAPI == "cli" && !class_exists("\\Remi\\SELinux")) {
	printf("Fallback on manual load\n");
	require_once __DIR__ . '/preload-selinux.inc';
} else {
	printf("Use preloaded class\n");
}

printf("is_enabled = %s\n", \Remi\SELinux::is_enabled() ? "Yes" : "No");
printf("getenforce = %s\n", \Remi\SELinux::getenforce());