Apache policy
I've been working on re-writing the Apache policy.
My new version is macro based, supports multiple user roles, and removes a lot of the cruft that had accumulated in the Apache policy.
I've attached all the Apache files (the changes are to big for a diff to be of much use) and the user_macros.te file which also has a minor change.
This one needs some testing, there's lots of significant changes.
Signature · 4 lines
http://www.coker.com.au/selinux/ My NSA Security Enhanced Linux packages http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark http://www.coker.com.au/postal/ Postal SMTP/POP benchmark http://www.coker.com.au/~russell/ My home page
# apache /var/www/html(/.*)? system_u:object_r:httpd_sys_content_t /var/www/mrtg(/.*)? system_u:object_r:httpd_sys_content_t /var/www/cgi-bin(/.*)? system_u:object_r:httpd_sys_script_exec_t /usr/lib/cgi-bin(/.*)? system_u:object_r:httpd_sys_script_exec_t /var/www/perl(/.*)? system_u:object_r:httpd_sys_script_exec_t /var/www/icons(/.*)? system_u:object_r:httpd_sys_content_t /var/cache/httpd(/.*)? system_u:object_r:httpd_cache_t /etc/httpd system_u:object_r:httpd_config_t /etc/httpd/conf(/.*)? system_u:object_r:httpd_config_t /etc/httpd/logs system_u:object_r:httpd_log_t /etc/httpd/modules system_u:object_r:httpd_modules_t /etc/apache(2)?(/.*)? system_u:object_r:httpd_config_t /etc/vhosts system_u:object_r:httpd_config_t /usr/lib/apache(/.*)? system_u:object_r:httpd_modules_t /usr/lib/apache2/modules(/.*)? system_u:object_r:httpd_modules_t /usr/sbin/httpd system_u:object_r:httpd_exec_t /usr/sbin/apache(2)? system_u:object_r:httpd_exec_t /usr/sbin/suexec system_u:object_r:httpd_suexec_exec_t /usr/lib/cgi-bin/(nph-)?cgiwrap(d)? system_u:object_r:httpd_suexec_exec_t /usr/lib/apache(2)?/suexec(2)? system_u:object_r:httpd_suexec_exec_t /var/log/httpd(/.*)? system_u:object_r:httpd_log_t /var/log/apache(2)?(/.*)? system_u:object_r:httpd_log_t /var/log/cgiwrap.log.* system_u:object_r:httpd_log_t /var/cache/ssl.*\.sem system_u:object_r:httpd_cache_t /var/run/apache(2)?.pid.* system_u:object_r:var_run_httpd_t
#DESC Apache - Web server
#
###############################################################################
#
# Policy file for running the Apache web server
#
# NOTES:
# This policy will work with SUEXEC enabled as part of the Apache # configuration. However, the user CGI scripts will run under the # system_u:system_r:httpd_$1_script_t domain where $1 is the domain of the # of the creating user. # # The user CGI scripts must be labeled with the httpd_$1_script_exec_t # type, and the directory containing the scripts should also be labeled # with these types. This policy allows user_r role to perform that # relabeling. If it is desired that only sysadm_r should be able to relabel # the user CGI scripts, then relabel rule for user_r should be removed.
#
###############################################################################
type http_port_t, port_type;
type http_cache_port_t, port_type;
#########################################################
# Apache types
#########################################################
# httpd_config_t is the type given to the configuration # files for apache /etc/httpd/conf # type httpd_config_t, file_type, sysadmfile;
log_domain(httpd)
# httpd_modules_t is the type given to module files (libraries) # that come with Apache /etc/httpd/modules and /usr/lib/apache # type httpd_modules_t, file_type, sysadmfile;
# httpd_cache_t is the type given to the /var/cache/httpd # directory and the files under that directory # type httpd_cache_t, file_type, sysadmfile;
# httpd_exec_t is the type give to the httpd executable. # daemon_domain(httpd)
general_domain_access(httpd_t)
# setup the system domain for system CGI scripts apache_domain(sys)
#every_domain(httpd_t)
#
# A type for tmpfs file system
#
type httpd_tmpfs_t, file_type, sysadmfile;
# The following are types for SUEXEC,which runs user scripts as their
# own user ID # daemon_sub_domain(httpd_t, httpd_suexec)
#########################################################
# Permissions for running child processes and scripts
##########################################################
allow httpd_suexec_t httpd_suexec_t:capability { setuid setgid };
allow httpd_suexec_t httpd_log_t:dir search; allow httpd_suexec_t httpd_log_t:file { append getattr };
allow httpd_suexec_t httpd_t:fifo_file {getattr} ;
ifdef(mta.te',
# apache should set close-on-exec
dontaudit httpd_suexec_t httpd_t:unix_stream_socket { read write };
dontaudit { system_mail_t mta_user_agent } httpd_t:unix_stream_socket { read write };
')uses_shlib(httpd_t)
# execute perl can_exec(httpd_t, bin_t)
can_network(httpd_t)
###################
# Allow httpd to search users diretories
######################
allow httpd_t home_root_t:dir { getattr search };
dontaudit httpd_t sysadm_home_dir_t:dir getattr;
############################################################################
# Allow the httpd_t the capability to bind to a port and various other stuff
############################################################################
allow httpd_t httpd_t:capability {chown net_bind_service setgid setuid kill dac_override dac_read_search };
#################################################
# Allow the httpd_t to read the web servers config files
###################################################r_dir_file(httpd_t, httpd_config_t)
# allow logrotate to read the config files for restart ifdef(`logrotate.te', ` r_dir_file(logrotate_t, httpd_config_t) ') r_dir_file(initrc_t, httpd_config_t) ##################################################
########################################
# Allow httpd_t to bind to the HTTP port
########################################
allow httpd_t { http_port_t http_cache_port_t }:tcp_socket name_bind;
###############################
# Allow httpd_t to put files in /var/cache/httpd etc
##############################create_dir_file(httpd_t, httpd_cache_t)
###############################
# Allow httpd_t to access the tmpfs file system
##############################file_type_auto_trans(httpd_t, tmpfs_t, httpd_tmpfs_t) allow httpd_tmpfs_t tmpfs_t:filesystem associate;
#####################
# Allow httpd_t to access
# libraries for its modules ############################### can_exec(httpd_t, httpd_modules_t) allow httpd_t httpd_modules_t:dir r_dir_perms; allow httpd_t httpd_modules_t:lnk_file r_file_perms;
######################################################################
# Allow initrc_t to access the Apache modules directory.
######################################################################
allow initrc_t httpd_modules_t:dir r_dir_perms;
##############################################
# Allow httpd_t to have access to files
# such as nisswitch.conf
###############################################
allow httpd_t { etc_t resolv_conf_t }:file { read getattr };
allow httpd_t etc_t:lnk_file read;# Several options for handling SSI exec cmd elements:
# Option #1: Don't support them at all. This is the default, since
# httpd_t is not permitted to execute shell_exec_t. # Option #2: Run SSI exec's in the same domain as system CGI scripts. # Uncomment the following line to enable: #domain_auto_trans(httpd_t, shell_exec_t, httpd_sys_script_t) # Option #3: Run SSI exec's directly in the httpd_t domain. This means # that they have the same permissions as the daemon. Probably not a good idea. # Uncomment the following line to enable: #can_exec(httpd_t, shell_exec_t)
##################################################
#
# PHP Directives
##################################################
type httpd_php_exec_t, file_type, exec_type;
type httpd_php_t, domain;
# Transition from the user domain to this domain. domain_auto_trans(httpd_t, httpd_php_exec_t, httpd_php_t)
# The system role is authorized for this domain.
role system_r types httpd_php_t;
general_domain_access(httpd_php_t)general_file_read_access(httpd_php_t)uses_shlib(httpd_php_t)can_exec(httpd_php_t, lib_t)
# allow php to read and append to apache logfiles allow httpd_php_t httpd_log_t:file ra_file_perms;
# access to /tmp tmp_domain(httpd_php);
# Creation of lock files for apache2lock_domain(httpd)
# connect to mysql
ifdef(`mysqld.te', `
can_unix_connect(httpd_php_t, mysqld_t)
allow httpd_php_t var_run_mysqld_t:dir { search };
allow httpd_php_t var_run_mysqld_t:sock_file { write };
')define(apache_domain',
#This type is for webpages
#
type httpd_$1_content_t, file_type, sysadmfile;
# This type is used for .htaccess files
#
type httpd_$1_htaccess_t, file_type, sysadmfile;
# Type that CGI scripts run as
#daemon_sub_domain(httpd_t, httpd_$1_script)
# The following are the only areas that
# scripts can read, read/write, or append to # type httpd_$1_script_ro_t, file_type, sysadmfile; type httpd_$1_script_rw_t, file_type, sysadmfile; file_type_auto_trans(httpd_$1_script_t, tmp_t, httpd_$1_script_rw_t) type httpd_$1_script_ra_t, file_type, sysadmfile;
#########################################################
# Permissions for running child processes and scripts
##########################################################domain_auto_trans(httpd_suexec_t, httpd_$1_script_exec_t, httpd_$1_script_t)
allow httpd_suexec_t httpd_$1_script_exec_t:dir { search getattr }; allow httpd_suexec_t httpd_$1_script_exec_t:file { execute entrypoint };
allow httpd_$1_script_t httpd_t:fifo_file { write };
allow httpd_$1_script_t random_device_t:chr_file r_file_perms;
###########################################################################
# Allow the script interpreters to run the scripts. So
# the perl executable will be able to run a perl script ######################################################################### can_exec(httpd_$1_script_t, bin_t)
############################################################################
# Allow the script process to search the cgi directory, and users directory
##############################################################################
allow httpd_$1_script_t httpd_$1_script_exec_t:dir {search add_name}; allow httpd_$1_script_t home_root_t:dir { getattr search }; allow httpd_$1_script_t httpd_$1_content_t:dir {search};
#############################################################################
# Allow the scripts to read, read/write, append to the specified directories
# or files ############################################################################ r_dir_file(httpd_$1_script_t, httpd_$1_script_ro_t) create_dir_file(httpd_$1_script_t, httpd_$1_script_rw_t) ra_dir_file(httpd_$1_script_t, httpd_$1_script_ra_t)
ifelse($1, sys, `
#
# If a user starts a script by hand it gets the proper context #domain_auto_trans(sysadm_t, httpd_$1_script_t, httpd_$1_script_t) role sysadm_r types httpd_$1_script_t;
', `
#
# If a user starts a script by hand it gets the proper context #domain_auto_trans($1_t, httpd_$1_script_t, httpd_$1_script_t) role $1_r types httpd_$1_script_t;
#######################################
# Allow user to create or edit web content
#########################################
create_dir_file($1_t, { httpd_$1_content_t httpd_$1_script_t })
allow $1_t { httpd_$1_content_t httpd_$1_script_t }:{ dir file lnk_file } { relabelto relabelfrom };
######################################################################
# Allow the user to create htaccess files
#####################################################################
allow $1_t httpd_$1_htaccess_t:{ file lnk_file } { create_file_perms relabelto relabelfrom };
#########################################################################
# Allow user to create files or directories
# that scripts are able to read, write, or append to ###########################################################################
create_dir_file($1_t, { httpd_$1_script_ro_t httpd_$1_script_rw_t httpd_$1_script_ra_t })
allow $1_t { httpd_$1_script_ro_t httpd_$1_script_rw_t httpd_$1_script_ra_t }:{ file dir lnk_file } { relabelto relabelfrom };
# allow accessing files/dirs below the users home dir
allow httpd_$1_script_t $1_home_dir_t:dir {getattr search};
allow httpd_t $1_home_dir_t:dir { getattr search };
')################################################################
# Allow the web server to run scripts and serve pages
##############################################################
allow httpd_t httpd_$1_content_t:file r_file_perms; allow httpd_t httpd_$1_content_t:dir r_dir_perms;
allow httpd_t httpd_$1_htaccess_t: file r_file_perms;
allow httpd_t httpd_$1_script_exec_t:file {execute getattr read}; allow httpd_t httpd_$1_script_t:process {signal sigkill sigstop}; allow httpd_t httpd_$1_script_t:process {transition}; allow httpd_t httpd_$1_script_exec_t:dir r_dir_perms;
allow httpd_t httpd_$1_script_rw_t:file r_file_perms; allow httpd_t httpd_$1_script_rw_t:dir r_dir_perms;
############################################
# Allow scripts to append to http logs
#########################################
allow httpd_$1_script_t httpd_log_t:file append;
')
#
# Macros for all user login domains.
#
#
# user_domain(domain_prefix)
#
# Define derived types and rules for an ordinary user domain. #
# The type declaration and role authorization for the domain must be
# provided separately. Likewise, domain transitions into this domain
# must be specified separately. If the every_domain() rules are desired,
# then these rules must also be specified separately.
#
undefine(`user_domain')
define(`user_domain',`
# Use capabilities
allow $1_t self:capability { setgid chown fowner };
dontaudit $1_t self:capability { sys_nice fsetid };# Type for home directory.
ifelse($1, sysadm, `
type $1_home_dir_t, file_type, sysadmfile, home_dir_type, home_type;
type $1_home_t, file_type, sysadmfile, home_type;tmp_domain($1)
', `
type $1_home_dir_t, file_type, sysadmfile, home_dir_type, user_home_dir_type, home_type, user_home_type; type $1_home_t, file_type, sysadmfile, home_type, user_home_type;
# do not allow privhome access to sysadm_home_dir_t file_type_auto_trans(privhome, $1_home_dir_t, $1_home_t) tmp_domain($1, `, user_tmpfile') ')
# Create, access, and remove files in home directory. file_type_auto_trans($1_t, $1_home_dir_t, $1_home_t) allow $1_t $1_home_t:dir_file_class_set { relabelfrom relabelto };
# Bind to a Unix domain socket in /tmp.
allow $1_t $1_tmp_t:unix_stream_socket name_bind;
# Type for tty devices.
type $1_tty_device_t, file_type, sysadmfile, ttyfile;
# Access ttys.
allow $1_t $1_tty_device_t:chr_file { setattr rw_file_perms }; # Use the type when relabeling terminal devices.type_change $1_t tty_device_t:chr_file $1_tty_device_t; ifdef(dpkg.te',
# Debian login is from shadow utils and does not allow resetting the perms.
# have to fix this! type_change $1_t ttyfile:chr_file $1_tty_device_t; ')
# Type and access for pty devices.
ifelse($1', sysadm', `can_create_pty($1)
', `
can_create_pty($1, `, userpty_type')
')
# Use the type when relabeling pty devices. ifdef(`rlogind.te',type_change $1_t rlogind_devpts_t:chr_file $1_devpts_t;') ifdef(ssh.te', `type_change $1_t sshd_devpts_t:chr_file $1_devpts_t;
# Access /tmp/ssh files.
allow $1_t sshd_tmp_t:dir rw_dir_perms;
allow $1_t sshd_tmp_t:file create_file_perms;
# Connect to sshd.can_tcp_connect($1_t, sshd_t)
# Connect to ssh proxy.can_tcp_connect($1_t, $1_ssh_t)
allow $1_t sshd_t:fd use;
allow $1_t sshd_t:tcp_socket rw_stream_socket_perms; # Use a Unix stream socket inherited from sshd. allow $1_t sshd_t:unix_stream_socket rw_stream_socket_perms; ')dnl end of ssh section
# Type for tmpfs/shm files.
type $1_tmpfs_t, file_type, sysadmfile, tmpfsfile; # Use the type when creating files in tmpfs. file_type_auto_trans($1_t, tmpfs_t, $1_tmpfs_t) allow $1_tmpfs_t tmpfs_t:filesystem associate;
# Read and write /var/catman.
allow $1_t catman_t:dir rw_dir_perms;
allow $1_t catman_t:notdevfile_class_set create_file_perms;
# Modify mail spool file.
allow $1_t mail_spool_t:dir r_dir_perms;
allow $1_t mail_spool_t:file rw_file_perms;
allow $1_t mail_spool_t:lnk_file read;
#
# Allow the query of filesystem quotas
#
allow $1_t fs_type:filesystem quotaget;
# Run helper programs.can_exec_any($1_t)
# Run programs developed by other users in the same domain. can_exec($1_t, $1_home_t)can_exec($1_t, $1_tmp_t)
# Run user programs that require different permissions in their own domain. # These rules were moved into the individual program domains.
# Instantiate derived domains for a number of programs. # These derived domains encode both information about the calling
# user domain and the program, and allow us to maintain separation # between different instances of the program being run by different # user domains. ifdef(`gnome-pty-helper.te', `gph_domain($1)') ifdef(`su.te', `su_domain($1)') ifdef(`chkpwd.te', `chkpwd_domain($1)') ifdef(`screen.te', `screen_domain($1)') ifdef(`netscape.te', `netscape_domain($1)') ifdef(`games.te', ` x_client_domain($1, games) rw_dir_create_file($1_games_t, games_data_t) ') ifdef(`gpg.te', `gpg_domain($1)') ifdef(`xauth.te', `xauth_domain($1)') ifdef(`xserver.te', `xserver_domain($1)') ifdef(`lpr.te', `lpr_domain($1)') ifdef(`mta.te', `mail_domain($1)') ifdef(`sendmail.te', `sendmail_user_domain($1)') ifdef(`crontab.te', `crontab_domain($1)') ifdef(`ssh.te', `ssh_domain($1)') ifdef(`irc.te', `irc_domain($1)') ifdef(`uml.te', `uml_domain($1)') ifdef(`clamav.te', `user_clamscan_domain($1)') ifdef(`fingerd.te', `fingerd_macro($1)')
# Instantiate a derived domain for user cron jobs. ifdef(crond.te', crond_domain($1)')
ifdef(vmware.te',
# probably should have a separate domain for each user file_type_auto_trans(vmware_user_t, $1_home_dir_t, vmware_user_file_t) ')
# Read the mouse.
allow $1_t mouse_device_t:chr_file r_file_perms; # Access other miscellaneous devices.
allow $1_t misc_device_t:file_class_set rw_file_perms;
ifdef(apache.te',
ifelse($1', sysadm', ', apache_domain($1)
')
')
# Use the network.can_network($1_t)
#
# connect_secure and sendmsg_secure calls with a # peer or destination socket SID can be enforced # when using the loopback interface. Enforcement # for real network interfaces will be possible when # a packet labeling mechanism is integrated. # allow $1_t node_lo_t:node enforce_dest;
# Communicate within the domain.can_udp_send($1_t, $1_t)can_tcp_connect($1_t, $1_t)
# Connect to inetd.
ifdef(inetd.te', can_tcp_connect($1_t,inetd_t)')
ifdef(`rshd.te',
`# Connect second port to rshd.can_tcp_connect(rshd_t, $1_t)')
# Connect data port to ftpd.
ifdef(ftpd.te', can_tcp_connect(ftpd_t, $1_t)')
# Connect to portmap.
ifdef(portmap.te', can_tcp_connect($1_t, portmap_t)')
# Inherit and use sockets from inetd ifdef(`inetd.te',
`allow $1_t inetd_t:fd use;
allow $1_t inetd_t:tcp_socket rw_stream_socket_perms;')
# Allow system log read
#allow $1_t kernel_t:system syslog_read;
# else do not log it dontaudit $1_t kernel_t:system syslog_read;
# Very permissive allowing every domain to see every type. allow $1_t kernel_t:system { ipc_info };
# When the user domain runs ps, there will be a number of access
# denials when ps tries to search /proc. Do not audit these denials. dontaudit $1_t domain:dir r_dir_perms; dontaudit $1_t domain:notdevfile_class_set r_file_perms;
# Some shells ask for w access to utmp, but will operate
# correctly without it. Do not audit write denials to utmp.
dontaudit $1_t initrc_var_run_t:file { read write };# do not audit getattr on tmpfile, otherwise ls -l /tmp fills the logs dontaudit $1_t tmpfile:dir_file_class_set getattr;
ifdef(xdm.te',
# Connect to the X server run by the X Display Manager. can_unix_connect($1_t, xdm_t)
allow $1_t xdm_tmp_t:sock_file rw_file_perms; allow $1_t xdm_tmp_t:dir r_dir_perms;
allow $1_t xdm_xserver_tmp_t:sock_file { read write }; allow $1_t xdm_xserver_tmp_t:dir search;
ifelse($1', sysadm, ', `file_type_auto_trans(xdm_t, $1_home_dir_t, $1_home_xauth_t, file) ')dnl end ifelse sysadm
')dnl end ifdef xdm.te
# Access the sound device.
allow $1_t sound_device_t:chr_file { getattr read write ioctl };
# Allow reading dpkg origins file
ifdef(dpkg.te', r_dir_file($1_t, etc_dpkg_t)
')
ifdef(ftpd.te',
# uncomment the following for FTP access to all home directories # or you can just enable FTP access for certain user domains in the ftpd.te # file #file_type_auto_trans(ftpd_t, $1_home_dir_t, $1_home_t) ')
')
###########################################################################
#
# Domains for ordinary users.
#
undefine(`full_user_role')
define(full_user_role',
# user_t/$1_t is an unprivileged users domain.
type $1_t, domain, userdomain, unpriv_userdomain;
# $1_r is authorized for $1_t for the initial login domain. role $1_r types $1_t;
allow system_r $1_r;
# user domains are granted the permissions common to most domains. every_domain($1_t) # $1_t is also granted permissions specific to user domains. user_domain($1)
# When an ordinary user domain runs su, su may try to
# update the /root/.Xauthority file, and the user shell may
# try to update the shell history. This isnt allowed, but
# we dont need to audit it.
ifdef(`su.te', `
dontaudit $1_su_t sysadm_home_t:dir { read getattr search write add_name remove_name };
dontaudit $1_su_t sysadm_home_t:file { read getattr create write link unlink };')
dontaudit $1_t sysadm_home_t:dir { read search getattr };
dontaudit $1_t sysadm_home_t:file { read getattr append };ifdef(syslogd.te',
# Some programs that are left in $1_t will try to connect
# to syslogd, but we do not want to let them generate log messages.
# Do not audit.
dontaudit $1_t devlog_t:sock_file { read write };
dontaudit $1_t syslogd_t:unix_dgram_socket sendto;
')# stop warnings about "ls -l" on directories with unlabelled files
dontaudit $1_t file_t:{ dir file lnk_file } getattr;
')undefine(`in_user_role')
define(in_user_role',
role user_r types $1;
#role staff_r types $1;
')
Quoted 2 lines · Russell Coker
I've been working on re-writing the Apache policy.
I haven't been able to test this yet, but here's some comments:
apache_macros.te:
- lines 61 and 67 domain_auto_trans via httpd_$1_script_t to httpd_$1_script_t. Should trans through script_exec_t or script_r?_t.
- line 74 allows user to create file with label httpd_$1_script_t. Should be exec_t, r?_t, etc.
- Why does httpd_t need access to httpd_$1_script_t (line 110)?
- Does $1_t need create permissions for script_exec_t? (around line 88)
- Uses ra_dir_file() macro; I've added global_macros (see patch)
apache.te
- Uses lock_domain() macro, not currently present in our tree.
I've attached a patch that fixes up some of the other policy files affected by your changes. However, for httpadm.te, this problem is created:
httpadm.te
- type httpd_sys_script_exec_t is an exec_type; this rule in the httpd_admin_domain() macro:
allow $1_t httpd_sys_script_exec_t:file create_file_perms
violates this assertion in assert.te:
neverallow ~{ldconfig_t admin} { exec_type ld_so_t shlib_t }:file {
write append unlink rename };
Thanks,
Signature · 2 lines
Wayne Salamon [email protected]
domains/httpadm.te +32 -32
@@ -24,10 +24,10 @@ ###################################################### # Allow the httpd_admin_t to view or edit the web server log files ####################################################### -allow $1_t httpd_log_files_t:file create_file_perms; -allow $1_t httpd_log_files_t:dir rw_dir_perms ; -allow $1_t httpd_log_files_t:security { sid_to_context }; -allow $1_t httpd_log_files_t:lnk_file link_file_perms; +allow $1_t httpd_log_t:file create_file_perms; +allow $1_t httpd_log_t:dir rw_dir_perms ; +allow $1_t httpd_log_t:security { sid_to_context }; +allow $1_t httpd_log_t:lnk_file link_file_perms; ################################################## # Allow the httpd_admin_t to view files in /etc/httpd/modules
@@ -56,20 +56,20 @@ allow $1_t httpd_sys_content_t:lnk_file {create}; allow $1_t httpd_user_content_t:lnk_file {create}; -allow $1_t httpd_sys_script_t:file create_file_perms; -allow $1_t httpd_sys_script_t:dir create_dir_perms; -allow $1_t httpd_sys_script_t:lnk_file {create}; +allow $1_t httpd_sys_script_exec_t:file create_file_perms; +allow $1_t httpd_sys_script_exec_t:dir create_dir_perms; +allow $1_t httpd_sys_script_exec_t:lnk_file {create}; allow $1_t httpd_sys_htaccess_t:file create_file_perms; allow $1_t httpd_sys_htaccess_t:lnk_file {create}; -allow $1_t httpd_sys_script_r_t:file create_file_perms; -allow $1_t httpd_sys_script_r_t:lnk_file {create}; -allow $1_t httpd_sys_script_r_t:dir create_dir_perms; - -allow $1_t httpd_user_script_r_t:file create_file_perms; -allow $1_t httpd_user_script_r_t:lnk_file {create}; -allow $1_t httpd_user_script_r_t:dir create_dir_perms; +allow $1_t httpd_sys_script_ro_t:file create_file_perms; +allow $1_t httpd_sys_script_ro_t:lnk_file {create}; +allow $1_t httpd_sys_script_ro_t:dir create_dir_perms; + +allow $1_t httpd_user_script_ro_t:file create_file_perms; +allow $1_t httpd_user_script_ro_t:lnk_file {create}; +allow $1_t httpd_user_script_ro_t:dir create_dir_perms; allow $1_t httpd_sys_script_rw_t:file rw_file_perms; allow $1_t httpd_sys_script_rw_t:lnk_file {create};
@@ -79,13 +79,13 @@ allow $1_t httpd_user_script_rw_t:lnk_file {create}; allow $1_t httpd_user_script_rw_t:dir rw_dir_perms; -allow $1_t httpd_sys_script_a_t:file ra_file_perms; -allow $1_t httpd_sys_script_a_t:lnk_file {create}; -allow $1_t httpd_sys_script_a_t:dir ra_dir_perms; - -allow $1_t httpd_user_script_a_t:file ra_file_perms; -allow $1_t httpd_user_script_a_t:lnk_file {create}; -allow $1_t httpd_user_script_a_t:dir ra_dir_perms; +allow $1_t httpd_sys_script_ra_t:file ra_file_perms; +allow $1_t httpd_sys_script_ra_t:lnk_file {create}; +allow $1_t httpd_sys_script_ra_t:dir ra_dir_perms; + +allow $1_t httpd_user_script_ra_t:file ra_file_perms; +allow $1_t httpd_user_script_ra_t:lnk_file {create}; +allow $1_t httpd_user_script_ra_t:dir ra_dir_perms; #################################### # Allow a domain change to httpd_admin_t via the newrole command
@@ -97,26 +97,26 @@ allow newrole_t $1_t:process {transition}; ############################################################################# -# Allow the httpd admin to use chcon to change contexts on scripts, web pages, +# Allow the httpd admin to use chcon to change contexts on scripts, web pages, # and htaccess files. ########################################################################### -allow $1_t httpd_sys_script_t:dir {relabelto}; -allow $1_t httpd_sys_script_a_t:dir {relabelto}; -allow $1_t httpd_sys_script_r_t:dir {relabelto}; +allow $1_t httpd_sys_script_exec_t:dir {relabelto}; +allow $1_t httpd_sys_script_ra_t:dir {relabelto}; +allow $1_t httpd_sys_script_ro_t:dir {relabelto}; allow $1_t httpd_sys_script_rw_t:dir {relabelto}; -allow $1_t httpd_user_script_t:dir {relabelto}; -allow $1_t httpd_user_script_a_t:dir {relabelto}; -allow $1_t httpd_user_script_r_t:dir {relabelto}; +allow $1_t httpd_user_script_exec_t:dir {relabelto}; +allow $1_t httpd_user_script_ra_t:dir {relabelto}; +allow $1_t httpd_user_script_ro_t:dir {relabelto}; allow $1_t httpd_user_script_rw_t:dir {relabelto}; -allow $1_t httpd_sys_script_a_t:file {relabelto}; -allow $1_t httpd_sys_script_r_t:file {relabelto}; +allow $1_t httpd_sys_script_ra_t:file {relabelto}; +allow $1_t httpd_sys_script_ro_t:file {relabelto}; allow $1_t httpd_sys_script_rw_t:file {relabelto}; -allow $1_t httpd_user_script_r_t:file {relabelto}; +allow $1_t httpd_user_script_ro_t:file {relabelto}; allow $1_t httpd_user_script_rw_t:file {relabelto}; -allow $1_t httpd_user_script_a_t:file {relabelto}; +allow $1_t httpd_user_script_ra_t:file {relabelto}; allow $1_t httpd_sys_content_t:dir {relabelto}; allow $1_t httpd_user_content_t:dir {relabelto};
domains/program/mailman.te +5 -5
@@ -59,17 +59,17 @@ mailman_domain(cgi) # for cgiwrap -domain_auto_trans(httpd_t, httpd_user_script_t, httpd_user_script_process_t) -can_exec(httpd_user_script_process_t, httpd_user_script_t) -allow httpd_user_script_process_t httpd_user_script_t:dir getattr; +domain_auto_trans(httpd_t, httpd_user_script_exec_t, httpd_user_script_t) +can_exec(httpd_user_script_t, httpd_user_script_exec_t) +allow httpd_user_script_t httpd_user_script_exec_t:dir getattr; -domain_auto_trans(httpd_user_script_process_t, mailman_cgi_exec_t, mailman_cgi_t) +domain_auto_trans(httpd_user_script_t, mailman_cgi_exec_t, mailman_cgi_t) # should have separate types for public and private archives r_dir_file(httpd_t, mailman_archive_t) allow httpd_t mailman_data_t:dir search; r_dir_file(mailman_cgi_t, mailman_archive_t) -dontaudit mailman_cgi_t httpd_log_files_t:file append; +dontaudit mailman_cgi_t httpd_log_t:file append; domain_auto_trans(httpd_t, mailman_cgi_exec_t, mailman_cgi_t) allow httpd_t mailman_cgi_t:process signal; allow mailman_cgi_t httpd_t:process sigchld;
domains/program/openca-ca.te +1 -1
@@ -84,7 +84,7 @@ ############################################ # Allow scripts to append to http logs ######################################### -allow openca_ca_t httpd_log_files_t:file { append getattr }; +allow openca_ca_t httpd_log_t:file { append getattr }; # # Allow access to writeable files under /etc/openca
macros/global_macros.te +5 -0
@@ -178,6 +178,11 @@ allow $1 $2:{ file lnk_file } r_file_perms; ') +define(`ra_dir_file', ` +allow $1 $2:dir ra_dir_perms; +allow $1 $2:{ file lnk_file } ra_file_perms; +') + define(`rw_dir_file', ` allow $1 $2:dir rw_dir_perms; allow $1 $2:{ file lnk_file } rw_file_perms;
Quoted 10 lines · Wayne Salamon
Quoted 1 line · Russell Coker
I've been working on re-writing the Apache policy.
I haven't been able to test this yet, but here's some comments:
apache_macros.te:
- lines 61 and 67domain_auto_transvia httpd_$1_script_t to httpd_$1_script_t. Should trans throughscript_exec_tor script_r?_t.
- line 74 allows user to create file with label httpd_$1_script_t. Should beexec_t, r?_t, etc.
I've already fixed those. I'll put a new archive on my web site on
http://www.coker.com.au/selinux/policy.tgz in a few minutes.
Quoted 1 line
- Why does
httpd_tneed access to httpd_$1_script_t (line 110)?
httpd_t needs to be able to read files that cgi-bin scripts write such as httpd_$1_script_rw_t. This is so that cgi-bin scripts can change other parts of the web site. It may be a bad idea though, perhaps I should comment it out and just leave it as a suggestion for those who need it?
Quoted 1 line
- Does $1_t need create permissions for
script_exec_t? (around line 88)
No. I can't find that in the version I sent you or the one in my current tree either.
Quoted 1 line
- Uses
ra_dir_file()macro; I've addedglobal_macros(see patch)
Yes.
Quoted 2 lines
apache.te
- Useslock_domain()macro, not currently present in our tree.
I put the following in global_macros.te:
define(lock_domain',
type $1_lock_t, file_type, sysadmfile, lockfile;file_type_auto_trans($1_t, var_lock_t, $1_lock_t)
')
Quoted 3 lines
I've attached a patch that fixes up some of the other policy files affected by your changes. However, for httpadm.te, this problem is created:
I've just removed httpadm.te entirely from my tree. My changes remove the need for it entirely.
The local administrator can define a new role in user.te for Apache administration and allow it to write to httpd_sys_script_exec_t and other similar file types. I'll probably write a macro to allow such access (so you can easily permit samba to perform such modifications etc).
PS There is still quite a bit of work to be done before this is release quality. This is a job I had been avoiding for about a year because it was so painful and because the problems with the previous version hadn't bitten me badly enough.
Signature · 10 lines
http://www.coker.com.au/selinux/ My NSA Security Enhanced Linux packages http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark http://www.coker.com.au/postal/ Postal SMTP/POP benchmark http://www.coker.com.au/~russell/ My home page -- 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 6 lines · Russell Coker
Quoted 2 lines
- Does $1_t need create permissions for
script_exec_t? (around line 88)No. I can't find that in the version I sent you or the one in my current tree either.
I meant, do we need to add this rule so users can relabel files ashttpd_user_script_exec_t? We also need a rule for sysadm_r to create httpd_sys_script_exec_t, right?
Quoted 4 lines
I've just removed httpadm.te entirely from my tree. My changes remove the need for it entirely.
OK, but doing that requires a change to our rbac file, and yours and our
openca-ca.te, I think. You want to remove httpd_admin_r and httpd_admin_t entirely, right?
Thanks,
Signature · 9 lines
Wayne Salamon [email protected] -- 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 10 lines · Wayne Salamon
Quoted 5 lines · Russell Coker
Quoted 2 lines
- Does $1_t need create permissions for
script_exec_t? (around line
88)No. I can't find that in the version I sent you or the one in my current tree either.
I meant, do we need to add this rule so users can relabel files as
httpd_user_script_exec_t? We also need a rule forsysadm_rto createhttpd_sys_script_exec_t, right?
Yes. I'll have to add that.
Quoted 6 lines
Quoted 2 lines
I've just removed httpadm.te entirely from my tree. My changes remove the need for it entirely.
OK, but doing that requires a change to our rbac file, and yours and our
openca-ca.te, I think. You want to removehttpd_admin_randhttpd_admin_tentirely, right?
Yes, I've done that in my tree.
Signature · 10 lines
http://www.coker.com.au/selinux/ My NSA Security Enhanced Linux packages http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark http://www.coker.com.au/postal/ Postal SMTP/POP benchmark http://www.coker.com.au/~russell/ My home page -- 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.