Detect if piwigo is running in a container

Append info on PHP_OS in the template of `admin/maintenance_env.php` and in `include/functions.inc.php` -> `send_piwigo_infos()`

Detection works by checking if PHP is running on Linux then check if PID2 is kthreadd
Kthreadd is useless in a container so PID2 should not exist of be another process
If unable to read /proc/2/sched for some reason, assume a SELinux restriction and that PHP is not running in a container

`is_in_container()` doesn't differentiate between VMs or bare metal, it only check if PHP is running in a containerized environement via tools like docker/podman/....
This commit is contained in:
Renarde-dev
2025-09-05 11:50:27 +02:00
parent 171e31bea4
commit dc86f2be5c
2 changed files with 41 additions and 3 deletions
+1 -1
View File
@@ -288,7 +288,7 @@ $template->assign(
'PHPWG_URL' => PHPWG_URL,
'PWG_VERSION' => PHPWG_VERSION,
'U_CHECK_UPGRADE' => sprintf($url_format, 'check_upgrade'),
'OS' => PHP_OS,
'OS' => PHP_OS.((is_in_container()) ? " (container)" : ""),
'PHP_VERSION' => phpversion(),
'DB_ENGINE' => 'MySQL',
'DB_VERSION' => $db_version,