|
Chris PeBenito |
2705f9 |
# DESC yam - Yum/Apt Mirroring
|
|
Chris PeBenito |
2705f9 |
#
|
|
Chris PeBenito |
2705f9 |
# Author: David Hampton <hampton@employees.org>
|
|
Chris PeBenito |
2705f9 |
#
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
#
|
|
Chris PeBenito |
2705f9 |
# Yam downloads lots of files, indexes them, and makes them available
|
|
Chris PeBenito |
2705f9 |
# for upload. Define a type for these file.
|
|
Chris PeBenito |
2705f9 |
#
|
|
Chris PeBenito |
2705f9 |
type yam_content_t, file_type, sysadmfile, httpdcontent;
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
#
|
|
Chris PeBenito |
2705f9 |
# Common definitions used by both the command line and the cron
|
|
Chris PeBenito |
2705f9 |
# invocation of yam.
|
|
Chris PeBenito |
2705f9 |
#
|
|
Chris PeBenito |
2705f9 |
define(`yam_common',`
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
# Update the content being managed by yam.
|
|
Chris PeBenito |
2705f9 |
create_dir_file($1_t, yam_content_t)
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
# Content can also be on ISO image files.
|
|
Chris PeBenito |
2705f9 |
r_dir_file($1_t, iso9660_t)
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
# Need to go through /var to get to /var/yam
|
|
Chris PeBenito |
2705f9 |
# Go through /var/www to get to /var/www/yam
|
|
Chris PeBenito |
2705f9 |
allow $1_t var_t:dir { getattr search };
|
|
Chris PeBenito |
2705f9 |
allow $1_t httpd_sys_content_t:dir { getattr search };
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
# Allow access to locale database, nsswitch, and mtab
|
|
Chris PeBenito |
2705f9 |
read_locale($1_t)
|
|
Chris PeBenito |
2705f9 |
allow $1_t etc_t:file { getattr read };
|
|
Chris PeBenito |
2705f9 |
allow $1_t etc_runtime_t:file { getattr read };
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
# Python seems to need things from various places
|
|
Chris PeBenito |
2705f9 |
allow $1_t { bin_t sbin_t }:dir { search getattr };
|
|
Chris PeBenito |
2705f9 |
allow $1_t { bin_t sbin_t lib_t usr_t }:file { getattr read };
|
|
Chris PeBenito |
2705f9 |
allow $1_t bin_t:lnk_file read;
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
# Python works fine without reading /proc/meminfo
|
|
Chris PeBenito |
2705f9 |
dontaudit $1_t proc_t:dir search;
|
|
Chris PeBenito |
2705f9 |
dontaudit $1_t proc_t:file { getattr read };
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
# Yam wants to run rsync, lftp, mount, and a shell. Allow the latter
|
|
Chris PeBenito |
2705f9 |
# two here. Run rsync and lftp in the yam_t context so that we dont
|
|
Chris PeBenito |
2705f9 |
# have to give any other programs write access to the yam_t files.
|
|
Chris PeBenito |
2705f9 |
general_domain_access($1_t)
|
|
Chris PeBenito |
2705f9 |
can_exec($1_t, shell_exec_t)
|
|
Chris PeBenito |
2705f9 |
can_exec($1_t, rsync_exec_t)
|
|
Chris PeBenito |
2705f9 |
can_exec($1_t, bin_t)
|
|
Chris PeBenito |
2705f9 |
can_exec($1_t, usr_t) #/usr/share/createrepo/genpkgmetadata.py
|
|
Chris PeBenito |
2705f9 |
ifdef(`mount.te', `
|
|
Chris PeBenito |
2705f9 |
domain_auto_trans($1_t, mount_exec_t, mount_t)
|
|
Chris PeBenito |
2705f9 |
')
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
# Rsync and lftp need to network. They also set files attributes to
|
|
Chris PeBenito |
2705f9 |
# match whats on the remote server.
|
|
Chris PeBenito |
2705f9 |
can_network_client($1_t)
|
|
Chris PeBenito |
2705f9 |
allow $1_t { http_port_t rsync_port_t }:tcp_socket name_connect;
|
|
Chris PeBenito |
2705f9 |
allow $1_t self:capability { chown fowner fsetid dac_override };
|
|
Chris PeBenito |
2705f9 |
allow $1_t self:process execmem;
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
# access to sysctl_kernel_t ( proc/sys/kernel/* )
|
|
Chris PeBenito |
2705f9 |
read_sysctl($1_t)
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
# Programs invoked to build package lists need various permissions.
|
|
Chris PeBenito |
2705f9 |
# genpkglist creates tmp files in /var/cache/apt/genpkglist
|
|
Chris PeBenito |
2705f9 |
allow $1_t var_t:file { getattr read write };
|
|
Chris PeBenito |
2705f9 |
allow $1_t var_t:dir read;
|
|
Chris PeBenito |
2705f9 |
# mktemp
|
|
Chris PeBenito |
2705f9 |
allow $1_t urandom_device_t:chr_file read;
|
|
Chris PeBenito |
2705f9 |
# mv
|
|
Chris PeBenito |
2705f9 |
allow $1_t proc_t:lnk_file read;
|
|
Chris PeBenito |
2705f9 |
allow $1_t selinux_config_t:dir search;
|
|
Chris PeBenito |
2705f9 |
allow $1_t selinux_config_t:file { getattr read };
|
|
Chris PeBenito |
2705f9 |
')
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
##########
|
|
Chris PeBenito |
2705f9 |
##########
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
#
|
|
Chris PeBenito |
2705f9 |
# Runnig yam from the command line
|
|
Chris PeBenito |
2705f9 |
#
|
|
Chris PeBenito |
2705f9 |
application_domain(yam, `, nscd_client_domain')
|
|
Chris PeBenito |
2705f9 |
role system_r types yam_t;
|
|
Chris PeBenito |
2705f9 |
yam_common(yam)
|
|
Chris PeBenito |
2705f9 |
etc_domain(yam)
|
|
Chris PeBenito |
2705f9 |
tmp_domain(yam)
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
# Terminal access
|
|
Chris PeBenito |
2705f9 |
allow yam_t devpts_t:dir search;
|
|
Chris PeBenito |
2705f9 |
allow yam_t devtty_t:chr_file { read write };
|
|
Chris PeBenito |
2705f9 |
allow yam_t sshd_t:fd use;
|
|
Chris PeBenito |
2705f9 |
allow yam_t sysadm_devpts_t:chr_file { getattr ioctl read write };
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
# Reading dotfiles...
|
|
Chris PeBenito |
2705f9 |
allow yam_t sysadm_home_dir_t:dir search; # /root
|
|
Chris PeBenito |
2705f9 |
allow yam_t sysadm_home_t:dir search; # /root/xxx
|
|
Chris PeBenito |
2705f9 |
allow yam_t home_root_t:dir search; # /home
|
|
Chris PeBenito |
2705f9 |
allow yam_t user_home_dir_t:dir r_dir_perms; # /home/user
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
##########
|
|
Chris PeBenito |
2705f9 |
##########
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
#
|
|
Chris PeBenito |
2705f9 |
# Running yam from cron
|
|
Chris PeBenito |
2705f9 |
#
|
|
Chris PeBenito |
2705f9 |
application_domain(yam_crond, `, nscd_client_domain')
|
|
Chris PeBenito |
2705f9 |
role system_r types yam_crond_t;
|
|
Chris PeBenito |
2705f9 |
ifdef(`crond.te', `
|
|
Chris PeBenito |
2705f9 |
system_crond_entry(yam_exec_t, yam_crond_t)
|
|
Chris PeBenito |
2705f9 |
')
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
yam_common(yam_crond)
|
|
Chris PeBenito |
2705f9 |
allow yam_crond_t yam_etc_t:file r_file_perms;
|
|
Chris PeBenito |
2705f9 |
file_type_auto_trans(yam_crond_t, tmp_t, yam_tmp_t, `{ file dir }')
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
allow yam_crond_t devtty_t:chr_file { read write };
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
# Reading dotfiles...
|
|
Chris PeBenito |
2705f9 |
# LFTP uses a directory for its dotfiles
|
|
Chris PeBenito |
2705f9 |
allow yam_crond_t default_t:dir search;
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
# Don't know why init tries to read this.
|
|
Chris PeBenito |
2705f9 |
allow initrc_t yam_etc_t:file { getattr read };
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
##########
|
|
Chris PeBenito |
2705f9 |
##########
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
# The whole point of this program is to make updates available on a
|
|
Chris PeBenito |
2705f9 |
# local web server. Allow apache access to these files.
|
|
Chris PeBenito |
2705f9 |
ifdef(`apache.te', `
|
|
Chris PeBenito |
2705f9 |
r_dir_file(httpd_t, yam_content_t)
|
|
Chris PeBenito |
2705f9 |
')
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
ifdef(`webalizer.te', `
|
|
Chris PeBenito |
2705f9 |
dontaudit webalizer_t yam_content_t:dir search;
|
|
Chris PeBenito |
2705f9 |
')
|
|
Chris PeBenito |
2705f9 |
|
|
Chris PeBenito |
2705f9 |
# Mount needs access to the yam directories in order to mount the ISO
|
|
Chris PeBenito |
2705f9 |
# files on a loobpack file system.
|
|
Chris PeBenito |
2705f9 |
ifdef(`mount.te', `
|
|
Chris PeBenito |
2705f9 |
allow mount_t yam_content_t:dir mounton;
|
|
Chris PeBenito |
2705f9 |
allow mount_t yam_content_t:file { read write };
|
|
Chris PeBenito |
2705f9 |
')
|