Skip to content

Commit c6aa70a

Browse files
author
Ashley Penney
committed
Merge pull request #724 from mhaskel/selinux
SELinux updates.
2 parents 2cc4b5f + 8f03f6c commit c6aa70a

4 files changed

Lines changed: 74 additions & 1 deletion

File tree

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1823,10 +1823,41 @@ The `apache::vhost::WSGIImportScript` parameter creates a statement inside the V
18231823

18241824
###General
18251825

1826-
This module is CI tested on Centos 5 & 6, Ubuntu 12.04, Debian 7, and RHEL 5 & 6 platforms against both the OSS and Enterprise version of Puppet.
1826+
This module is CI tested on Centos 5 & 6, Ubuntu 12.04 & 14.04, Debian 7, and RHEL 5, 6 & 7 platforms against both the OSS and Enterprise version of Puppet.
18271827

18281828
The module contains support for other distributions and operating systems, such as FreeBSD and Amazon Linux, but is not formally tested on those and regressions may occur.
18291829

1830+
###SELinux and Custom Paths
1831+
1832+
If you are running with SELinux in enforcing mode and want to use custom paths for your `logroot`, `mod_dir`, `vhost_dir`, and `docroot`, you will need to manage the context for the files yourself.
1833+
1834+
Something along the lines of:
1835+
1836+
```puppet
1837+
exec { 'set_apache_defaults':
1838+
command => 'semanage fcontext -a -t httpd_sys_content_t "/custom/path(/.*)?"',
1839+
path => '/bin:/usr/bin/:/sbin:/usr/sbin',
1840+
require => Package['policycoreutils-python'],
1841+
}
1842+
package { 'policycoreutils-python': ensure => installed }
1843+
exec { 'restorecon_apache':
1844+
command => 'restorecon -Rv /apache_spec',
1845+
path => '/bin:/usr/bin/:/sbin:/usr/sbin',
1846+
before => Service['httpd'],
1847+
require => Class['apache'],
1848+
}
1849+
class { 'apache': }
1850+
host { 'test.server': ip => '127.0.0.1' }
1851+
file { '/custom/path': ensure => directory, }
1852+
file { '/custom/path/include': ensure => present, content => '#additional_includes' }
1853+
apache::vhost { 'test.server':
1854+
docroot => '/custom/path',
1855+
additional_includes => '/custom/path/include',
1856+
}
1857+
```
1858+
1859+
You need to set the contexts using `semanage fcontext` not `chcon` because `file {...}` resources will reset the context to the values in the database if the resource isn't specifying the context.
1860+
18301861
##Development
18311862

18321863
###Contributing

spec/acceptance/apache_parameters_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,20 @@ class { 'apache':
329329
describe 'setup' do
330330
it 'applies cleanly' do
331331
pp = <<-EOS
332+
if $::osfamily == 'RedHat' and $::operatingsystemmajrelease == '7' {
333+
package { 'policycoreutils-python': ensure => installed }
334+
exec { 'set_apache_defaults':
335+
command => 'semanage fcontext -a -t httpd_log_t "/apache_spec(/.*)?"',
336+
path => '/bin:/usr/bin/:/sbin:/usr/sbin',
337+
require => Package['policycoreutils-python'],
338+
}
339+
exec { 'restorecon_apache':
340+
command => 'restorecon -Rv /apache_spec',
341+
path => '/bin:/usr/bin/:/sbin:/usr/sbin',
342+
before => Service['httpd'],
343+
require => Class['apache'],
344+
}
345+
}
332346
file { '/apache_spec': ensure => directory, }
333347
class { 'apache': logroot => '/apache_spec' }
334348
EOS

spec/acceptance/class_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@ class { 'apache': }
3838
# Using puppet_apply as a helper
3939
it 'should work with no errors' do
4040
pp = <<-EOS
41+
if $::osfamily == 'RedHat' and $::operatingsystemmajrelease == '7' {
42+
package { 'policycoreutils-python': ensure => installed }
43+
exec { 'set_apache_defaults':
44+
command => 'semanage fcontext -a -t httpd_sys_content_t "/apache_spec(/.*)?"',
45+
path => '/bin:/usr/bin/:/sbin:/usr/sbin',
46+
require => Package['policycoreutils-python'],
47+
}
48+
exec { 'restorecon_apache':
49+
command => 'restorecon -Rv /apache_spec',
50+
path => '/bin:/usr/bin/:/sbin:/usr/sbin',
51+
before => Service['httpd'],
52+
require => Class['apache'],
53+
}
54+
}
4155
file { '/apache_spec': ensure => directory, }
4256
file { '/apache_spec/apache_custom': ensure => directory, }
4357
class { 'apache':

spec/acceptance/vhost_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,20 @@ class { 'apache::mod::fastcgi': }
10411041
describe 'additional_includes' do
10421042
it 'applies cleanly' do
10431043
pp = <<-EOS
1044+
if $::osfamily == 'RedHat' and $::operatingsystemmajrelease == '7' {
1045+
exec { 'set_apache_defaults':
1046+
command => 'semanage fcontext -a -t httpd_sys_content_t "/apache_spec(/.*)?"',
1047+
path => '/bin:/usr/bin/:/sbin:/usr/sbin',
1048+
require => Package['policycoreutils-python'],
1049+
}
1050+
package { 'policycoreutils-python': ensure => installed }
1051+
exec { 'restorecon_apache':
1052+
command => 'restorecon -Rv /apache_spec',
1053+
path => '/bin:/usr/bin/:/sbin:/usr/sbin',
1054+
before => Service['httpd'],
1055+
require => Class['apache'],
1056+
}
1057+
}
10441058
class { 'apache': }
10451059
host { 'test.server': ip => '127.0.0.1' }
10461060
file { '/apache_spec': ensure => directory, }

0 commit comments

Comments
 (0)