Skip to contentSkip to conversation

New fail2ban policy

PATCH Daniel J Walsh 2 participants 4 messages Mar 8, 2007 – Mar 21, 2007 SELinux security module

lore
Share & tools
lore
#0 lore raw

Resend to list.

policy/modules/services/fail2ban.fc +4 -0
@@ -0,0 +1,4 @@
+
+/usr/bin/fail2ban		--	gen_context(system_u:object_r:fail2ban_exec_t,s0)
+/var/log/fail2ban.log		--	gen_context(system_u:object_r:fail2ban_log_t,s0)
+/var/run/fail2ban.pid		--	gen_context(system_u:object_r:fail2ban_var_run_t,s0)
policy/modules/services/fail2ban.if +87 -0

87 lines not on this page · raw message

policy/modules/services/fail2ban.te +77 -0

77 lines not on this page · raw message

#1 lore raw

On Thu, 2007-03-08 at 09:28 -0500, Daniel J Walsh wrote:

This seems to have rules similar to iptables:

policy/modules/services/fail2ban.te line 28

Quoted 2 lines
policy/modules/services/fail2ban.te +2 -0
+allow fail2ban_t self : capability { net_admin net_raw };
+allow fail2ban_t self : rawip_socket { getopt create setopt };

But also transitions to iptables?

policy/modules/services/fail2ban.te line 71

Quoted 3 lines
policy/modules/services/fail2ban.te +3 -0
+optional_policy(`
+       iptables_domtrans(fail2ban_t)
+')

This also seems out of place:

Quoted 1 line

+selinux_get_fs_mount(fail2ban_t)

Signature · 9 lines
Chris PeBenito
Tresys Technology, LLC
(410) 290-1411 x150


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#2 lore raw
Quoted 5 lines · Christopher J. PeBenito

On Thu, 2007-03-08 at 09:28 -0500, Daniel J Walsh wrote:

This seems to have rules similar to iptables:

Quoted 8 lines

policy/modules/services/fail2ban.te line 28

Quoted 3 lines
policy/modules/services/fail2ban.te +2 -0
+allow fail2ban_t self : capability { net_admin net_raw };
+allow fail2ban_t self : rawip_socket { getopt create setopt };

But also transitions to iptables?

Yes remove these

Quoted 5 lines

policy/modules/services/fail2ban.te line 71

Quoted 4 lines
policy/modules/services/fail2ban.te +3 -0
+optional_policy(`
+       iptables_domtrans(fail2ban_t)
+')
Quoted 7 lines

This also seems out of place:

Quoted 2 lines

+selinux_get_fs_mount(fail2ban_t)

Not sure, but retesting now it did not complain so remove.

Also seems to need

kernel_read_system_state(fail2ban_t)

policy_module(fail2ban,1.0.0)

########################################
#
# Declarations
#

type fail2ban_t;
type fail2ban_exec_t;
domain_type(fail2ban_t)
init_daemon_domain(fail2ban_t, fail2ban_exec_t)

# log files
type fail2ban_log_t;
logging_log_file(fail2ban_log_t)
# pid files
type fail2ban_var_run_t;
files_pid_file(fail2ban_var_run_t)

########################################
#

# fail2ban local policy
#

allow fail2ban_t self : process signal;

# Init script handling
init_use_fds(fail2ban_t)
init_use_script_ptys(fail2ban_t)
domain_use_interactive_fds(fail2ban_t)

## internal communication is often done using fifo and unix sockets. allow fail2ban_t self:fifo_file rw_file_perms;
allow fail2ban_t self:unix_stream_socket create_stream_socket_perms;

# Some common macros (you might be able to remove some) files_read_etc_files(fail2ban_t)

kernel_read_system_state(fail2ban_t)

libs_use_ld_so(fail2ban_t)
libs_use_shared_libs(fail2ban_t)

miscfiles_read_localization(fail2ban_t)

# log files
allow fail2ban_t fail2ban_log_t:file manage_file_perms;
allow fail2ban_t fail2ban_log_t:dir { rw_dir_perms setattr };
logging_log_filetrans(fail2ban_t,fail2ban_log_t,{ file dir })
# pid file
allow fail2ban_t fail2ban_var_run_t:file manage_file_perms;
allow fail2ban_t fail2ban_var_run_t:dir rw_dir_perms;
files_pid_filetrans(fail2ban_t,fail2ban_var_run_t, file)

corecmd_search_sbin(fail2ban_t)
corecmd_exec_bin(fail2ban_t)
corecmd_exec_shell(fail2ban_t)

dev_read_urand(fail2ban_t)

files_read_usr_files(fail2ban_t)

logging_read_generic_logs(fail2ban_t)

optional_policy(`
iptables_domtrans(fail2ban_t)
')

ifdef(targeted_policy',
term_dontaudit_use_unallocated_ttys(fail2ban_t) term_dontaudit_use_generic_ptys(fail2ban_t)
')

#3 lore raw
Quoted 27 lines · Daniel J Walsh
Quoted 5 lines · Christopher J. PeBenito

On Thu, 2007-03-08 at 09:28 -0500, Daniel J Walsh wrote:

This seems to have rules similar to iptables:

Quoted 8 lines

policy/modules/services/fail2ban.te line 28

Quoted 3 lines
policy/modules/services/fail2ban.te +2 -0
+allow fail2ban_t self : capability { net_admin net_raw };
+allow fail2ban_t self : rawip_socket { getopt create setopt };

But also transitions to iptables?

Yes remove these

Quoted 5 lines

policy/modules/services/fail2ban.te line 71

Quoted 4 lines
policy/modules/services/fail2ban.te +3 -0
+optional_policy(`
+       iptables_domtrans(fail2ban_t)
+')
Quoted 7 lines

This also seems out of place:

Quoted 2 lines

+selinux_get_fs_mount(fail2ban_t)

Quoted 5 lines

Not sure, but retesting now it did not complain so remove.

Also seems to need

kernel_read_system_state(fail2ban_t)

Merged. I also added an optional log reading for apache and ftp since the project's page says it can read these logs too.

Signature · 9 lines
Chris PeBenito
Tresys Technology, LLC
(410) 290-1411 x150


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.