mirror of
https://github.com/unraid/webgui.git
synced 2026-01-04 16:40:21 -06:00
Fix: Don't autostart containers on host network with TS enabled
This commit is contained in:
@@ -1,2 +1,33 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/php
|
||||
<?
|
||||
# Invoked after docker image loopback mounted but before docker is started
|
||||
$autostart = @file("/var/lib/docker/unraid-autostart",FILE_IGNORE_NEW_LINES);
|
||||
if ( ! $autostart ) exit();
|
||||
|
||||
$newAuto = [];
|
||||
foreach ($autostart as $container) {
|
||||
if (! trim($container) ) continue;
|
||||
|
||||
$cont = explode(" ",$container);
|
||||
if ( ! is_file("/boot/config/plugins/dockerMan/templates-user/my-{$cont[0]}.xml")) {
|
||||
$newAuto[] = $container;
|
||||
continue;
|
||||
}
|
||||
|
||||
$doc = new DOMDocument();
|
||||
$doc->load("/boot/config/plugins/dockerMan/templates-user/my-{$cont[0]}.xml");
|
||||
if ( ! $doc ) {
|
||||
$newAuto[] = $container;
|
||||
continue;
|
||||
}
|
||||
if ( ($doc->getElementsByTagName("Network")->item(0)->nodeValue ?? false) == "host" ) {
|
||||
if ( ($doc->getElementsByTagName("TailscaleEnabled")->item(0)->nodeValue ?? false) == true ) {
|
||||
exec("logger ".escapeshellarg("Autostart disabled on {$cont[0]} due to tailscale integration with host network."));
|
||||
exec("logger ".escapeshellarg("This is a security risk due to the possibility of unauthenticated access to your server's GUI and resources"));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$newAuto[] = $container;
|
||||
}
|
||||
file_put_contents("/var/lib/docker/unraid-autostart",implode("\n",$newAuto));
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user