New policy for pyzor
This is a new strict policy for the pyzor spam filter. It is based on the selinux-policy-strict-sources-1.23.2-1 fedora RPM. This policy requires the definition of a pyzor reserved port that was in the net_contexts diff I sent last Wednesday. Please let me know if there are any problems with or changes needed to this policy.
David
/etc/pyzor(/.*)? system_u:object_r:pyzor_etc_t/usr/bin/pyzor -- system_u:object_r:pyzor_exec_t/usr/bin/pyzord -- system_u:object_r:pyzord_exec_t
/var/lib/pyzord(/.*)? system_u:object_r:pyzor_var_lib_t/var/log/pyzord.log -- system_u:object_r:pyzord_log_t
HOME_DIR/\.pyzor(/.*)? system_u:object_r:ROLE_pyzor_home_t
#
# Pyzor - Pyzor is a collaborative, networked system to detect and
# block spam using identifying digests of messages.
#
# Author: David Hampton <[email protected]>
#
##########
# common definitions for pyzord and all flavors of pyzor ########## define(`pyzor_base_domain',`
# Networkingcan_network_client_tcp($1_t, http_port_t);can_network_udp($1_t, pyzor_port_t);can_resolve($1_t);
general_proc_read_access($1_t)
tmp_domain($1)
allow $1_t bin_t:dir { getattr search }; allow $1_t bin_t:file getattr;
allow $1_t lib_t:file { getattr read }; allow $1_t { var_t var_lib_t var_run_t }:dir search; uses_shlib($1_t)
# Python does a getattr on this file
allow $1_t pyzor_exec_t:file getattr;
# mktemp and other randoms
allow $1_t { random_device_t urandom_device_t }:chr_file r_file_perms;# Allow access to various files in the /etc/directory including mtab
# and nsswitch
allow $1_t { etc_t etc_runtime_t }:file { getattr read };
read_locale($1_t)
')#
# Define a user domain for a pyzor
#
# Note: expects to be called with an argument of user, sysadm
define(pyzor_domain',
type $1_pyzor_t, domain, privlog, nscd_client_domain; role $1_r types $1_pyzor_t; domain_auto_trans($1_t, pyzor_exec_t, $1_pyzor_t)
pyzor_base_domain($1_pyzor)
# Per-user config/data fileshome_domain($1, pyzor)
# System config filesr_dir_file($1_pyzor_t, pyzor_etc_t)
# System data filesr_dir_file($1_pyzor_t, pyzor_var_lib_t);
allow $1_pyzor_t self:unix_stream_socket create_stream_socket_perms;
# Allow pyzor to be run by hand. Needed by any action other than
# invocation from a spam filter. allow $1_pyzor_t $1_devpts_t:chr_file rw_file_perms; allow $1_pyzor_t sshd_t:fd use; ')
#
# Pyzor - Pyzor is a collaborative, networked system to detect and
# block spam using identifying digests of messages.
#
# Author: David Hampton <[email protected]>
#
# NOTE: This policy is based upon the FC3 pyzor rpm from ATrpms. # Pyzor normally dumps everything into $HOME/.pyzor. By putting the
# following line to the spamassassin config file: # # pyzor_options --homedir /etc/pyzor # # the various files will be put into appropriate directories. # (I.E. The log file into /var/log, etc.) This policy will work # either way.
type pyzor_port_t, port_type, reserved_port_type;
##########
# pyzor daemon ########## daemon_domain(pyzord, `, privlog, nscd_client_domain') pyzor_base_domain(pyzord) allow pyzord_t pyzor_port_t:udp_socket name_bind; home_domain_access(pyzord_t, sysadm, pyzor) log_domain(pyzord)
# Read shared daemon/client config filer_dir_file(pyzord_t, pyzor_etc_t)
# Write shared daemon/client data dir
allow pyzord_t var_lib_t:dir search;create_dir_file(pyzord_t, pyzor_var_lib_t)
##########
# Pyzor query application - from system_r applictions
##########
type pyzor_t, domain, privlog, daemon;
type pyzor_exec_t, file_type, sysadmfile, exec_type; role system_r types pyzor_t;
pyzor_base_domain(pyzor)
# System config/data filesetcdir_domain(pyzor)var_lib_domain(pyzor)
##########
##########
#
# Some spam filters executes the pyzor code directly. Allow them access here. #
ifdef(spamd.te',domain_auto_trans(spamd_t, pyzor_exec_t, pyzor_t);
# pyzor needs access to the email spamassassin is checking allow pyzor_t spamd_tmp_t:file r_file_perms; ')
Quoted 1 line
From pyzor.te:
##########
# pyzor daemon ########## daemon_domain(pyzord, `, privlog, nscd_client_domain') pyzor_base_domain(pyzord) allow pyzord_t pyzor_port_t:udp_socket name_bind; home_domain_access(pyzord_t, sysadm, pyzor)
Why home_domain_access()?
There is no sysadm_pyzor_home_t defined, so it causes an error.
Quoted 8 lines · David Hampton
This is a new strict policy for the pyzor spam filter. It is based on the selinux-policy-strict-sources-1.23.2-1 fedora RPM. This policy requires the definition of a pyzor reserved port that was in the
net_contextsdiff I sent last Wednesday. Please let me know if there are any problems with or changes needed to this policy.David
Signature · 8 lines
James Carter <[email protected]> National Security Agency -- 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.
Quoted 3 lines · James Carter
Quoted 1 line
From pyzor.te:
Why
home_domain_access()?
If you don't specify a directory with the --homedir argument, pyzor creates a ~/.pyzor directory to store its files. I've had them created as both /root/.pyzor and /home/david/.pyzor depending upon which uid I use to run the applications. Try something like:
cat virus-20050321-104527-01034-08 | pyzor check
as various users.
Quoted 1 line
There is no
sysadm_pyzor_home_tdefined, so it causes an error.
Oops. That would be because I forgot to include a diff to base_user_macros.te. Attached below.
David
Index: macros/base_user_macros.te
===================================================================
RCS file: /home/cvs/starfury/etc/selinux/strict/src/policy/macros/base_user_macros.te,v retrieving revision 1.1
base_user_macros.te +2 -0
@@ -185,6 +185,8 @@ ifdef(`ssh.te', `ssh_domain($1)') ifdef(`irc.te', `irc_domain($1)') ifdef(`using_spamassassin', `spamassassin_domain($1)') +ifdef(`pyzor.te', `pyzor_domain($1)') +ifdef(`razor.te', `razor_domain($1)') ifdef(`uml.te', `uml_domain($1)') ifdef(`cdrecord.te', `cdrecord_domain($1)') ifdef(`mplayer.te', `mplayer_domains($1)')
Quoted 9 lines · David Hampton
Quoted 3 lines · James Carter
Quoted 1 line
From pyzor.te:
Why
home_domain_access()?If you don't specify a directory with the --homedir argument, pyzor creates a ~/.pyzor directory to store its files. I've had them created as both
/root/.pyzorand/home/david/.pyzordepending upon which uid I use to run the applications.
... btw just as an aside, what the heck is razor doing attempting to create /razor.log and /root/razor.log?
l.
--
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.
Quoted 2 lines · Luke Kenneth Casson Leighton
... btw just as an aside, what the heck is razor doing attempting to create /razor.log and
/root/razor.log?
The first time you run razor it can't find a config file telling it where to put its log, so it drops the log into the current working directory. It then attempts to create a ~/.razor home directory and default config file. All subsequent invocations of razor will find the just created config file and put the log where it specifies (which is ~/.razor by default).
The /razor.log is probably from the first invocation by a system daemon, and the /root/razor.log from the first time you tested it as root.
David
--
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.
James Carter
AppliedMerged into the SELinux policy CVS tree at sourceforge.
Quoted 8 lines · David Hampton
This is a new strict policy for the pyzor spam filter. It is based on the selinux-policy-strict-sources-1.23.2-1 fedora RPM. This policy requires the definition of a pyzor reserved port that was in the
net_contextsdiff I sent last Wednesday. Please let me know if there are any problems with or changes needed to this policy.David
Signature · 8 lines
James Carter <[email protected]> National Security Agency -- 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.