1 | #!/bin/bash |
---|
2 | #/** |
---|
3 | #@file security-config |
---|
4 | #@brief OpenGnsys Server security configuration. |
---|
5 | #@version 1.1 - Initial version. |
---|
6 | #@author Ramón J. Gómez, ETSII Univ. Sevilla |
---|
7 | #@date 2016-03-01 |
---|
8 | #*/ ## |
---|
9 | |
---|
10 | |
---|
11 | # Variables. |
---|
12 | PROG=$(basename "$0") |
---|
13 | OPENGNSYS=/opt/opengnsys |
---|
14 | # Errors control. |
---|
15 | if [ "$USER" != "root" ]; then |
---|
16 | echo "$PROG: Need to be root." >&2 |
---|
17 | exit 1 |
---|
18 | fi |
---|
19 | |
---|
20 | # FirewallD configuration. |
---|
21 | if which firewall-cmd 2>/dev/null; then |
---|
22 | # Defining OpenGnsys services. |
---|
23 | python -c " |
---|
24 | import firewall.core.io.service as ios |
---|
25 | s=ios.Service() |
---|
26 | s.short = 'OpenGnsys Server' |
---|
27 | s.name = 'ogAdmServer' |
---|
28 | s.ports = [('2008', 'tcp')] |
---|
29 | ios.service_writer(s, '/etc/firewalld/services') |
---|
30 | //s.short = 'OpenGnsys Repository' |
---|
31 | //s.name = 'ogAdmRepo' |
---|
32 | //s.ports = [('2002', 'tcp')] |
---|
33 | //ios.service_writer(s, '/etc/firewalld/services')" |
---|
34 | # Adding active services. |
---|
35 | firewall-cmd --permanent --add-service=dhcp |
---|
36 | firewall-cmd --permanent --add-service=https |
---|
37 | firewall-cmd --permanent --add-service=mysql --zone internal |
---|
38 | #firewall-cmd --permanent --add-service=ogAdmRepo |
---|
39 | firewall-cmd --permanent --add-service=ogAdmServer |
---|
40 | # Ubuntu 14.04 does not define "rsyncd" service. |
---|
41 | firewall-cmd --permanent --add-service=rsyncd || \ |
---|
42 | firewall-cmd --permanent --add-port=873/tcp |
---|
43 | firewall-cmd --permanent --add-service=samba |
---|
44 | firewall-cmd --permanent --add-service=ssh |
---|
45 | firewall-cmd --permanent --add-service=tftp |
---|
46 | # Adding Multicast ports. |
---|
47 | firewall-cmd --permanent --add-port=9000-9051/udp |
---|
48 | # Adding Torent ports? |
---|
49 | #firewall-cmd --permanent --add-port=6881-6999/udp |
---|
50 | # Applying configuration. |
---|
51 | firewall-cmd --reload |
---|
52 | else |
---|
53 | echo "$PROG: Warning: FirewallD won't be configured (firewalld is not installed)." |
---|
54 | fi |
---|
55 | |
---|
56 | # SELinux configuration. |
---|
57 | if which setsebool 2>/dev/null; then |
---|
58 | # Configuring Apache. |
---|
59 | setsebool -P httpd_can_connect_ldap on |
---|
60 | semanage fcontext -at httpd_sys_content_t "$OPENGNSYS/www(/.*)?" |
---|
61 | # Configuring Samba. |
---|
62 | setsebool -P samba_export_all_ro=1 samba_export_all_rw=1 |
---|
63 | semanage fcontext -at samba_share_t "$OPENGNSYS/client(/.*)?" |
---|
64 | semanage fcontext -at samba_share_t "$OPENGNSYS/images(/.*)?" |
---|
65 | # Applying configuration. |
---|
66 | restorecon -R $OPENGNSYS |
---|
67 | else |
---|
68 | echo "$PROG: Warning: SELinux won't be configured (policycoreutils is not installed)." |
---|
69 | fi |
---|
70 | |
---|