Showing with 646 additions and 337 deletions.
  1. +19 −4 .github/CONTRIBUTING.md
  2. +1 −1 .msync.yml
  3. +31 −1 CHANGELOG.md
  4. +1 −0 Gemfile
  5. +5 −15 README.md
  6. +33 −22 REFERENCE.md
  7. +2 −0 data/common.yaml
  8. +2 −0 data/os/Debian.yaml
  9. +6 −0 data/os/Debian/Debian/10.yaml
  10. +3 −0 data/os/RedHat.yaml
  11. +2 −0 data/os/RedHat/Amazon.yaml
  12. +2 −0 data/os/RedHat/CentOS/5.yaml
  13. +2 −0 data/os/RedHat/CentOS/6.yaml
  14. +2 −0 data/os/RedHat/CentOS/7.yaml
  15. +2 −0 data/os/RedHat/OracleLinux/5.yaml
  16. +2 −0 data/os/RedHat/OracleLinux/6.yaml
  17. +2 −0 data/os/RedHat/OracleLinux/7.yaml
  18. +2 −0 data/os/RedHat/RedHat/5.yaml
  19. +2 −0 data/os/RedHat/RedHat/6.yaml
  20. +2 −0 data/os/RedHat/RedHat/7.yaml
  21. +2 −0 data/os/RedHat/Scientific/5.yaml
  22. +2 −0 data/os/RedHat/Scientific/6.yaml
  23. +2 −0 data/os/RedHat/Scientific/7.yaml
  24. +3 −4 examples/fcontext_equals.pp
  25. +6 −0 hiera.yaml
  26. +15 −0 lib/facter/selinux_python_command.rb
  27. +0 −6 lib/facter/selinux_semanage_is_python3.rb
  28. +1 −2 lib/puppet/provider/selinux_port/semanage.rb
  29. +9 −6 manifests/boolean.pp
  30. +1 −1 manifests/build.pp
  31. +19 −9 manifests/config.pp
  32. +12 −9 manifests/fcontext.pp
  33. +1 −1 manifests/fcontext/equivalence.pp
  34. +23 −15 manifests/init.pp
  35. +12 −5 manifests/package.pp
  36. +0 −25 manifests/params.pp
  37. +9 −6 manifests/port.pp
  38. +2 −2 manifests/refpolicy_package.pp
  39. +14 −5 metadata.json
  40. +113 −25 spec/acceptance/class_disabled_spec.rb
  41. +69 −74 spec/acceptance/class_spec.rb
  42. +1 −13 spec/acceptance/selinux_module_refpolicy_spec.rb
  43. +2 −14 spec/acceptance/selinux_permissive_spec.rb
  44. +33 −39 spec/classes/selinux_config_mode_spec.rb
  45. +45 −0 spec/classes/selinux_package_spec.rb
  46. +0 −1 spec/classes/selinux_spec.rb
  47. +62 −22 spec/defines/selinux_boolean_spec.rb
  48. +1 −1 spec/defines/selinux_fcontext_spec.rb
  49. +1 −1 spec/defines/selinux_port_spec.rb
  50. +2 −0 spec/spec_helper.rb
  51. +47 −8 spec/spec_helper_acceptance.rb
  52. +14 −0 test-acceptance-with-vagrant
23 changes: 19 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,34 @@ You can install all needed gems for spec tests into the modules directory by
running:

```sh
bundle install --path .vendor/ --without development system_tests release
bundle install --path .vendor/ --without development system_tests release --jobs "$(nproc)"
```

If you also want to run acceptance tests:

```sh
bundle install --path .vendor/ --with system_tests --without development release
bundle install --path .vendor/ --with system_tests --without development release --jobs "$(nproc)"
```

Our all in one solution if you don't know if you need to install or update gems:

```sh
bundle install --path .vendor/ --with system_tests --without development release; bundle update; bundle clean
bundle install --path .vendor/ --with system_tests --without development release --jobs "$(nproc)"; bundle update; bundle clean
```

