Support read/append/manage functions for various httpd content
v2 cover Support read/append/manage functions for various httpd content
Within this patch set, we make the web content types as defined by the apache module more generic in use so that other domains, who need to interact with these types, can do so without getting too many privileges assigned (like with apache_manage_all_content).
Since v1, the following changes have been incorporated:
- Adding apache_search_all_content within the apache_append_all_ra_content_files interface
- Adding phpfpm_t domain as an example user for these interfaces
With thanks to Dominick Grift for his feedback.
Wkr,
Sven Vermeulen
PATCH v2 1/3 Support read/append/manage functions for various httpd content
Within the apache module, the apache_content_template() allows creation of additional derived types for "apache web content". But it is actually being used to label generic web content, and it creates additional types based on the prefix.
When we want to support additional web servers (or parsers used by web servers) that do not run within the apache-provided domains, they have a hard time accessing the data. There is currently one interface available, called "apache_manage_all_content" but that's a lot of privileges for a parser that needs to read content.
In this patch, we create additional attributes (like httpd_ra_content and httpd_rw_content) and define interfaces to manage the types that have these attributes assigned.
--- apache.if | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 126 insertions(+), 2 deletions(-)
apache.if +126 -2
@@ -16,6 +16,8 @@ template(`apache_content_template',` attribute httpdcontent; attribute httpd_exec_scripts; attribute httpd_script_exec_type; + attribute httpd_rw_content; + attribute httpd_ra_content; type httpd_t, httpd_suexec_t, httpd_log_t; ') # allow write access to public file transfer
@@ -41,11 +43,11 @@ template(`apache_content_template',` corecmd_shell_entry_type(httpd_$1_script_t) domain_entry_file(httpd_$1_script_t, httpd_$1_script_exec_t) - type httpd_$1_rw_content_t, httpdcontent; # customizable + type httpd_$1_rw_content_t, httpdcontent, httpd_rw_content; # customizable typealias httpd_$1_rw_content_t alias { httpd_$1_script_rw_t httpd_$1_content_rw_t }; files_type(httpd_$1_rw_content_t) - type httpd_$1_ra_content_t, httpdcontent; # customizable + type httpd_$1_ra_content_t, httpdcontent, httpd_ra_content; # customizable typealias httpd_$1_ra_content_t alias { httpd_$1_script_ra_t httpd_$1_content_ra_t }; files_type(httpd_$1_ra_content_t)
@@ -448,6 +450,128 @@ interface(`apache_dontaudit_rw_tcp_sockets',` ######################################## ## <summary> +## Read all appendable content. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +## <rolecap/> +# +interface(`apache_read_all_ra_content',` + gen_require(` + attribute httpd_ra_content; + ') + + read_files_pattern($1, httpd_ra_content, httpd_ra_content) + read_lnk_files_pattern($1, httpd_ra_content, httpd_ra_content) +') + +######################################## +## <summary> +## Append to all appendable web content files. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +## <rolecap/> +# +interface(`apache_append_all_ra_content_files',` + gen_require(` + attribute httpd_ra_content; + ') + + apache_search_all_content($1) + append_files_pattern($1, httpd_ra_content, httpd_ra_content) +') + +######################################## +## <summary> +## Read all read/write content. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +## <rolecap/> +# +interface(`apache_read_all_rw_content',` + gen_require(` + attribute httpd_rw_content; + ') + + read_files_pattern($1, httpd_rw_content, httpd_rw_content) + read_lnk_files_pattern($1, httpd_rw_content, httpd_rw_content) +') + +######################################## +## <summary> +## Manage all read/write content. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +## <rolecap/> +# +interface(`apache_manage_all_rw_content',` + gen_require(` + attribute httpd_rw_content; + ') + + manage_dirs_pattern($1, httpd_rw_content, httpd_rw_content) + manage_files_pattern($1, httpd_rw_content, httpd_rw_content) + manage_lnk_files_pattern($1, httpd_rw_content, httpd_rw_content) +') + +######################################## +## <summary> +## Read all web content. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +## <rolecap/> +# +interface(`apache_read_all_content',` + gen_require(` + attribute httpdcontent, httpd_script_exec_type; + ') + + read_files_pattern($1, httpdcontent, httpdcontent) + read_lnk_files_pattern($1, httpdcontent, httpdcontent) + + read_files_pattern($1, httpd_script_exec_type, httpd_script_exec_type) + read_lnk_files_pattern($1, httpd_script_exec_type, httpd_script_exec_type) +') + +######################################## +## <summary> +## Search all apache content. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`apache_search_all_content',` + gen_require(` + attribute httpdcontent; + ') + + allow $1 httpdcontent:dir search_dir_perms; +') + +######################################## +## <summary> ## Create, read, write, and delete all web content. ## </summary> ## <param name="domain">
Signature · 1 line
1.7.3.4
PATCH v2 2/3 Introducing phpfpm_t domain
In reply to Sven VermeulenThe PHP FactCGI Process Manager is a standalone daemon capable of handling web content and is specifically targeting high-traffic, dynamic sites.
Since it too is a web server, it needs access to the various http content types as declared through the apache module.
--- phpfpm.fc | 5 +++ phpfpm.if | 30 +++++++++++++++++++++ phpfpm.te | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 121 insertions(+), 0 deletions(-) create mode 100644 phpfpm.fc create mode 100644 phpfpm.if create mode 100644 phpfpm.te
phpfpm.fc new file +5 -0
@@ -0,0 +1,5 @@ +/usr/lib(64)?/php.*/bin/php-fpm gen_context(system_u:object_r:phpfpm_exec_t,s0) + +/var/log/php-fpm.log gen_context(system_u:object_r:phpfpm_log_t,s0) +/var/run/php-fpm.pid gen_context(system_u:object_r:phpfpm_var_run_t,s0) +
phpfpm.if new file +30 -0
@@ -0,0 +1,30 @@ +# <summary>PHP FastCGI Process Manager</summary> + +################################################# +## <summary> +## Administrate a phpfpm environment +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access +## </summary> +## </param> +# +interface(`phpfpm_admin',` + gen_require(` + type phpfpm_t; + type phpfpm_log_t, phpfpm_tmp_t, phpfpm_var_run_t; + ') + + allow $1 phpfpm_t:process { ptrace signal_perms }; + ps_process_pattern($1, phpfpm_t) + + logging_list_logs($1) + admin_pattern($1, phpfpm_log_t) + + files_list_tmp($1) + admin_pattern($1, phpfpm_tmp_t) + + files_list_pids($1) + admin_pattern($1, phpfpm_var_run_t) +')
phpfpm.te new file +86 -0
86 lines not on this page · raw message
Signature · 1 line
1.7.3.4
PATCH v2 2/3 Introducing phpfpm_t domain
Meh, didn't use double-comment in the interface' <summary>..</summary> block. Will report soonish.
PATCH v2 3/3 Allow sysadm_t to administer phpfpm environment
In reply to Sven Vermeulen--- policy/modules/roles/sysadm.te | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
policy/modules/roles/sysadm.te +4 -0
@@ -260,6 +260,10 @@ optional_policy(` ') optional_policy(` + phpfpm_admin(sysadm_t) +') + +optional_policy(` portage_run(sysadm_t, sysadm_r) portage_run_fetch(sysadm_t, sysadm_r) portage_run_gcc_config(sysadm_t, sysadm_r)
Signature · 1 line
1.7.3.4