summaryrefslogtreecommitdiffstats
path: root/selinux.php
diff options
context:
space:
mode:
Diffstat (limited to 'selinux.php')
-rw-r--r--selinux.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/selinux.php b/selinux.php
new file mode 100644
index 0000000..7443f95
--- /dev/null
+++ b/selinux.php
@@ -0,0 +1,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());