Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Ian Eiloart
Sympl
Commits
a766325d
Commit
a766325d
authored
Nov 27, 2013
by
Patrick J Cherry
Browse files
Updated firewall whitelist to better cope with junk data in wtmp.
parent
921760da
Changes
1
Hide whitespace changes
Inline
Side-by-side
firewall/sbin/symbiosis-firewall-whitelist
View file @
a766325d
...
...
@@ -193,10 +193,15 @@ end
#
updated
=
false
#
# Time we started this run
#
time_now
=
Time
.
now
#
# Expiry is measured in days.
#
expire_before
=
T
ime
.
now
-
(
expire_after
*
(
24
*
60
*
60
)
)
expire_before
=
t
ime
_
now
-
(
expire_after
*
(
24
*
60
*
60
)
)
#
# Check to see when we were last run.
...
...
@@ -216,7 +221,24 @@ FileUtils.touch(stamp_file)
# Fetch the IP addresses
#
Symbiosis
::
Utmp
.
read
(
wtmp_file
).
each
do
|
entry
|
#
# Only interested in USER_PROCESS types.
#
next
unless
entry
[
'type'
]
==
7
#
# Make sure the entry isn't in the future
#
next
unless
at
<
time_now
#
# Make sure the record isn't already expired.
#
next
unless
at
>
expire_before
#
# Fetch the IP
#
begin
ip
=
Symbiosis
::
IPAddr
.
new
(
entry
[
'ip'
].
to_s
)
rescue
ArgumentError
...
...
@@ -225,12 +247,6 @@ Symbiosis::Utmp.read(wtmp_file).each do |entry|
#
next
end
at
=
entry
[
'time'
]
#
# Make sure the record isn't already expired.
#
next
unless
at
>
expire_before
#
# Mask IPv6 to /64s.
...
...
Write
Preview
Supports
Markdown
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