Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proper SELinux context and setup appropriate booleans #405

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 66 additions & 9 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -274,17 +274,74 @@
}

if $manage_selinux {
selboolean { 'httpd_can_network_relay':
persistent => true,
value => 'on',
# Include puppet/selinux
include selinux
# Set SELinux booleans required for httpd proper functioning
# https://linux.die.net/man/8/httpd_selinux
selinux::boolean {
default:
ensure => 'on',
persistent => true,
;
# allow httpd scripts to connect to network: Puppetboard connects
# to PuppetDB
'httpd_can_network_connect':
;
# allow httpd script to connect to database servers: PuppetDB relies
# on PostgreSQL
'httpd_can_network_connect_db':
;
# allow httpd to be used as a forward/reverse proxy
'httpd_can_network_relay':
;
# enable cgi support
'httpd_enable_cgi':
;
}
selboolean { 'httpd_can_network_connect':
persistent => true,
value => 'on',
# Set context for wsgi and settings
selinux::fcontext {
default:
ensure => present,
notify => Selinux::Exec_restorecon["${basedir}/puppetboard"],
;
"${basedir}/puppetboard/wsgi.py":
seltype => 'httpd_sys_script_exec_t',
;
$settings_file :
require => File[$settings_file],
seltype => 'httpd_sys_content_t',
;
}
selboolean { 'httpd_can_network_connect_db':
persistent => true,
value => 'on',
# Apply changes above
selinux::exec_restorecon { "${basedir}/puppetboard":
notify => Service['httpd'],
}

if $manage_virtualenv {
# Set context for venv files
selinux::fcontext {
default:
ensure => present,
require => Python::Pip['puppetboard'],
notify => Selinux::Exec_restorecon[$virtualenv_dir],
;
"${virtualenv_dir} static files":
seltype => 'httpd_sys_content_t',
pathspec => "${virtualenv_dir}(/.*\\.(cfg|css|html|ico|js|pem|png|svg|ttf|txt|woff|woff2|xml))?",
;
"${virtualenv_dir} METADATA":
seltype => 'httpd_sys_content_t',
pathspec => "${virtualenv_dir}(/.*/METADATA)?",
;
"${virtualenv_dir} executables":
seltype => 'httpd_sys_script_exec_t',
pathspec => "${virtualenv_dir}(/.*\\.(pth|py|pyc|pyi|so))?",
;
}
# Apply changes above
selinux::exec_restorecon { $virtualenv_dir :
notify => Service['httpd'],
}
}
}
}
4 changes: 4 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@
{
"name": "puppet/python",
"version_requirement": ">= 6.3.0 < 8.0.0"
},
{
"name": "puppet/selinux",
"version_requirement": ">= 3.0.0 < 5.0.0"
}
]
}