Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
Display SELinux errors
Browse files Browse the repository at this point in the history
  • Loading branch information
fao89 committed Jul 12, 2021
1 parent 80a84c7 commit 1989426
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES/9007.misc
@@ -0,0 +1 @@
Display SELinux errors even on permissive mode
1 change: 1 addition & 0 deletions roles/pulp_devel/tasks/install_basic_packages.yml
Expand Up @@ -15,6 +15,7 @@
- gnupg
- rubygems
- npm
- rsyslog
state: present
retries: "{{ pulp_devel_package_retries }}"
register: result
Expand Down
28 changes: 28 additions & 0 deletions roles/pulp_devel/tasks/main.yml
Expand Up @@ -69,4 +69,32 @@
src: motd
dest: /etc/motd
become: true

- name: Check SELinux logs
stat:
path: "/var/log/audit/audit.log"
register: selinuxlog

- name: SELinux Analyze
shell: |
set -o pipefail
sealert --analyze=/var/log/audit/audit.log | grep "SELinux is preventing"
args:
# Debian defaults to bourne, but it doesn't understand pipefail.
executable: /bin/bash
changed_when: false
register: selinux_analyze
check_mode: false
become: true
when:
- selinuxlog.stat.exists
- ansible_facts.os_family == "RedHat"

- name: SELinux status
debug:
var: selinux_analyze.stdout_lines
when:
- ansible_facts.os_family == "RedHat"
- selinuxlog.stat.exists
- selinux_analyze.stdout
...
5 changes: 5 additions & 0 deletions roles/pulp_devel/templates/alias.bashrc.j2
Expand Up @@ -149,6 +149,11 @@ pyclean () {
}
_pyclean_help="Cleanup extra python files"

pselinux () {
sealert --analyze=/var/log/audit/audit.log | grep "SELinux is preventing"
}
_pselinux_help="Display SELinux errors"

pbindings(){
CURRENT_DIR=$(pwd)
lang="${2:-python}"
Expand Down
1 change: 1 addition & 0 deletions roles/pulp_devel/vars/CentOS-7.yml
Expand Up @@ -4,3 +4,4 @@ pulp_devel_distro_pkgs:
- python-virtualenvwrapper
- ruby-devel
- jnettop
- setroubleshoot
1 change: 1 addition & 0 deletions roles/pulp_devel/vars/CentOS-8.yml
Expand Up @@ -8,3 +8,4 @@ pulp_devel_distro_pkgs:
- python3-virtualenv-clone
- vim-enhanced
- ruby-devel
- setroubleshoot
1 change: 1 addition & 0 deletions roles/pulp_devel/vars/Fedora-34.yml
Expand Up @@ -12,3 +12,4 @@ pulp_devel_distro_pkgs:
- vim-enhanced
- ruby-devel
- crun
- setroubleshoot
1 change: 1 addition & 0 deletions roles/pulp_devel/vars/Fedora.yml
Expand Up @@ -12,3 +12,4 @@ pulp_devel_distro_pkgs:
- vim-enhanced
- ruby-devel
- jnettop
- setroubleshoot
9 changes: 9 additions & 0 deletions vagrant/playbooks/pre_tasks/selinux-workarounds.yml
Expand Up @@ -15,6 +15,15 @@
- ansible_facts.os_family == 'RedHat'
- ansible_facts.distribution_major_version | int != 7

- name: Install loggers
yum:
name:
- rsyslog
- setroubleshoot
become: true
when:
- ansible_facts.os_family == 'RedHat'

# e.g. `ausearch -m AVC,USER_AVC` to see all SELinux errors,
# rather than having Pulp fail on the 1st SELinux error.
- name: Set SELinux to permissive to facilitate debugging
Expand Down

0 comments on commit 1989426

Please sign in to comment.