Close STDIN ($fp) handle before returning back to shell. Major doh's.

This commit is contained in:
Scott Ullrich 2007-06-02 22:05:43 +00:00
parent 2106861ba9
commit 5397d0ebad
6 changed files with 29 additions and 3 deletions

View File

@ -59,4 +59,7 @@ EOD;
system_reboot_sync();
}
fclose($fp);
?>

View File

@ -55,4 +55,7 @@ EOD;
system_halt();
}
?>
fclose($fp);
?>

View File

@ -68,4 +68,6 @@ EOD;
sync_webgui_passwords();
fclose($fp);
?>

View File

@ -45,4 +45,7 @@
echo "\nPress ENTER to continue.\n";
fgets($fp);
}
fclose($fp);
?>

View File

@ -53,4 +53,7 @@ EOD;
system_reboot_sync();
}
fclose($fp);
?>

View File

@ -31,13 +31,16 @@ switch ($command) {
case "q":
case "quit":
echo "\n";
fclose($fp);
die;
break;
case "1":
echo "\nEnter the URL to the .tgz update file:\n> ";
$url = chop(fgets($fp));
if(!$url)
if(!$url) {
fclose($fp);
die;
}
$status = does_url_exist($url);
if($status) {
conf_mount_rw();
@ -49,10 +52,12 @@ switch ($command) {
exec("fetch -1 -w15 -a -v -o /root/firmware.tgz \"$url\"");
if($file_size <> filesize("/root/firmware.tgz")) {
echo "\nFile size mismatch. Upgrade cancelled.\n\n";
fclose($fp);
die;
}
if(!file_exists("/root/firmware.tgz")) {
echo "Something went wrong during file transfer. Exiting.\n\n";
fclose($fp);
die;
}
$status = does_url_exist("$url.md5");
@ -71,6 +76,7 @@ switch ($command) {
echo "Downloaded file MD5: $file_md5\n";
if($source_md5 <> $file_md5) {
echo "\n\nMD5 checksum does not match. Cancelling upgrade.\n\n";
fclose($fp);
die -1;
}
echo "\nMD5 checksum matches.\n";
@ -79,21 +85,27 @@ switch ($command) {
do_upgrade("/root/firmware.tgz");
} else {
echo "\nCould not download update.\n\n";
fclose($fp);
die -1;
}
case "2":
echo "\nEnter the complete path to the .tgz update file: ";
$path = chop(fgets($fp));
if(!$path)
if(!$path) {
fclose($fp);
die;
}
if(file_exists($path)) {
do_upgrade($path);
} else {
echo "\nCould not find file.\n\n";
fclose($fp);
die -1;
}
}
fclose($fp);
function do_upgrade($path) {
echo "\nOne moment please... Invoking firmware upgrade...\n";
exec("/etc/rc.firmware pfSenseupgrade $path");