summaryrefslogtreecommitdiffstats
path: root/etc/rc.firmware
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2009-07-07 20:45:58 -0400
committerScott Ullrich <sullrich@pfsense.org>2009-07-07 20:45:58 -0400
commitb90885ff961077fb6551e998fd39b25c72a72671 (patch)
treee1df93168160fc5456aee6f9308cbdef9600525d /etc/rc.firmware
parent34c7f02eb11bbf988b83651dfc37470f46e6e7ad (diff)
downloadpfsense-b90885ff961077fb6551e998fd39b25c72a72671.zip
pfsense-b90885ff961077fb6551e998fd39b25c72a72671.tar.gz
Add a seatbelt check to ensure the on disk partition is the same size (or larger) and bail if it has any issues.
Diffstat (limited to 'etc/rc.firmware')
-rwxr-xr-xetc/rc.firmware12
1 files changed, 12 insertions, 0 deletions
diff --git a/etc/rc.firmware b/etc/rc.firmware
index 0ff0fa3..1e64128 100755
--- a/etc/rc.firmware
+++ b/etc/rc.firmware
@@ -193,6 +193,18 @@ pfSenseNanoBSDupgrade)
echo "COMPLETE_PATH $COMPLETE_PATH" >> /conf/upgrade_log.txt
echo "GLABEL_SLICE $GLABEL_SLICE" >> /conf/upgrade_log.txt
+ # First ensure the new file can fit inside the
+ # slice that we are going to be operating on.
+ NEW_IMG_SIZE=`echo $((\`gzip -l ${IMG} | grep -v compressed | awk '{ print $2}'\` / 1024 / 1024))`
+ SIZE=`/sbin/fdisk ${COMPLETE_PATH} | /usr/bin/grep Meg | /usr/bin/awk '{ print $5 }' | /usr/bin/cut -d"(" -f2`
+ if [ "$SIZE" -lt "$NEW_IMG_SIZE" ]; then
+ file_notice "UpgradeFailure" "Upgrade failed due to the upgrade image being larger than the partition that is configured on disk. Halting."
+ echo "Upgrade failed. Please check the system log file for more information" | wall
+ rm /var/run/firmwarelock.dirty
+ /etc/rc.conf_mount_ro
+ exit 1
+ fi
+
# Output environment information to log file
output_env_to_log
OpenPOWER on IntegriCloud