From fab6ef63e343362a8992743332a830909f4c9c28 Mon Sep 17 00:00:00 2001 From: Jeroen De Meerleer Date: Fri, 26 Apr 2019 16:28:34 +0200 Subject: [PATCH] Do not require url-encoding when providing reboot command --- webcron.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/webcron.php b/webcron.php index 0329204..85e0143 100644 --- a/webcron.php +++ b/webcron.php @@ -42,7 +42,12 @@ if (file_exists("cache/get-services.trigger")) { foreach($rebootjobs as $job) { $services = array(); - parse_str(str_replace("reboot ", "", $job['url']), $rebootcommands); + $rebooter = preg_replace("/reboot /", "", $job['url'], 1); + $rebooter = urlencode($rebooter); + $rebooter = str_replace("cmd%3D", "cmd=", $rebooter); + $rebooter = str_replace("services%3D", "services=", $rebooter); + $rebooter = str_replace("%26", "&", $rebooter); + parse_str($rebooter, $rebootcommands); $cmd = $rebootcommands['services']; if ($cmd == '') { @@ -128,13 +133,18 @@ if(file_exists("cache/reboot.trigger")) { file_put_contents("cache/reboot-time.trigger", time() + ((get_configvalue('jobs.reboottime') + get_configvalue('jobs.rebootwait')) * 60)); $rebooted_hosts = array(); foreach($rebootjobs as $job) { - parse_str(str_replace("reboot ", "", $job['url']), $rebootcommands); + $rebooter = preg_replace("/reboot /", "", $job['url'], 1); + $rebooter = urlencode($rebooter); + $rebooter = str_replace("cmd%3D", "cmd=", $rebooter); + $rebooter = str_replace("services%3D", "services=", $rebooter); + $rebooter = str_replace("%26", "&", $rebooter); + parse_str($rebooter, $rebootcommands); $cmd = $rebootcommands['cmd']; if ($cmd == '') { $cmd = 'sudo shutdown -r +' . get_configvalue('jobs.rebootwait') . ' "A reboot has been scheduled. Please save your work."'; } - $url = "ssh " . $job['host'] . " '" . $cmd . "'"; + $url = "ssh " . $job['host'] . " '" . $cmd . " &'"; exec($url); $cmd = ''; }