diff options
author | bcyrill <cyrill@bannwart.info> | 2013-01-07 21:42:59 +0100 |
---|---|---|
committer | bcyrill <cyrill@bannwart.info> | 2013-01-07 21:42:59 +0100 |
commit | 3cde94cff2077122a3455bacbefaf295211183b3 (patch) | |
tree | 20d747a1e9fa171926f066e930fd81ac4781db62 /etc/rc.update_bogons.sh | |
parent | 7c05f800947fdd4dd4974cc3b8aea15d8668cbf2 (diff) | |
download | pfsense-3cde94cff2077122a3455bacbefaf295211183b3.zip pfsense-3cde94cff2077122a3455bacbefaf295211183b3.tar.gz |
Avoid 'Cannot allocate memory' errors
Diffstat (limited to 'etc/rc.update_bogons.sh')
-rwxr-xr-x | etc/rc.update_bogons.sh | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/etc/rc.update_bogons.sh b/etc/rc.update_bogons.sh index bd33034..e7e56e2 100755 --- a/etc/rc.update_bogons.sh +++ b/etc/rc.update_bogons.sh @@ -90,29 +90,32 @@ ON_DISK_V6_CKSUM=`md5 /tmp/bogonsv6 | awk '{ print $4 }'` if [ "$BOGON_V4_CKSUM" = "$ON_DISK_V4_CKSUM" ] || [ "$BOGON_V6_CKSUM" = "$ON_DISK_V6_CKSUM" ]; then # At least one of the downloaded checksums matches, so mount RW /etc/rc.conf_mount_rw -fi - -if [ "$BOGON_V4_CKSUM" = "$ON_DISK_V4_CKSUM" ]; then - egrep -v "^192.168.0.0/16|^172.16.0.0/12|^10.0.0.0/8" /tmp/bogons > /etc/bogons - RESULT=`/sbin/pfctl -t bogons -T replace -f /etc/bogons 2>&1` - rm /tmp/bogons - echo "$RESULT" |awk '{ print "Bogons V4 file downloaded: " $0 }' | logger -else - echo "Could not download ${v4url} (checksum mismatch)" | logger - checksum_error="true" -fi - -if [ "$BOGON_V6_CKSUM" = "$ON_DISK_V6_CKSUM" ]; then - egrep -v "^fc00::/7" /tmp/bogonsv6 > /etc/bogonsv6 - RESULT=`/sbin/pfctl -t bogonsv6 -T replace -f /etc/bogonsv6 2>&1` - rm /tmp/bogonsv6 - echo "$RESULT" |awk '{ print "Bogons V6 file downloaded: " $0 }' | logger -else - echo "Could not download ${v6url} (checksum mismatch)" | logger - checksum_error="true" -fi + + MAXENTRIES=`pfctl -s memory | awk '/table-entries/ { print $4 }'` + + if [ "$BOGON_V4_CKSUM" = "$ON_DISK_V4_CKSUM" ]; then + egrep -v "^192.168.0.0/16|^172.16.0.0/12|^10.0.0.0/8" /tmp/bogons > /etc/bogons + RESULT=`/sbin/pfctl -t bogons -T replace -f /etc/bogons 2>&1` + echo "$RESULT" |awk '{ print "Bogons V4 file downloaded: " $0 }' | logger + rm /tmp/bogons + else + echo "Could not download ${v4url} (checksum mismatch)" | logger + checksum_error="true" + fi -if [ "$BOGON_V4_CKSUM" = "$ON_DISK_V4_CKSUM" ] || [ "$BOGON_V6_CKSUM" = "$ON_DISK_V6_CKSUM" ]; then + if [ "$BOGON_V6_CKSUM" = "$ON_DISK_V6_CKSUM" ]; then + LINES=`wc -l /tmp/bogonsv6 | awk '{ print $1 }'` + if [ $MAXENTRIES -gt $((2*LINES)) ]; then + egrep -v "^fc00::/7" /tmp/bogonsv6 > /etc/bogonsv6 + RESULT=`/sbin/pfctl -t bogonsv6 -T replace -f /etc/bogonsv6 2>&1` + echo "$RESULT" |awk '{ print "Bogons V6 file downloaded: " $0 }' | logger + fi + rm /tmp/bogonsv6 + else + echo "Could not download ${v6url} (checksum mismatch)" | logger + checksum_error="true" + fi + # We mounted RW, so switch back to RO /etc/rc.conf_mount_ro fi |