diff --git a/config/config-sample.ini b/config/config-sample.ini index 7e400c0..030e70e 100644 --- a/config/config-sample.ini +++ b/config/config-sample.ini @@ -7,6 +7,13 @@ logo = /logo-header-opera.png ; " < $gt; footer = 'Developed by Opera Software.' +[general] +; Use timeout --version to find out the current version +; used on e.g. debian +timeout_util = GNU coreutils +; used on e.g. alpine +; timeout_util = BusyBox + [security] ; It is important that SKA is able to verify that it has connected to the ; server that it expected to connect to (otherwise it could be tricked into diff --git a/scripts/sync-common.php b/scripts/sync-common.php index ce7284b..766236c 100644 --- a/scripts/sync-common.php +++ b/scripts/sync-common.php @@ -32,6 +32,9 @@ class SyncProcess { * @param Request $request object that triggered this sync */ public function __construct($command, $args, $request = null) { + global $config; + $timeout_util = $config['general']['timeout_util']; + $this->request = $request; $this->output = ''; $descriptorspec = array( @@ -40,7 +43,13 @@ public function __construct($command, $args, $request = null) { 2 => array("pipe", "w"), // stderr 3 => array("pipe", "w") // ); - $commandline = '/usr/bin/timeout 60s '.$command.' '.implode(' ', array_map('escapeshellarg', $args)); + switch ($timeout_util) { + case "BusyBox": + $commandline = '/usr/bin/timeout -t 60 '.$command.' '.implode(' ', array_map('escapeshellarg', $args)); + break; + default: + $commandline = '/usr/bin/timeout 60s '.$command.' '.implode(' ', array_map('escapeshellarg', $args)); + } $this->handle = proc_open($commandline, $descriptorspec, $this->pipes); stream_set_blocking($this->pipes[1], 0);