Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
1328c754
Commit
1328c754
authored
Nov 10, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rc: use at least a bit of variable sanity in bogons fetch
parent
897b2c96
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
16 deletions
+19
-16
rc.update_bogons
src/etc/rc.update_bogons
+19
-16
No files found.
src/etc/rc.update_bogons
View file @
1328c754
...
@@ -2,15 +2,18 @@
...
@@ -2,15 +2,18 @@
CORE_ABI
=
$(
cat
/usr/local/opnsense/version/opnsense.abi 2> /dev/null
)
CORE_ABI
=
$(
cat
/usr/local/opnsense/version/opnsense.abi 2> /dev/null
)
SYS_ABI
=
$(
opnsense-verify
-a
2> /dev/null
)
SYS_ABI
=
$(
opnsense-verify
-a
2> /dev/null
)
URL
=
"https://pkg.opnsense.org"
URL
=
"https://pkg.opnsense.org"
if
[
-n
"
${
CORE_ABI
}
"
-a
-n
"
${
SYS_ABI
}
"
]
;
then
if
[
-n
"
${
CORE_ABI
}
"
-a
-n
"
${
SYS_ABI
}
"
]
;
then
# expand url to new mirror layout per release
# expand url to new mirror layout per release
URL
=
"
${
URL
}
/
${
SYS_ABI
}
/
${
CORE_ABI
}
"
URL
=
"
${
URL
}
/
${
SYS_ABI
}
/
${
CORE_ABI
}
"
fi
fi
URL
=
"
${
URL
}
/sets/bogons.txz"
URL
=
"
${
URL
}
/sets/bogons.txz"
DESTDIR
=
"/usr/local/etc"
WORKDIR
=
"/tmp/bogons"
FETCH
=
"fetch -aqT 30"
proc_error
=
proc_error
=
echo
"rc.update_bogons is starting up."
| logger
echo
"rc.update_bogons is starting up."
| logger
...
@@ -25,19 +28,19 @@ fi
...
@@ -25,19 +28,19 @@ fi
echo
"rc.update_bogons is beginning the update cycle."
| logger
echo
"rc.update_bogons is beginning the update cycle."
| logger
rm
-rf
/tmp/bogons
rm
-rf
${
WORKDIR
}
mkdir
-p
/tmp/bogons
mkdir
-p
${
WORKDIR
}
fetch
-a
-T
30
-q
-o
/tmp/bogons
/bogons.txz.sig
"
${
URL
}
.sig"
${
FETCH
}
-o
${
WORKDIR
}
/bogons.txz.sig
"
${
URL
}
.sig"
fetch
-a
-T
30
-q
-o
/tmp/bogons
/bogons.txz
"
${
URL
}
"
${
FETCH
}
-o
${
WORKDIR
}
/bogons.txz
"
${
URL
}
"
if
[
!
-f
/tmp/bogons
/bogons.txz
]
;
then
if
[
!
-f
${
WORKDIR
}
/bogons.txz
]
;
then
echo
"Could not download
${
URL
}
"
| logger
echo
"Could not download
${
URL
}
"
| logger
proc_error
=
"true"
proc_error
=
"true"
elif
!
opnsense-verify
-q
/tmp/bogons
/bogons.txz
;
then
elif
!
opnsense-verify
-q
${
WORKDIR
}
/bogons.txz
;
then
echo
"Could not verify
${
URL
}
"
| logger
echo
"Could not verify
${
URL
}
"
| logger
proc_error
=
"true"
proc_error
=
"true"
elif
!
tar
-C
/tmp/bogons
-xJf
/tmp/bogons
/bogons.txz
;
then
elif
!
tar
-C
${
WORKDIR
}
-xJf
${
WORKDIR
}
/bogons.txz
;
then
echo
"Could not extract
${
URL
}
"
| logger
echo
"Could not extract
${
URL
}
"
| logger
proc_error
=
"true"
proc_error
=
"true"
fi
fi
...
@@ -51,13 +54,13 @@ fi
...
@@ -51,13 +54,13 @@ fi
ENTRIES_MAX
=
`
pfctl
-s
memory |
awk
'/table-entries/ { print $4 }'
`
ENTRIES_MAX
=
`
pfctl
-s
memory |
awk
'/table-entries/ { print $4 }'
`
ENTRIES_TOT
=
`
pfctl
-vvsTables
|
awk
'/Addresses/ {s+=$2}; END {print s}'
`
ENTRIES_TOT
=
`
pfctl
-vvsTables
|
awk
'/Addresses/ {s+=$2}; END {print s}'
`
ENTRIES_V4
=
`
pfctl
-vvsTables
|
awk
'/-\tbogons$/ {getline; print $2}'
`
ENTRIES_V4
=
`
pfctl
-vvsTables
|
awk
'/-\tbogons$/ {getline; print $2}'
`
LINES_V4
=
`
wc
-l
/tmp/bogons
/fullbogons-ipv4.txt |
awk
'{ print $1 }'
`
LINES_V4
=
`
wc
-l
${
WORKDIR
}
/fullbogons-ipv4.txt |
awk
'{ print $1 }'
`
if
[
$ENTRIES_MAX
-gt
$((
2
*
ENTRIES_TOT-
${
ENTRIES_V4
:-
0
}
+
LINES_V4
))
]
;
then
if
[
$ENTRIES_MAX
-gt
$((
2
*
ENTRIES_TOT-
${
ENTRIES_V4
:-
0
}
+
LINES_V4
))
]
;
then
# These bogons are removed as they are private. I'm not going
# These bogons are removed as they are private. I'm not going
# to question this now, adding a big WARNING instead. Here be
# to question this now, adding a big WARNING instead. Here be
# dragons...
# dragons...
egrep
-v
"^100.64.0.0/10|^192.168.0.0/16|^172.16.0.0/12|^10.0.0.0/8"
/tmp/bogons/fullbogons-ipv4.txt
>
/usr/local/etc
/bogons
egrep
-v
"^100.64.0.0/10|^192.168.0.0/16|^172.16.0.0/12|^10.0.0.0/8"
${
WORKDIR
}
/fullbogons-ipv4.txt
>
${
DESTDIR
}
/bogons
RESULT
=
`
/sbin/pfctl
-t
bogons
-T
replace
-f
/usr/local/etc
/bogons 2>&1
`
RESULT
=
`
/sbin/pfctl
-t
bogons
-T
replace
-f
${
DESTDIR
}
/bogons 2>&1
`
echo
"
$RESULT
"
|
awk
'{ print "Bogons V4 file downloaded: " $0 }'
| logger
echo
"
$RESULT
"
|
awk
'{ print "Bogons V4 file downloaded: " $0 }'
| logger
else
else
echo
"Not updating IPv4 bogons (increase table-entries limit)"
| logger
echo
"Not updating IPv4 bogons (increase table-entries limit)"
| logger
...
@@ -67,19 +70,19 @@ ENTRIES_MAX=`pfctl -s memory | awk '/table-entries/ { print $4 }'`
...
@@ -67,19 +70,19 @@ ENTRIES_MAX=`pfctl -s memory | awk '/table-entries/ { print $4 }'`
ENTRIES_TOT
=
`
pfctl
-vvsTables
|
awk
'/Addresses/ {s+=$2}; END {print s}'
`
ENTRIES_TOT
=
`
pfctl
-vvsTables
|
awk
'/Addresses/ {s+=$2}; END {print s}'
`
BOGONS_V6_TABLE_COUNT
=
`
pfctl
-sTables
|
grep
^bogonsv6
$
|
wc
-l
|
awk
'{ print $1 }'
`
BOGONS_V6_TABLE_COUNT
=
`
pfctl
-sTables
|
grep
^bogonsv6
$
|
wc
-l
|
awk
'{ print $1 }'
`
ENTRIES_TOT
=
`
pfctl
-vvsTables
|
awk
'/Addresses/ {s+=$2}; END {print s}'
`
ENTRIES_TOT
=
`
pfctl
-vvsTables
|
awk
'/Addresses/ {s+=$2}; END {print s}'
`
LINES_V6
=
`
wc
-l
/tmp/bogons
/fullbogons-ipv6.txt |
awk
'{ print $1 }'
`
LINES_V6
=
`
wc
-l
${
WORKDIR
}
/fullbogons-ipv6.txt |
awk
'{ print $1 }'
`
if
[
$BOGONS_V6_TABLE_COUNT
-gt
0
]
;
then
if
[
$BOGONS_V6_TABLE_COUNT
-gt
0
]
;
then
ENTRIES_V6
=
`
pfctl
-vvsTables
|
awk
'/-\tbogonsv6$/ {getline; print $2}'
`
ENTRIES_V6
=
`
pfctl
-vvsTables
|
awk
'/-\tbogonsv6$/ {getline; print $2}'
`
if
[
$ENTRIES_MAX
-gt
$((
2
*
ENTRIES_TOT-
${
ENTRIES_V6
:-
0
}
+
LINES_V6
))
]
;
then
if
[
$ENTRIES_MAX
-gt
$((
2
*
ENTRIES_TOT-
${
ENTRIES_V6
:-
0
}
+
LINES_V6
))
]
;
then
egrep
-iv
"^fc00::/7"
/tmp/bogons/fullbogons-ipv6.txt
>
/usr/local/etc
/bogonsv6
egrep
-iv
"^fc00::/7"
${
WORKDIR
}
/fullbogons-ipv6.txt
>
${
DESTDIR
}
/bogonsv6
RESULT
=
`
/sbin/pfctl
-t
bogonsv6
-T
replace
-f
/usr/local/etc
/bogonsv6 2>&1
`
RESULT
=
`
/sbin/pfctl
-t
bogonsv6
-T
replace
-f
${
DESTDIR
}
/bogonsv6 2>&1
`
echo
"
$RESULT
"
|
awk
'{ print "Bogons V6 file downloaded: " $0 }'
| logger
echo
"
$RESULT
"
|
awk
'{ print "Bogons V6 file downloaded: " $0 }'
| logger
else
else
echo
"Not saving or updating IPv6 bogons (increase table-entries limit)"
| logger
echo
"Not saving or updating IPv6 bogons (increase table-entries limit)"
| logger
fi
fi
else
else
if
[
$ENTRIES_MAX
-gt
$((
2
*
ENTRIES_TOT+LINES_V6
))
]
;
then
if
[
$ENTRIES_MAX
-gt
$((
2
*
ENTRIES_TOT+LINES_V6
))
]
;
then
egrep
-iv
"^fc00::/7"
/tmp/bogons/fullbogons-ipv6.txt
>
/usr/local/etc
/bogonsv6
egrep
-iv
"^fc00::/7"
${
WORKDIR
}
/fullbogons-ipv6.txt
>
${
DESTDIR
}
/bogonsv6
echo
"Bogons V6 file downloaded but not updating IPv6 bogons table because IPv6 Allow is off"
| logger
echo
"Bogons V6 file downloaded but not updating IPv6 bogons table because IPv6 Allow is off"
| logger
else
else
echo
"Not saving IPv6 bogons table (IPv6 Allow is off and table-entries limit is potentially too low)"
| logger
echo
"Not saving IPv6 bogons table (IPv6 Allow is off and table-entries limit is potentially too low)"
| logger
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment