Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mailinabox
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
Administrator
mailinabox
Commits
c9f30e80
Commit
c9f30e80
authored
Apr 02, 2016
by
Michael Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add status checks for ufw
parent
1a1d125b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
status_checks.py
management/status_checks.py
+25
-0
No files found.
management/status_checks.py
View file @
c9f30e80
...
...
@@ -168,6 +168,31 @@ def run_system_checks(rounded_values, env, output):
check_system_aliases
(
env
,
output
)
check_free_disk_space
(
rounded_values
,
env
,
output
)
check_free_memory
(
rounded_values
,
env
,
output
)
check_ufw
(
env
,
output
)
def
check_ufw
(
env
,
output
):
ufw
=
shell
(
'check_output'
,
[
'ufw'
,
'status'
])
.
splitlines
()
if
ufw
[
0
]
==
"Status: active"
:
ports_that_should_be_allowed
=
[
"22"
,
"53"
,
"25"
,
"587"
,
"993"
,
"995"
,
"4190"
,
"80"
,
"443"
]
not_allowed_ports
=
[]
for
port
in
ports_that_should_be_allowed
:
if
not
is_port_allowed
(
ufw
,
port
):
not_allowed_ports
.
append
(
port
)
if
len
(
not_allowed_ports
)
==
1
:
output
.
print_error
(
"Port
%
s should be allowed in the firewall, please rerun the setup."
%
(
not_allowed_ports
[
0
]))
elif
len
(
not_allowed_ports
)
>
1
:
output
.
print_error
(
"Ports
%
s should be allowed in the firewall, please rerun the setup."
%
(
", "
.
join
(
not_allowed_ports
)))
else
:
output
.
print_ok
(
"Firewall is active"
)
else
:
output
.
print_warning
(
"""The firewall is disabled on this machine, this might be because the system
is protected by an external firewall. We can't protect against bruteforce attacks using fail2ban
without the local firewall active. Via ssh please try to run: ufw enable"""
)
def
is_port_allowed
(
ufw
,
port
):
return
any
(
item
.
startswith
(
port
)
for
item
in
ufw
)
def
check_ssh_password
(
env
,
output
):
# Check that SSH login with password is disabled. The openssh-server
...
...
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