/* move the image so PHP won't delete it */ rename($_FILES['ulfile']['tmp_name'], "{$g['upload_path']}/firmware.tgz"); /* check digital signature */ $sigchk = verify_digital_signature("{$g['upload_path']}/firmware.tgz"); if ($sigchk == 1) { $sig_warning = "Imaj ait dijital imza hatalı!"; } else { if ($sigchk == 2) { $sig_warning = "Imaj dijital olarak imzalanmamış!"; } else { if ($sigchk == 3 || $sigchk == 4) { $sig_warning = "Imaj imza belirlemede hata ile karşılaşıldı!"; } } } if (!verify_gzip_file("{$g['upload_path']}/firmware.tgz")) { $input_errors[] = "Imaj dosyası bozuk!"; unlink("{$g['upload_path']}/firmware.tgz"); } } } } run_plugins("/usr/local/pkg/firmware_upgrade"); /* Check for input errors, firmware locks, warnings, then check for firmware if sig_override is set */ if (!$input_errors && !file_exists($d_firmwarelock_path) && (!$sig_warning || $_POST['sig_override'])) { if (file_exists("{$g['upload_path']}/firmware.tgz")) { /* fire up the update script in the background */ touch($d_firmwarelock_path); $savemsg = "Güncelleme yüklendi. Birazdan otomatik olarak yeniden başlatılacaktır."; if (stristr($_FILES['ulfile']['name'], "nanobsd") or $_POST['isnano'] == "yes") { mwexec_bg("/etc/rc.firmware pfSenseNanoBSDupgrade {$g['upload_path']}/firmware.tgz");
$exitstatus = 1; } } } if ($exitstatus) { update_status($sig_warning); update_output_window(gettext("Update cannot continue. You can disable this check on the Updater Settings tab.")); require "fend.inc"; exit; } else { if ($sigchk == 2) { update_status("Upgrade in progress..."); update_output_window("\n" . gettext("Upgrade Image does not contain a signature but the system has been configured to allow unsigned images. One moment please...") . "\n"); } } if (!verify_gzip_file("{$g['upload_path']}/latest.tgz")) { update_status(gettext("The image file is corrupt.")); update_output_window(gettext("Update cannot continue")); if (file_exists("{$g['upload_path']}/latest.tgz")) { conf_mount_rw(); unlink("{$g['upload_path']}/latest.tgz"); conf_mount_ro(); } require "fend.inc"; exit; } if ($downloaded_latest_tgz_sha256 != $upgrade_latest_tgz_sha256) { update_status(gettext("Downloading complete but sha256 does not match.")); update_output_window(gettext("Auto upgrade aborted.") . " \n\n" . gettext("Downloaded SHA256") . ": " . $downloaded_latest_tgz_sha256 . "\n\n" . gettext("Needed SHA256") . ": " . $upgrade_latest_tgz_sha256); } else { update_output_window($g['product_name'] . " " . gettext("is now upgrading.") . "\\n\\n" . gettext("The firewall will reboot once the operation is completed."));
unlink($d_fwupenabled_path); } } else { if ($mode === "upgrade") { if (!empty($_FILES) && is_uploaded_file($_FILES['ulfile']['tmp_name'])) { /* verify firmware image(s) */ if (!stristr($_FILES['ulfile']['name'], $g['fullplatform']) && !$_POST['sig_override']) { $input_errors[] = gettext("The uploaded image file is not for this platform") . " ({$g['fullplatform']})."; } else { if (!file_exists($_FILES['ulfile']['tmp_name'])) { /* probably out of memory for the MFS */ $input_errors[] = gettext("Image upload failed (out of memory?)"); } else { /* move the image so PHP won't delete it */ move_uploaded_file($_FILES['ulfile']['tmp_name'], "{$g['ftmp_path']}/firmware.gz.img"); if (!verify_gzip_file("{$g['ftmp_path']}/firmware.gz.img")) { $input_errors[] = gettext("The image file is corrupt"); unlink("{$g['ftmp_path']}/firmware.gz.img"); } } } } else { $input_errors[] = gettext("Image upload failed (out of memory?)"); } // Cleanup if there were errors. if (!empty($input_errors)) { rc_exec_script("/etc/rc.firmware disable"); unlink_if_exists($d_fwupenabled_path); } // Upgrade firmware if there were no errors. if (empty($input_errors) && !file_exists($d_firmwarelock_path) && (empty($sig_warning) || $_POST['sig_override'])) {