summaryrefslogtreecommitdiffstats
path: root/selinux.php
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2019-10-25 12:07:15 +0200
committerRemi Collet <remi@remirepo.net>2019-10-25 12:07:15 +0200
commit0e40a793f2452276bf18ed70d6206898d620c13f (patch)
tree424254d29c6b782827b186d888560c80ea37a0a3 /selinux.php
parent47cb18001f6777b2c149c819497a3e8ed7edca81 (diff)
add SELinux example (wip)
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());