As an alternative to the `--jobs "$(nproc)` parameter, you can set an
environment variable:

```sh
BUNDLE_JOBS="$(nproc)"
```

### Note for OS X users

`nproc` isn't a valid command unter OS x. As an alternative, you can do:

```sh
--jobs "$(sysctl -n hw.ncpu)"
```

## Syntax and style
Expand Down Expand Up @@ -160,7 +175,7 @@ created virtual machines will be in `.vagrant/beaker_vagrant_files`.
Beaker also supports docker containers. We also use that in our automated CI
pipeline at [travis-ci](http://travis-ci.org). To use that instead of Vagrant:

```
```sh
PUPPET_INSTALL_TYPE=agent BEAKER_IS_PE=no BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_debug=true BEAKER_setfile=debian9-64{hypervisor=docker} BEAKER_destroy=yes bundle exec rake beaker
```

Expand Down
2 changes: 1 addition & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
modulesync_config_version: '2.7.0'
modulesync_config_version: '2.8.0'
32 changes: 31 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,36 @@ All notable changes to this project will be documented in this file.
Each new release typically also includes the latest modulesync defaults.
These should not affect the functionality of the module.

## [v3.1.0](https://github.com/voxpupuli/puppet-selinux/tree/v3.1.0) (2019-12-09)

[Full Changelog](https://github.com/voxpupuli/puppet-selinux/compare/v3.0.0...v3.1.0)

**Implemented enhancements:**

- RHEL8 [\#293](https://github.com/voxpupuli/puppet-selinux/issues/293)
- add partial support for Debian 10, and supporting changes [\#310](https://github.com/voxpupuli/puppet-selinux/pull/310) ([tequeter](https://github.com/tequeter))
- Avoid puppet errors when SELinux is disabled [\#295](https://github.com/voxpupuli/puppet-selinux/pull/295) ([blackknight36](https://github.com/blackknight36))

**Fixed bugs:**

- "Could not find a suitable provider for selinux\_port" on Fedora 28 [\#254](https://github.com/voxpupuli/puppet-selinux/issues/254)
- Fix selinux\_port on RHEL 8/CentOS 8 [\#298](https://github.com/voxpupuli/puppet-selinux/pull/298) ([oranenj](https://github.com/oranenj))

**Closed issues:**

- No autorelabel when enabling SELinux [\#309](https://github.com/voxpupuli/puppet-selinux/issues/309)
- Just a heads-up - change in RHEL 7.7 [\#299](https://github.com/voxpupuli/puppet-selinux/issues/299)
- Puppet errors on nodes with SELinux disabled [\#286](https://github.com/voxpupuli/puppet-selinux/issues/286)

**Merged pull requests:**

- update example to match current version [\#307](https://github.com/voxpupuli/puppet-selinux/pull/307) ([ubellavance](https://github.com/ubellavance))
- Regenerate REFERENCE.md [\#306](https://github.com/voxpupuli/puppet-selinux/pull/306) ([bastelfreak](https://github.com/bastelfreak))
- Clean up acceptance spec helper [\#305](https://github.com/voxpupuli/puppet-selinux/pull/305) ([ekohl](https://github.com/ekohl))
- Change double quotes to single quotes in example in comments [\#304](https://github.com/voxpupuli/puppet-selinux/pull/304) ([ubellavance](https://github.com/ubellavance))
- fix reference documentation link [\#302](https://github.com/voxpupuli/puppet-selinux/pull/302) ([igalic](https://github.com/igalic))
- Add EL8 and Fedora 30 to the supported OS list [\#294](https://github.com/voxpupuli/puppet-selinux/pull/294) ([blackknight36](https://github.com/blackknight36))

## [v3.0.0](https://github.com/voxpupuli/puppet-selinux/tree/v3.0.0) (2019-06-17)

[Full Changelog](https://github.com/voxpupuli/puppet-selinux/compare/v2.0.0...v3.0.0)
Expand Down Expand Up @@ -414,7 +444,7 @@ These should not affect the functionality of the module.

- Pivot to internal types [\#73](https://github.com/voxpupuli/puppet-selinux/pull/73) ([jyaworski](https://github.com/jyaworski))
- Allow custom package name and management [\#72](https://github.com/voxpupuli/puppet-selinux/pull/72) ([jyaworski](https://github.com/jyaworski))
- Switch default behavior to not manage selinux [\#67](https://github.com/voxpupuli/puppet-selinux/pull/67) ([thrnio](https://github.com/thrnio))
- Switch default behavior to not manage selinux [\#67](https://github.com/voxpupuli/puppet-selinux/pull/67) ([purplexa](https://github.com/purplexa))
- Whitespace lint fixes [\#63](https://github.com/voxpupuli/puppet-selinux/pull/63) ([mld](https://github.com/mld))
- Implements SELinux type checking and ensuring. [\#62](https://github.com/voxpupuli/puppet-selinux/pull/62) ([ElvenSpellmaker](https://github.com/ElvenSpellmaker))
- added hiera support [\#49](https://github.com/voxpupuli/puppet-selinux/pull/49) ([dacron](https://github.com/dacron))
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ group :test do
gem 'puppet-lint-unquoted_string-check', :require => false
gem 'puppet-lint-variable_contains_upcase', :require => false
gem 'puppet-lint-absolute_classname-check', :require => false
gem 'puppet-lint-topscope-variable-check', :require => false
gem 'metadata-json-lint', :require => false
gem 'redcarpet', :require => false
gem 'rubocop', '~> 0.49.1', :require => false
Expand Down
20 changes: 5 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

## Overview

This class manages SELinux on RHEL based systems.
This class manages SELinux.

## Requirements

Expand Down Expand Up @@ -67,21 +67,19 @@ running system.
does) the order is important. If you add /my/folder before /my/folder/subfolder
only /my/folder will match (limitation of SELinux). There is no such limitation
to file-contexts defined in SELinux modules. (GH-121)
* While SELinux is disabled the defined types `selinux::boolean`,
`selinux::fcontext`, `selinux::port` will produce puppet agent runtime errors
because the used tools fail.
* If you try to remove a built-in permissive type, the operation will appear to succeed
but will actually have no effect, making your puppet runs non-idempotent.
* The `selinux_port` provider may misbehave if the title does not correspond to
the format it expects. Users should use the `selinux::port` define instead except
when purging resources
* Defining port ranges that overlap with existing ranges is currently not detected, and will
cause semanage to error when the resource is applied.
* On Debian systems, the defined types fcontext, permissive, and port do not
work because of [PA-2985](https://tickets.puppetlabs.com/browse/PA-2985).

## Usage

Generated puppet strings documentation with examples is available from
https://voxpupuli.org/puppet-selinux/
Generated puppet strings documentation with examples is available in the [REFERENCE.md](./REFERENCE.md)

It's also included in the docs/ folder as simple html pages.

Expand Down Expand Up @@ -157,15 +155,7 @@ selinux::boolean { 'puppetagent_manage_all_files': }
* `semanage` requires `--noreload` while in disabled mode when
adding or changing something
* Only few `--list` operations work
* run acceptance tests:

```
BEAKER_debug=yes BEAKER_set="centos-6-x64" PUPPET_INSTALL_TYPE="agent" bundle exec rake beaker &&
BEAKER_debug=yes BEAKER_set="centos-7-x64" PUPPET_INSTALL_TYPE="agent" bundle exec rake beaker &&
BEAKER_debug=yes BEAKER_set="fedora-25-x64" PUPPET_INSTALL_TYPE="agent" bundle exec rake beaker &&
BEAKER_debug=yes BEAKER_set="fedora-26-x64" PUPPET_INSTALL_TYPE="agent" bundle exec rake beaker &&
BEAKER_debug=yes BEAKER_set="fedora-27-x64" PUPPET_INSTALL_TYPE="agent" bundle exec rake beaker
```
* run acceptance tests: `./test-acceptance-with-vagrant`

### Facter facts

Expand Down
55 changes: 33 additions & 22 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ _Public Classes_
_Private Classes_

* `selinux::build`: Configure the system for module building
* `selinux::config`: Configure the system to use SELinux on the system. It is included in the main class ::selinux
* `selinux::config`: Configure the system to use SELinux on the system.
* `selinux::package`: Manages additional packages required to support some of the functions.
* `selinux::params`: This class provides default parameters for the selinux class
* `selinux::refpolicy_package`: Manages additional packages required to support some of the functions.

**Defined types**
Expand Down Expand Up @@ -55,6 +54,29 @@ class { 'selinux':

The following parameters are available in the `selinux` class.

##### `package_name`

Data type: `Variant[String[1], Array[String[1]]]`

sets the name(s) for the selinux tools package
Default value: OS dependent (see data/).

##### `manage_auditd_package`

Data type: `Boolean`

install auditd to log SELinux violations,
for OSes that do not have auditd installed by default.
Default value: OS dependent (see data/)

##### `refpolicy_package_name`

Data type: `String`

sets the name for the refpolicy development package, required for the
refpolicy module builder
Default value: OS dependent (see data/)

##### `mode`

Data type: `Optional[Enum['enforcing', 'permissive', 'disabled']]`
Expand Down Expand Up @@ -87,32 +109,21 @@ manage the package for selinux tools and refpolicy

Default value: `true`

##### `package_name`

Data type: `String`

sets the name for the selinux tools package
Default value: OS dependent (see params.pp)
##### `auditd_package_name`

Default value: $::selinux::params::package_name
Data type: `String[1]`

##### `refpolicy_package_name`

Data type: `String`

sets the name for the refpolicy development package, required for the
refpolicy module builder
Default value: OS dependent (see params.pp)
used when `manage_auditd_package` is true

Default value: 'selinux-policy-devel'
Default value: 'auditd'

##### `module_build_root`

Data type: `Stdlib::Absolutepath`

directory where modules are built. Defaults to `$vardir/puppet-selinux`

Default value: $::selinux::params::module_build_root
Default value: "${facts['puppet_vardir']}/puppet-selinux"

##### `default_builder`

Expand Down Expand Up @@ -182,15 +193,15 @@ Manage the state of an SELinux boolean.

```puppet
selinux::boolean{ 'named_write_master_zones':
ensure => 'on',
ensure => 'on',
}
```

##### Ensure `named_write_master_zones` boolean is disabled

```puppet
selinux::boolean{ 'named_write_master_zones':
ensure => 'off',
ensure => 'off',
}
```

Expand Down Expand Up @@ -284,8 +295,8 @@ selinux::fcontext::equivalence

```puppet
selinux::fcontext{'set-mysql-log-context':
seltype => "mysqld_log_t",
pathspec => "/u01/log/mysql(/.*)?",
seltype => 'mysqld_log_t',
pathspec => '/u01/log/mysql(/.*)?',
}
```

Expand Down
2 changes: 2 additions & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ lookup_options:
merge: hash
selinux::exec_restorecon:
merge: hash

selinux::refpolicy_package_name: selinux-policy-devel
2 changes: 2 additions & 0 deletions data/os/Debian.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
selinux::manage_auditd_package: true
6 changes: 6 additions & 0 deletions data/os/Debian/Debian/10.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
selinux::package_name:
- policycoreutils-python-utils
- selinux-basics
- selinux-policy-default
selinux::refpolicy_package_name: selinux-policy-dev
3 changes: 3 additions & 0 deletions data/os/RedHat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
selinux::package_name: policycoreutils-python-utils
selinux::manage_auditd_package: false
2 changes: 2 additions & 0 deletions data/os/RedHat/Amazon.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
selinux::package_name: policycoreutils
2 changes: 2 additions & 0 deletions data/os/RedHat/CentOS/5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
selinux::package_name: policycoreutils
2 changes: 2 additions & 0 deletions data/os/RedHat/CentOS/6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
selinux::package_name: policycoreutils-python
2 changes: 2 additions & 0 deletions data/os/RedHat/CentOS/7.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
selinux::package_name: policycoreutils-python
2 changes: 2 additions & 0 deletions data/os/RedHat/OracleLinux/5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
selinux::package_name: policycoreutils
2 changes: 2 additions & 0 deletions data/os/RedHat/OracleLinux/6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
selinux::package_name: policycoreutils-python
2 changes: 2 additions & 0 deletions data/os/RedHat/OracleLinux/7.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
selinux::package_name: policycoreutils-python
2 changes: 2 additions & 0 deletions data/os/RedHat/RedHat/5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
selinux::package_name: policycoreutils
2 changes: 2 additions & 0 deletions data/os/RedHat/RedHat/6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
selinux::package_name: policycoreutils-python
2 changes: 2 additions & 0 deletions data/os/RedHat/RedHat/7.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
selinux::package_name: policycoreutils-python
2 changes: 2 additions & 0 deletions data/os/RedHat/Scientific/5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
selinux::package_name: policycoreutils
2 changes: 2 additions & 0 deletions data/os/RedHat/Scientific/6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
selinux::package_name: policycoreutils-python
2 changes: 2 additions & 0 deletions data/os/RedHat/Scientific/7.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
selinux::package_name: policycoreutils-python
7 changes: 3 additions & 4 deletions examples/fcontext_equals.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
selinux::fcontext{'set-postfix-instance1-spool':
equals => true,
pathname => '/var/spool/postfix-instance1',
destination => '/var/spool/postfix',
selinux::fcontext::equivalence { '/opt/wordpress':
ensure => 'present',
target => '/usr/share/wordpress',
}
6 changes: 6 additions & 0 deletions hiera.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,11 @@
version: 5

hierarchy:
- name: "OS version"
path: "os/%{facts.os.family}/%{facts.os.name}/%{facts.os.release.major}.yaml"
- name: "OS variant"
path: "os/%{facts.os.family}/%{facts.os.name}.yaml"
- name: "OS family"
path: "os/%{facts.os.family}.yaml"
- name: "common"
path: "common.yaml"
15 changes: 15 additions & 0 deletions lib/facter/selinux_python_command.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Facter.add(:selinux_python_command) do
confine osfamily: 'RedHat'
setcode do
if File.exist? '/usr/libexec/platform-python'
# RHEL 8 / CentOS 8
'/usr/libexec/platform-python'
elsif Facter::Core::Execution.execute('rpm -q python3-libsemanage') !~ %r{not installed}
'python3'
else
# This might be python 2 or 3. Keeping it at 'python' matches the module
# worked previously
'python'
end
end
end
6 changes: 0 additions & 6 deletions lib/facter/selinux_semanage_is_python3.rb

This file was deleted.

3 changes: 1 addition & 2 deletions lib/puppet/provider/selinux_port/semanage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
# SELinux must be enabled. Is there a way to get a better error message?
confine selinux: true

# custom fact, needed for fedora 24+
python_command = Facter.value(:selinux_semanage_is_python3) ? 'python3' : 'python'
python_command = Facter.value(:selinux_python_command)
# current file path is lib/puppet/provider/selinux_port/semanage.rb
# semanage_ports.py is lib/puppet_x/voxpupuli/selinux/semanage_ports.py
PORTS_HELPER = File.expand_path('../../../../puppet_x/voxpupuli/selinux/semanage_ports.py', __FILE__)
Expand Down
Loading