-
Notifications
You must be signed in to change notification settings - Fork 28
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just some thoughts, although i do not have any experience with ejabberd
ejabberd.fc
Outdated
|
||
/usr/lib/systemd/system/ejabberd.* -- gen_context(system_u:object_r:ejabberd_unit_file_t,s0) | ||
|
||
/var/lib/ejabberd.* gen_context(system_u:object_r:ejabberd_var_lib_t,s0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better regex might be /var/lib/ejabberd(/.*)?
; there shouldn't be files in /var/lib
ejabberd.if
Outdated
') | ||
|
||
allow $1 { ejabberd_t }:process { ptrace signal_perms }; | ||
ps_process_pattern($1, ejabberd_t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these two line can be combined into admin_process_pattern($1, ejabberd_t)
ejabberd.if
Outdated
|
||
domain_system_change_exemption($1) | ||
role_transition $2 ejabberd_exec_t system_r; | ||
allow $2 system_r; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these three line should be replaced by init_startstop_service($1, $2, ejabberd_t, ejabberd_initrc_exec_t, ejabberd_unit_t)
for restarting the service as root
ejabberd.te
Outdated
class tcp_socket { accept bind connect create getattr getopt listen read setopt write }; | ||
class udp_socket { bind connect create getattr getopt read setopt write }; | ||
class unix_dgram_socket { connect create getopt setopt write }; | ||
') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gen_require
should not be used: class ones are not necessary and the net_conf_t
should be include in a macro call
ejabberd.te
Outdated
type ejabberd_var_lib_t; | ||
type ejabberd_var_log_t; | ||
|
||
files_type(ejabberd_var_lib_t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
macro calls describing a type, like this, should be next to the type definition
ejabberd.te
Outdated
corecmd_exec_bin(ejabberd_t) | ||
corecmd_exec_shell(ejabberd_t) | ||
corecmd_mmap_bin_files(ejabberd_t) | ||
corecmd_shell_entry_type(ejabberd_t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is only needed when the entrypoint of the domain is a shell script.
As ejabberd_t's entrypoint is /usr/bin/ejabberdctl this should not be necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/usr/bin/ejabberdctl is a shell script. Does that make this necessary?
ejabberd.te
Outdated
|
||
corenet_udp_bind_generic_node(ejabberd_t) | ||
|
||
dev_list_sysfs(ejabberd_t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dev_list_sysfs(ejabberd_t)
is superseded by dev_read_sysfs(ejabberd_t)
ejabberd.te
Outdated
dev_read_sysfs(ejabberd_t) | ||
|
||
files_rw_etc_files(ejabberd_t) | ||
files_var_lib_filetrans(ejabberd_t, ejabberd_var_lib_t, dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in my opinion application should not be able to create /var/lib entries, the package manager or installation script should handle this
so this might be replaced by files_search_var_lib
ejabberd.te
Outdated
|
||
kernel_dgram_send(ejabberd_t) | ||
|
||
logging_create_devlog_dev(ejabberd_t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a fedora specific interface, maybe logging_send_syslog_msg
could fit
ejabberd.te
Outdated
|
||
sysnet_read_config(ejabberd_t) | ||
|
||
fs_associate(ejabberd_var_lib_t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is superseded by files_type(ejabberd_var_lib_t)
On Sun, Apr 09, 2017 at 11:17:25AM -0700, Randy Barlow wrote:
bowlofeggs commented on this pull request.
> +systemd_unit_file(ejabberd_unit_file_t)
+
+domain_type(ejabberd_t)
+domain_entry_file(ejabberd_t, ejabberd_exec_t)
+
+logging_log_file(ejabberd_var_log_t)
+
+
+# What will we allow
+allow ejabberd_t net_conf_t:lnk_file read;
+
+allow ejabberd_t self:tcp_socket { accept bind connect create getattr getopt listen read setopt write };
+allow ejabberd_t self:udp_socket { bind connect create getattr getopt read setopt write };
+allow ejabberd_t self:unix_dgram_socket { connect create getopt setopt write };
+
+auth_read_passwd(ejabberd_t)
ejabberd has a built-in PAM module for authentication, which is why it is trying to read the /etc/passwd file.
Reading /etc/passwd is very common for nss, and is part of auth_use_nsswith() which you should use for ejabberd_t if you arent already
…
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#57 (comment)
--
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift
|
On Sun, Apr 09, 2017 at 11:18:33AM -0700, Randy Barlow wrote:
bowlofeggs commented on this pull request.
> +logging_log_file(ejabberd_var_log_t)
+
+
+# What will we allow
+allow ejabberd_t net_conf_t:lnk_file read;
+
+allow ejabberd_t self:tcp_socket { accept bind connect create getattr getopt listen read setopt write };
+allow ejabberd_t self:udp_socket { bind connect create getattr getopt read setopt write };
+allow ejabberd_t self:unix_dgram_socket { connect create getopt setopt write };
+
+auth_read_passwd(ejabberd_t)
+
+corecmd_exec_bin(ejabberd_t)
+corecmd_exec_shell(ejabberd_t)
+corecmd_mmap_bin_files(ejabberd_t)
+corecmd_shell_entry_type(ejabberd_t)
/usr/bin/ejabberdctl is a shell script. Does that make this necessary?
Unlikely, remove corecmd_shell_entry_type(ejabberd_t) and then if you see any related avc denials enclose them.
…
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#57 (comment)
--
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift
|
5d4daca
to
fa1893b
Compare
@cgzones and @doverride, Thanks for all the helpful tips! As you can probably tell, this is my first SELinux policy so I lack a lot of familiarity with all the macros. I believe I now have all of your suggestions in place, and I've sent this same policy to the Fedora-specific policy with the exception of keeping the Fedora-specific logging statement in that one. The Fedora version of this seems to work well on my ejabberd system. Let me know if there are other changes I should make, and thanks again! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question about rules, otherwise it needs some style cleanup. https://github.com/TresysTechnology/refpolicy/wiki/StyleGuide
ejabberd.te
Outdated
|
||
miscfiles_read_generic_certs(ejabberd_t) | ||
|
||
networkmanager_read_pid_files(ejabberd_t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work without networkmanager (is networkmanager a hard dependency?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @pebenito,
I don't believe that networkmanager is a hard dependency of ejabberd. It sounds like @doverride is recommending that I use sysnet_read_config()
instead, so I'll make that change.
On 04/27/2017 12:09 AM, Chris PeBenito wrote:
pebenito requested changes on this pull request.
One question about rules, otherwise it needs some style cleanup. https://github.com/TresysTechnology/refpolicy/wiki/StyleGuide
> +
+files_search_var_lib(ejabberd_t, ejabberd_var_lib_t, dir)
+
+kernel_dgram_send(ejabberd_t)
This is journal logging should probably be part of logging_send_syslog_msg()
+
+logging_send_syslog_msg(ejabberd_t)
+logging_log_filetrans(ejabberd_t, ejabberd_var_log_t, { dir file })
+
+manage_dirs_pattern(ejabberd_t, ejabberd_var_lib_t, ejabberd_var_lib_t)
+manage_dirs_pattern(ejabberd_t, ejabberd_var_log_t, ejabberd_var_log_t)
+manage_files_pattern(ejabberd_t, ejabberd_var_lib_t, ejabberd_var_lib_t)
+manage_files_pattern(ejabberd_t, ejabberd_var_log_t, ejabberd_var_log_t)
+
+miscfiles_read_generic_certs(ejabberd_t)
+
+networkmanager_read_pid_files(ejabberd_t)
Does this work without networkmanager (is networkmanager a hard dependency?)
its reading /run/NetworkManager/resolv.conf which should be part of
sysnet_read_config() i suppose
…--
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift
|
I have made the requested changes:
|
@doverride I think dropping the
Thus, I am going to add it back. |
On Sun, Apr 30, 2017 at 09:34:08AM -0700, Randy Barlow wrote:
@doverride I think dropping the ```kernel_dgram_send()``` might not work. At least, it doesn't work on my Fedora Rawhide system as ejabberd hangs during startup, and ```audit2allow``` show this:
```
sudo audit2allow -Rbl
require {
type ejabberd_t;
}
#============= ejabberd_t ==============
kernel_dgram_send(ejabberd_t)
```
Thus, I am going to add it back.
Okay, I suspect that this is (should be) part of logging_send_syslog_msg() but if fedora/refpolicy does not include this access as part of that interface then i supose you'd have to add it in manually.
…
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#57 (comment)
--
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift
|
Signed-off-by: Randy Barlow <[email protected]>
@doverride if we are confident that it is part of |
On Sun, Apr 30, 2017 at 09:44:03AM -0700, Randy Barlow wrote:
@doverride if we are confident that it is part of ```logging_send_syslog_msg()``` in refpol, I'm happy to add it back but I don't have a setup I can use to verify that it works.
I was not suggesting that it *is* part of logging_send_syslog_msg(), instead i was merely thinking out loud that this access should * ideally be* part of logging_send_syslog_msg()
…
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#57 (comment)
--
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift
|
Ah. Thanks for the review! |
Closing stale PR. Please reopen when/if you will be providing updates. |
@pebenito I wasn't aware that updates were required from me. From my perspective, I thought I was just waiting for further review or a merge. Can you clarify what I should do to get this merged? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mainly stylistic fixes needed.
@@ -0,0 +1,33 @@ | |||
######################################## |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing module summary tag
|
||
admin_process_pattern($1, ejabberd_t) | ||
|
||
init_startstop_service($1, $2, ejabberd_t, ejabberd_initrc_exec_t, ejabberd_unit_t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indents should be tabs
@@ -0,0 +1,57 @@ | |||
policy_module(ejabberd,0.0) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be ordered and commented per the Style Guide, including the header comment blocks like in other modules. Also module version 1.0.0.
# What will we allow | ||
allow ejabberd_t self:tcp_socket { accept bind connect create getattr getopt listen read setopt write }; | ||
allow ejabberd_t self:udp_socket { bind connect create getattr getopt read setopt write }; | ||
allow ejabberd_t self:unix_dgram_socket { connect create getopt setopt write }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please review the existing permission set macros to see if they can be used instead of the verbose permission lists here.
This pull request may depend on OwlCyberDefense/refpolicy#114 being fixed to work effectively, but I wanted to go ahead and get the code upstream. I've also send a PR with this code to Fedora's contrib policy:
fedora-selinux/selinux-policy-contrib#8
Signed-off-by: Randy Barlow [email protected]