|
|
44eea6 |
From 4995c390a22020454be6625f2bd63c1a04302043 Mon Sep 17 00:00:00 2001
|
|
|
44eea6 |
From: Gabe <redhatrises@gmail.com>
|
|
|
44eea6 |
Date: Fri, 30 Aug 2019 11:15:22 -0600
|
|
|
44eea6 |
Subject: [PATCH 1/5] Remove usage of the SHELL module or get rid of pipe usage
|
|
|
44eea6 |
|
|
|
44eea6 |
---
|
|
|
44eea6 |
.../no_direct_root_logins/ansible/shared.yml | 10 ++++-----
|
|
|
44eea6 |
.../ansible/shared.yml | 22 +++++++++----------
|
|
|
44eea6 |
.../ansible/shared.yml | 4 +---
|
|
|
44eea6 |
.../template_ANSIBLE_service_disabled | 14 +++++++-----
|
|
|
44eea6 |
4 files changed, 25 insertions(+), 25 deletions(-)
|
|
|
44eea6 |
|
|
|
44eea6 |
diff --git a/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_direct_root_logins/ansible/shared.yml b/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_direct_root_logins/ansible/shared.yml
|
|
|
44eea6 |
index 9049733c64..e9a29a24d5 100644
|
|
|
44eea6 |
--- a/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_direct_root_logins/ansible/shared.yml
|
|
|
44eea6 |
+++ b/linux_os/guide/system/accounts/accounts-restrictions/root_logins/no_direct_root_logins/ansible/shared.yml
|
|
|
44eea6 |
@@ -3,13 +3,13 @@
|
|
|
44eea6 |
# strategy = restrict
|
|
|
44eea6 |
# complexity = low
|
|
|
44eea6 |
# disruption = low
|
|
|
44eea6 |
-- name: Test for existence /etc/cron.allow
|
|
|
44eea6 |
+- name: Test for existence of /etc/securetty
|
|
|
44eea6 |
stat:
|
|
|
44eea6 |
path: /etc/securetty
|
|
|
44eea6 |
register: securetty_empty
|
|
|
44eea6 |
|
|
|
44eea6 |
- name: "Direct root Logins Not Allowed"
|
|
|
44eea6 |
- shell: echo > /etc/securetty
|
|
|
44eea6 |
- args:
|
|
|
44eea6 |
- warn: False
|
|
|
44eea6 |
- changed_when: securetty_empty.stat.size > 1
|
|
|
44eea6 |
+ copy:
|
|
|
44eea6 |
+ dest: /etc/securetty
|
|
|
44eea6 |
+ content: ""
|
|
|
44eea6 |
+ when: securetty_empty.stat.size > 1
|
|
|
44eea6 |
diff --git a/linux_os/guide/system/accounts/accounts-session/root_paths/accounts_root_path_dirs_no_write/ansible/shared.yml b/linux_os/guide/system/accounts/accounts-session/root_paths/accounts_root_path_dirs_no_write/ansible/shared.yml
|
|
|
44eea6 |
index 3ec812835f..cee947e8cc 100644
|
|
|
44eea6 |
--- a/linux_os/guide/system/accounts/accounts-session/root_paths/accounts_root_path_dirs_no_write/ansible/shared.yml
|
|
|
44eea6 |
+++ b/linux_os/guide/system/accounts/accounts-session/root_paths/accounts_root_path_dirs_no_write/ansible/shared.yml
|
|
|
44eea6 |
@@ -3,27 +3,27 @@
|
|
|
44eea6 |
# strategy = restrict
|
|
|
44eea6 |
# complexity = low
|
|
|
44eea6 |
# disruption = medium
|
|
|
44eea6 |
-- name: "Fail if user is not root"
|
|
|
44eea6 |
+- name: "Print error message if user is not root"
|
|
|
44eea6 |
fail:
|
|
|
44eea6 |
msg: 'Root account required to read root $PATH'
|
|
|
44eea6 |
when: ansible_user != "root"
|
|
|
44eea6 |
+ ignore_errors: true
|
|
|
44eea6 |
|
|
|
44eea6 |
- name: "Get root paths which are not symbolic links"
|
|
|
44eea6 |
- shell: |
|
|
|
44eea6 |
- set -o pipefail
|
|
|
44eea6 |
- tr ":" "\n" <<< "$PATH" | xargs -I% find % -maxdepth 0 -type d
|
|
|
44eea6 |
- args:
|
|
|
44eea6 |
- warn: False
|
|
|
44eea6 |
- executable: /bin/bash
|
|
|
44eea6 |
+ stat:
|
|
|
44eea6 |
+ path: "{{ item }}"
|
|
|
44eea6 |
changed_when: False
|
|
|
44eea6 |
failed_when: False
|
|
|
44eea6 |
register: root_paths
|
|
|
44eea6 |
+ with_items: "{{ ansible_env.PATH.split(':') }}"
|
|
|
44eea6 |
when: ansible_user == "root"
|
|
|
44eea6 |
- check_mode: no
|
|
|
44eea6 |
|
|
|
44eea6 |
- name: "Disable writability to root directories"
|
|
|
44eea6 |
file:
|
|
|
44eea6 |
- path: "{{ item }}"
|
|
|
44eea6 |
+ path: "{{ item.item }}"
|
|
|
44eea6 |
mode: "g-w,o-w"
|
|
|
44eea6 |
- with_items: "{{ root_paths.stdout_lines }}"
|
|
|
44eea6 |
- when: root_paths.stdout_lines is defined
|
|
|
44eea6 |
+ with_items: "{{ root_paths.results }}"
|
|
|
44eea6 |
+ when:
|
|
|
44eea6 |
+ - root_paths.results is defined
|
|
|
44eea6 |
+ - item.stat.exists
|
|
|
44eea6 |
+ - not item.stat.islnk
|
|
|
44eea6 |
diff --git a/linux_os/guide/system/auditing/auditd_configure_rules/audit_privileged_commands/audit_rules_privileged_commands/ansible/shared.yml b/linux_os/guide/system/auditing/auditd_configure_rules/audit_privileged_commands/audit_rules_privileged_commands/ansible/shared.yml
|
|
|
44eea6 |
index 7f958e0af5..9a8f91020c 100644
|
|
|
44eea6 |
--- a/linux_os/guide/system/auditing/auditd_configure_rules/audit_privileged_commands/audit_rules_privileged_commands/ansible/shared.yml
|
|
|
44eea6 |
+++ b/linux_os/guide/system/auditing/auditd_configure_rules/audit_privileged_commands/audit_rules_privileged_commands/ansible/shared.yml
|
|
|
44eea6 |
@@ -5,9 +5,7 @@
|
|
|
44eea6 |
# disruption = low
|
|
|
44eea6 |
|
|
|
44eea6 |
- name: Search for privileged commands
|
|
|
44eea6 |
- shell: |
|
|
|
44eea6 |
- set -o pipefail
|
|
|
44eea6 |
- find / -xdev -type f -perm -4000 -o -type f -perm -2000 2>/dev/null | cat
|
|
|
44eea6 |
+ shell: find / -xdev -type f -perm -4000 -o -type f -perm -2000 2>/dev/null
|
|
|
44eea6 |
args:
|
|
|
44eea6 |
warn: False
|
|
|
44eea6 |
executable: /bin/bash
|
|
|
44eea6 |
diff --git a/shared/templates/template_ANSIBLE_service_disabled b/shared/templates/template_ANSIBLE_service_disabled
|
|
|
44eea6 |
index 69bf69aaea..07bb8fff0c 100644
|
|
|
44eea6 |
--- a/shared/templates/template_ANSIBLE_service_disabled
|
|
|
44eea6 |
+++ b/shared/templates/template_ANSIBLE_service_disabled
|
|
|
44eea6 |
@@ -4,9 +4,10 @@
|
|
|
44eea6 |
# complexity = low
|
|
|
44eea6 |
# disruption = low
|
|
|
44eea6 |
{{%- if init_system == "systemd" %}}
|
|
|
44eea6 |
-- name: "Unit Service Exists"
|
|
|
44eea6 |
- shell: systemctl list-unit-files | grep -q '^{{{ DAEMONNAME }}}.service'
|
|
|
44eea6 |
+- name: "Unit Service Exists - {{{ DAEMONNAME }}}.service"
|
|
|
44eea6 |
+ command: systemctl list-unit-files {{{ DAEMONNAME }}}.service
|
|
|
44eea6 |
register: service_file_exists
|
|
|
44eea6 |
+ changed_when: False
|
|
|
44eea6 |
ignore_errors: True
|
|
|
44eea6 |
|
|
|
44eea6 |
- name: Disable service {{{ SERVICENAME }}}
|
|
|
44eea6 |
@@ -17,11 +18,12 @@
|
|
|
44eea6 |
{{%- if MASK_SERVICE %}}
|
|
|
44eea6 |
masked: "yes"
|
|
|
44eea6 |
{{%- endif %}}
|
|
|
44eea6 |
- when: service_file_exists.rc == 0
|
|
|
44eea6 |
+ when: '"{{{ DAEMONNAME }}}.service" in service_file_exists.stdout_lines[1]'
|
|
|
44eea6 |
|
|
|
44eea6 |
-- name: "Unit Socket Exists"
|
|
|
44eea6 |
- shell: systemctl list-unit-files | grep -q '^{{{ DAEMONNAME }}}.socket'
|
|
|
44eea6 |
+- name: "Unit Socket Exists - {{{ DAEMONNAME }}}.socket"
|
|
|
44eea6 |
+ command: systemctl list-unit-files {{{ DAEMONNAME }}}.socket
|
|
|
44eea6 |
register: socket_file_exists
|
|
|
44eea6 |
+ changed_when: False
|
|
|
44eea6 |
ignore_errors: True
|
|
|
44eea6 |
|
|
|
44eea6 |
- name: Disable socket {{{ SERVICENAME }}}
|
|
|
44eea6 |
@@ -32,7 +34,7 @@
|
|
|
44eea6 |
{{%- if MASK_SERVICE %}}
|
|
|
44eea6 |
masked: "yes"
|
|
|
44eea6 |
{{%- endif %}}
|
|
|
44eea6 |
- when: socket_file_exists.rc == 0
|
|
|
44eea6 |
+ when: '"{{{ DAEMONNAME }}}.socket" in socket_file_exists.stdout_lines[1]'
|
|
|
44eea6 |
|
|
|
44eea6 |
{{% elif init_system == "upstart" %}}
|
|
|
44eea6 |
- name: Stop {{{ SERVICENAME }}}
|
|
|
44eea6 |
|
|
|
44eea6 |
From e268f1e07192a5cf343b6ac36053553d1074bd3b Mon Sep 17 00:00:00 2001
|
|
|
44eea6 |
From: Gabe <redhatrises@gmail.com>
|
|
|
44eea6 |
Date: Fri, 30 Aug 2019 12:53:40 -0600
|
|
|
44eea6 |
Subject: [PATCH 2/5] Use command and mount module instead of shell
|
|
|
44eea6 |
|
|
|
44eea6 |
- Fixes #4783
|
|
|
44eea6 |
---
|
|
|
44eea6 |
.../ansible/shared.yml | 20 ++++++++-----------
|
|
|
44eea6 |
...te_ANSIBLE_mount_option_remote_filesystems | 19 ++++++++----------
|
|
|
44eea6 |
2 files changed, 16 insertions(+), 23 deletions(-)
|
|
|
44eea6 |
|
|
|
44eea6 |
diff --git a/linux_os/guide/services/nfs_and_rpc/nfs_configuring_clients/mounting_remote_filesystems/mount_option_krb_sec_remote_filesystems/ansible/shared.yml b/linux_os/guide/services/nfs_and_rpc/nfs_configuring_clients/mounting_remote_filesystems/mount_option_krb_sec_remote_filesystems/ansible/shared.yml
|
|
|
44eea6 |
index 506c3dee31..6982ce293e 100644
|
|
|
44eea6 |
--- a/linux_os/guide/services/nfs_and_rpc/nfs_configuring_clients/mounting_remote_filesystems/mount_option_krb_sec_remote_filesystems/ansible/shared.yml
|
|
|
44eea6 |
+++ b/linux_os/guide/services/nfs_and_rpc/nfs_configuring_clients/mounting_remote_filesystems/mount_option_krb_sec_remote_filesystems/ansible/shared.yml
|
|
|
44eea6 |
@@ -5,20 +5,16 @@
|
|
|
44eea6 |
# disruption = medium
|
|
|
44eea6 |
|
|
|
44eea6 |
- name: "Get nfs and nfs4 mount points, that don't have Kerberos security option"
|
|
|
44eea6 |
- shell: |
|
|
|
44eea6 |
- set -o pipefail
|
|
|
44eea6 |
- grep -E "[[:space:]]nfs[4]?[[:space:]]" /etc/fstab | grep -v "sec=krb5:krb5i:krb5p" | awk '{print $2}'
|
|
|
44eea6 |
- args:
|
|
|
44eea6 |
- warn: False
|
|
|
44eea6 |
- executable: /bin/bash
|
|
|
44eea6 |
+ command: findmnt --fstab --types nfs,nfs4 -O nosec=krb5:krb5i:krb5p -n -o TARGET
|
|
|
44eea6 |
register: points_register
|
|
|
44eea6 |
check_mode: no
|
|
|
44eea6 |
changed_when: False
|
|
|
44eea6 |
|
|
|
44eea6 |
-- name: "Add Kerberos security to mount points"
|
|
|
44eea6 |
- shell: awk '$2=="{{ item }}"{$4=$4",sec=krb5:krb5i:krb5p"}1' /etc/fstab > fstab.tmp && mv fstab.tmp /etc/fstab
|
|
|
44eea6 |
- args:
|
|
|
44eea6 |
- warn: False
|
|
|
44eea6 |
- with_items:
|
|
|
44eea6 |
- - "{{ points_register.stdout_lines }}"
|
|
|
44eea6 |
+- name: "Add Kerberos security to nfs and nfs4 mount points"
|
|
|
44eea6 |
+ mount:
|
|
|
44eea6 |
+ path: "{{ item.split()[0] }}"
|
|
|
44eea6 |
+ src: "{{ item.split()[1] }}"
|
|
|
44eea6 |
+ fstype: "{{ item.split()[2] }}"
|
|
|
44eea6 |
+ state: mounted
|
|
|
44eea6 |
+ opts: "{{ item.split()[3] }},sec=krb5:krb5i:krb5p"
|
|
|
44eea6 |
when: (points_register.stdout | length > 0)
|
|
|
44eea6 |
diff --git a/shared/templates/template_ANSIBLE_mount_option_remote_filesystems b/shared/templates/template_ANSIBLE_mount_option_remote_filesystems
|
|
|
44eea6 |
index f89c1d7285..f3d6f02d82 100644
|
|
|
44eea6 |
--- a/shared/templates/template_ANSIBLE_mount_option_remote_filesystems
|
|
|
44eea6 |
+++ b/shared/templates/template_ANSIBLE_mount_option_remote_filesystems
|
|
|
44eea6 |
@@ -5,19 +5,16 @@
|
|
|
44eea6 |
# disruption = medium
|
|
|
44eea6 |
|
|
|
44eea6 |
- name: "Get nfs and nfs4 mount points, that don't have {{{ MOUNTOPTION }}}"
|
|
|
44eea6 |
- shell: |
|
|
|
44eea6 |
- set -o pipefail
|
|
|
44eea6 |
- grep -E "[[:space:]]nfs[4]?[[:space:]]" /etc/fstab | grep -v "{{{ MOUNTOPTION }}}" | awk '{print $2}'
|
|
|
44eea6 |
- args:
|
|
|
44eea6 |
- executable: /bin/bash
|
|
|
44eea6 |
+ command: findmnt --fstab --types nfs,nfs4 -O no{{{ MOUNTOPTION }} -n
|
|
|
44eea6 |
register: points_register
|
|
|
44eea6 |
check_mode: no
|
|
|
44eea6 |
changed_when: False
|
|
|
44eea6 |
|
|
|
44eea6 |
-- name: "Add {{{ MOUNTOPTION }}} to mount points"
|
|
|
44eea6 |
- shell: awk '$2=="{{ item }}"{$4=$4",{{{ MOUNTOPTION }}}"}1' /etc/fstab > fstab.tmp && mv fstab.tmp /etc/fstab
|
|
|
44eea6 |
- args:
|
|
|
44eea6 |
- executable: /bin/bash
|
|
|
44eea6 |
- with_items:
|
|
|
44eea6 |
- - "{{ points_register.stdout_lines }}"
|
|
|
44eea6 |
+- name: "Add {{{ MOUNTOPTION }}} to nfs and nfs4 mount points"
|
|
|
44eea6 |
+ mount:
|
|
|
44eea6 |
+ path: "{{ item.split()[0] }}"
|
|
|
44eea6 |
+ src: "{{ item.split()[1] }}"
|
|
|
44eea6 |
+ fstype: "{{ item.split()[2] }}"
|
|
|
44eea6 |
+ state: mounted
|
|
|
44eea6 |
+ opts: "{{ item.split()[3] }},{{{ MOUNTOPTION }}}"
|
|
|
44eea6 |
when: (points_register.stdout | length > 0)
|
|
|
44eea6 |
|
|
|
44eea6 |
From 189a8962ddfc35a516eb468f7df1b66a55d874a6 Mon Sep 17 00:00:00 2001
|
|
|
44eea6 |
From: Gabe <redhatrises@gmail.com>
|
|
|
44eea6 |
Date: Fri, 30 Aug 2019 15:18:02 -0600
|
|
|
44eea6 |
Subject: [PATCH 3/5] Remove usage of shell module in gpgkey install Ansible
|
|
|
44eea6 |
snippet
|
|
|
44eea6 |
|
|
|
44eea6 |
---
|
|
|
44eea6 |
.../ansible/shared.yml | 18 +++++++++---------
|
|
|
44eea6 |
...ate_ANSIBLE_mount_option_remote_filesystems | 2 +-
|
|
|
44eea6 |
2 files changed, 10 insertions(+), 10 deletions(-)
|
|
|
44eea6 |
|
|
|
44eea6 |
diff --git a/linux_os/guide/system/software/updating/ensure_redhat_gpgkey_installed/ansible/shared.yml b/linux_os/guide/system/software/updating/ensure_redhat_gpgkey_installed/ansible/shared.yml
|
|
|
44eea6 |
index 079020f8cd..91a98640ad 100644
|
|
|
44eea6 |
--- a/linux_os/guide/system/software/updating/ensure_redhat_gpgkey_installed/ansible/shared.yml
|
|
|
44eea6 |
+++ b/linux_os/guide/system/software/updating/ensure_redhat_gpgkey_installed/ansible/shared.yml
|
|
|
44eea6 |
@@ -14,13 +14,9 @@
|
|
|
44eea6 |
- name: Read signatures in GPG key
|
|
|
44eea6 |
# According to /usr/share/doc/gnupg2/DETAILS fingerprints are in "fpr" record in field 10
|
|
|
44eea6 |
{{% if product == "rhel8" -%}}
|
|
|
44eea6 |
- shell: |
|
|
|
44eea6 |
- set -o pipefail
|
|
|
44eea6 |
- gpg --show-keys --with-fingerprint --with-colons "/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release" | grep -A1 "^pub" | grep "^fpr" | cut -d ":" -f 10
|
|
|
44eea6 |
+ command: gpg --show-keys --with-fingerprint --with-colons "/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release"
|
|
|
44eea6 |
{{%- else -%}}
|
|
|
44eea6 |
- shell: |
|
|
|
44eea6 |
- set -o pipefail
|
|
|
44eea6 |
- gpg --with-fingerprint --with-colons "/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release" | grep "^fpr" | cut -d ":" -f 10
|
|
|
44eea6 |
+ command: gpg --with-fingerprint --with-colons "/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release"
|
|
|
44eea6 |
{{%- endif %}}
|
|
|
44eea6 |
args:
|
|
|
44eea6 |
warn: False
|
|
|
44eea6 |
@@ -29,9 +25,13 @@
|
|
|
44eea6 |
register: gpg_fingerprints
|
|
|
44eea6 |
check_mode: no
|
|
|
44eea6 |
|
|
|
44eea6 |
+- name: Set Fact - Installed GPG Fingerprints
|
|
|
44eea6 |
+ set_fact:
|
|
|
44eea6 |
+ gpg_installed_fingerprints: "{{ gpg_fingerprints.stdout | regex_findall('^pub.*\n(?:^fpr[:]*)([0-9A-Fa-f]*)', '\\1') | list }}"
|
|
|
44eea6 |
+
|
|
|
44eea6 |
- name: Set Fact - Valid fingerprints
|
|
|
44eea6 |
set_fact:
|
|
|
44eea6 |
- gpg_valid_fingerprints: ("{{{ release_key_fingerprint }}}" "{{{ auxiliary_key_fingerprint }}}")
|
|
|
44eea6 |
+ gpg_valid_fingerprints: ("{{{ release_key_fingerprint }}}" "{{{ auxiliary_key_fingerprint }}}")
|
|
|
44eea6 |
|
|
|
44eea6 |
- name: Import RedHat GPG key
|
|
|
44eea6 |
rpm_key:
|
|
|
44eea6 |
@@ -39,6 +39,6 @@
|
|
|
44eea6 |
key: /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
|
|
|
44eea6 |
when:
|
|
|
44eea6 |
- gpg_key_directory_permission.stat.mode <= '0755'
|
|
|
44eea6 |
- - ( gpg_fingerprints.stdout_lines | difference(gpg_valid_fingerprints)) | length == 0
|
|
|
44eea6 |
- - gpg_fingerprints.stdout_lines | length > 0
|
|
|
44eea6 |
+ - (gpg_installed_fingerprints | difference(gpg_valid_fingerprints)) | length == 0
|
|
|
44eea6 |
+ - gpg_installed_fingerprints | length > 0
|
|
|
44eea6 |
- ansible_distribution == "RedHat"
|
|
|
44eea6 |
diff --git a/shared/templates/template_ANSIBLE_mount_option_remote_filesystems b/shared/templates/template_ANSIBLE_mount_option_remote_filesystems
|
|
|
44eea6 |
index f3d6f02d82..a58d7729ec 100644
|
|
|
44eea6 |
--- a/shared/templates/template_ANSIBLE_mount_option_remote_filesystems
|
|
|
44eea6 |
+++ b/shared/templates/template_ANSIBLE_mount_option_remote_filesystems
|
|
|
44eea6 |
@@ -5,7 +5,7 @@
|
|
|
44eea6 |
# disruption = medium
|
|
|
44eea6 |
|
|
|
44eea6 |
- name: "Get nfs and nfs4 mount points, that don't have {{{ MOUNTOPTION }}}"
|
|
|
44eea6 |
- command: findmnt --fstab --types nfs,nfs4 -O no{{{ MOUNTOPTION }} -n
|
|
|
44eea6 |
+ command: findmnt --fstab --types nfs,nfs4 -O no{{{ MOUNTOPTION }}} -n
|
|
|
44eea6 |
register: points_register
|
|
|
44eea6 |
check_mode: no
|
|
|
44eea6 |
changed_when: False
|
|
|
44eea6 |
|
|
|
44eea6 |
From 047c5d342860745dcc2f80a9f00d30cf25e76348 Mon Sep 17 00:00:00 2001
|
|
|
44eea6 |
From: Gabe <redhatrises@gmail.com>
|
|
|
44eea6 |
Date: Tue, 3 Sep 2019 14:18:54 -0600
|
|
|
44eea6 |
Subject: [PATCH 4/5] Remove shell module usage for rpm verification tasks
|
|
|
44eea6 |
|
|
|
44eea6 |
- Fixes #4617
|
|
|
44eea6 |
---
|
|
|
44eea6 |
.../rpm_verify_hashes/ansible/shared.yml | 27 ++++++++++++-------
|
|
|
44eea6 |
.../rpm_verify_ownership/ansible/shared.yml | 11 +++-----
|
|
|
44eea6 |
.../rpm_verify_permissions/ansible/shared.yml | 19 ++++++++-----
|
|
|
44eea6 |
3 files changed, 34 insertions(+), 23 deletions(-)
|
|
|
44eea6 |
|
|
|
44eea6 |
diff --git a/linux_os/guide/system/software/integrity/software-integrity/rpm_verification/rpm_verify_hashes/ansible/shared.yml b/linux_os/guide/system/software/integrity/software-integrity/rpm_verification/rpm_verify_hashes/ansible/shared.yml
|
|
|
44eea6 |
index 2a38e43c3b..1ba29992ab 100644
|
|
|
44eea6 |
--- a/linux_os/guide/system/software/integrity/software-integrity/rpm_verification/rpm_verify_hashes/ansible/shared.yml
|
|
|
44eea6 |
+++ b/linux_os/guide/system/software/integrity/software-integrity/rpm_verification/rpm_verify_hashes/ansible/shared.yml
|
|
|
44eea6 |
@@ -1,6 +1,6 @@
|
|
|
44eea6 |
# platform = multi_platform_rhel,multi_platform_fedora,multi_platform_ol,multi_platform_rhv
|
|
|
44eea6 |
# reboot = false
|
|
|
44eea6 |
-# strategy = unknown
|
|
|
44eea6 |
+# strategy = restrict
|
|
|
44eea6 |
# complexity = high
|
|
|
44eea6 |
# disruption = medium
|
|
|
44eea6 |
- name: "Set fact: Package manager reinstall command (dnf)"
|
|
|
44eea6 |
@@ -14,21 +14,30 @@
|
|
|
44eea6 |
when: (ansible_distribution == "RedHat" or ansible_distribution == "OracleLinux")
|
|
|
44eea6 |
|
|
|
44eea6 |
- name: "Read files with incorrect hash"
|
|
|
44eea6 |
- shell: |
|
|
|
44eea6 |
- set -o pipefail
|
|
|
44eea6 |
- rpm -Va | grep -E '^..5.* /(bin|sbin|lib|lib64|usr)/' | awk '{print $NF}'
|
|
|
44eea6 |
+ command: rpm -Va --nodeps --nosize --nomtime --nordev --nocaps --nolinkto --nouser --nogroup --nomode --noconfig --noghost
|
|
|
44eea6 |
args:
|
|
|
44eea6 |
warn: False # Ignore ANSIBLE0006, we can't fetch files with incorrect hash using rpm module
|
|
|
44eea6 |
- executable: /bin/bash
|
|
|
44eea6 |
register: files_with_incorrect_hash
|
|
|
44eea6 |
changed_when: False
|
|
|
44eea6 |
failed_when: files_with_incorrect_hash.rc > 1
|
|
|
44eea6 |
when: (package_manager_reinstall_cmd is defined)
|
|
|
44eea6 |
- check_mode: no
|
|
|
44eea6 |
+
|
|
|
44eea6 |
+- name: Create list of packages
|
|
|
44eea6 |
+ command: rpm -qf "{{ item }}"
|
|
|
44eea6 |
+ args:
|
|
|
44eea6 |
+ warn: False # Ignore ANSIBLE0006, we can't fetch packages with files with incorrect hash using rpm module
|
|
|
44eea6 |
+ with_items: "{{ files_with_incorrect_hash.stdout_lines | map('regex_findall', '^[.]+[5]+.* (\/.*)', '\\1') | map('join') | select('match', '(\/.*)') | list | unique }}"
|
|
|
44eea6 |
+ register: list_of_packages
|
|
|
44eea6 |
+ changed_when: False
|
|
|
44eea6 |
+ when:
|
|
|
44eea6 |
+ - files_with_incorrect_hash.stdout_lines is defined
|
|
|
44eea6 |
+ - (files_with_incorrect_hash.stdout_lines | length > 0)
|
|
|
44eea6 |
|
|
|
44eea6 |
- name: "Reinstall packages of files with incorrect hash"
|
|
|
44eea6 |
- shell: "{{ package_manager_reinstall_cmd }} $(rpm -qf '{{ item }}')"
|
|
|
44eea6 |
+ command: "{{ package_manager_reinstall_cmd }} '{{ item }}'"
|
|
|
44eea6 |
args:
|
|
|
44eea6 |
warn: False # Ignore ANSIBLE0006, this task is flexible with regards to package manager
|
|
|
44eea6 |
- with_items: "{{ files_with_incorrect_hash.stdout_lines }}"
|
|
|
44eea6 |
- when: (package_manager_reinstall_cmd is defined and (files_with_incorrect_hash.stdout_lines | length > 0))
|
|
|
44eea6 |
+ with_items: "{{ list_of_packages.results | map(attribute='stdout_lines') | list | unique }}"
|
|
|
44eea6 |
+ when:
|
|
|
44eea6 |
+ - files_with_incorrect_hash.stdout_lines is defined
|
|
|
44eea6 |
+ - (package_manager_reinstall_cmd is defined and (files_with_incorrect_hash.stdout_lines | length > 0))
|
|
|
44eea6 |
diff --git a/linux_os/guide/system/software/integrity/software-integrity/rpm_verification/rpm_verify_ownership/ansible/shared.yml b/linux_os/guide/system/software/integrity/software-integrity/rpm_verification/rpm_verify_ownership/ansible/shared.yml
|
|
|
44eea6 |
index 9fd07f8da2..1d9720cb82 100644
|
|
|
44eea6 |
--- a/linux_os/guide/system/software/integrity/software-integrity/rpm_verification/rpm_verify_ownership/ansible/shared.yml
|
|
|
44eea6 |
+++ b/linux_os/guide/system/software/integrity/software-integrity/rpm_verification/rpm_verify_ownership/ansible/shared.yml
|
|
|
44eea6 |
@@ -4,27 +4,24 @@
|
|
|
44eea6 |
# complexity = high
|
|
|
44eea6 |
# disruption = medium
|
|
|
44eea6 |
- name: "Read list of files with incorrect ownership"
|
|
|
44eea6 |
- shell: |
|
|
|
44eea6 |
- set -o pipefail
|
|
|
44eea6 |
- rpm -Va --nofiledigest | awk '{ if (substr($0,6,1)=="U" || substr($0,7,1)=="G") print $NF }'
|
|
|
44eea6 |
+ command: rpm -Va --nodeps --nosignature --nofiledigest --nosize --nomtime --nordev --nocaps --nolinkto --nomode
|
|
|
44eea6 |
args:
|
|
|
44eea6 |
warn: False # Ignore ANSIBLE0006, we can't fetch files with incorrect ownership using rpm module
|
|
|
44eea6 |
- executable: /bin/bash
|
|
|
44eea6 |
register: files_with_incorrect_ownership
|
|
|
44eea6 |
failed_when: files_with_incorrect_ownership.rc > 1
|
|
|
44eea6 |
changed_when: False
|
|
|
44eea6 |
- check_mode: no
|
|
|
44eea6 |
|
|
|
44eea6 |
- name: Create list of packages
|
|
|
44eea6 |
command: rpm -qf "{{ item }}"
|
|
|
44eea6 |
args:
|
|
|
44eea6 |
warn: False # Ignore ANSIBLE0006, we can't fetch packages with files with incorrect ownership using rpm module
|
|
|
44eea6 |
- with_items: "{{ files_with_incorrect_ownership.stdout_lines | unique }}"
|
|
|
44eea6 |
+ with_items: "{{ files_with_incorrect_ownership.stdout_lines | map('regex_findall', '^[.]+[U|G]+.* (\/.*)', '\\1') | map('join') | select('match', '(\/.*)') | list | unique }}"
|
|
|
44eea6 |
register: list_of_packages
|
|
|
44eea6 |
+ changed_when: False
|
|
|
44eea6 |
when: (files_with_incorrect_ownership.stdout_lines | length > 0)
|
|
|
44eea6 |
|
|
|
44eea6 |
- name: "Correct file ownership with RPM"
|
|
|
44eea6 |
- command: "rpm --quiet --setugids '{{ item }}'"
|
|
|
44eea6 |
+ command: "rpm --setperms '{{ item }}'"
|
|
|
44eea6 |
args:
|
|
|
44eea6 |
warn: False # Ignore ANSIBLE0006, we can't correct ownership using rpm module
|
|
|
44eea6 |
with_items: "{{ list_of_packages.results | map(attribute='stdout_lines') | list | unique }}"
|
|
|
44eea6 |
diff --git a/linux_os/guide/system/software/integrity/software-integrity/rpm_verification/rpm_verify_permissions/ansible/shared.yml b/linux_os/guide/system/software/integrity/software-integrity/rpm_verification/rpm_verify_permissions/ansible/shared.yml
|
|
|
44eea6 |
index a22f03a987..149dbf9fb7 100644
|
|
|
44eea6 |
--- a/linux_os/guide/system/software/integrity/software-integrity/rpm_verification/rpm_verify_permissions/ansible/shared.yml
|
|
|
44eea6 |
+++ b/linux_os/guide/system/software/integrity/software-integrity/rpm_verification/rpm_verify_permissions/ansible/shared.yml
|
|
|
44eea6 |
@@ -4,20 +4,25 @@
|
|
|
44eea6 |
# complexity = high
|
|
|
44eea6 |
# disruption = medium
|
|
|
44eea6 |
- name: "Read list of files with incorrect permissions"
|
|
|
44eea6 |
- shell: |
|
|
|
44eea6 |
- set -o pipefail
|
|
|
44eea6 |
- rpm -Va --nofiledigest | awk '{ if (substr($0,2,1)=="M") print $NF }'
|
|
|
44eea6 |
+ command: rpm -Va --nodeps --nosignature --nofiledigest --nosize --nomtime --nordev --nocaps --nolinkto --nouser --nogroup
|
|
|
44eea6 |
args:
|
|
|
44eea6 |
warn: False # Ignore ANSIBLE0006, we can't fetch files with incorrect permissions using rpm module
|
|
|
44eea6 |
- executable: /bin/bash
|
|
|
44eea6 |
register: files_with_incorrect_permissions
|
|
|
44eea6 |
failed_when: files_with_incorrect_permissions.rc > 1
|
|
|
44eea6 |
changed_when: False
|
|
|
44eea6 |
- check_mode: no
|
|
|
44eea6 |
+
|
|
|
44eea6 |
+- name: Create list of packages
|
|
|
44eea6 |
+ command: rpm -qf "{{ item }}"
|
|
|
44eea6 |
+ args:
|
|
|
44eea6 |
+ warn: False # Ignore ANSIBLE0006, we can't fetch packages with files with incorrect permissions using rpm module
|
|
|
44eea6 |
+ with_items: "{{ files_with_incorrect_permissions.stdout_lines | map('regex_findall', '^[.]+[M]+.* (\/.*)', '\\1') | map('join') | select('match', '(\/.*)') | list | unique }}"
|
|
|
44eea6 |
+ register: list_of_packages
|
|
|
44eea6 |
+ changed_when: False
|
|
|
44eea6 |
+ when: (files_with_incorrect_permissions.stdout_lines | length > 0)
|
|
|
44eea6 |
|
|
|
44eea6 |
- name: "Correct file permissions with RPM"
|
|
|
44eea6 |
- shell: "rpm --setperms $(rpm -qf '{{ item }}')"
|
|
|
44eea6 |
+ command: "rpm --setperms '{{ item }}'"
|
|
|
44eea6 |
args:
|
|
|
44eea6 |
warn: False # Ignore ANSIBLE0006, we can't correct permissions using rpm module
|
|
|
44eea6 |
- with_items: "{{ files_with_incorrect_permissions.stdout_lines }}"
|
|
|
44eea6 |
+ with_items: "{{ list_of_packages.results | map(attribute='stdout_lines') | list | unique }}"
|
|
|
44eea6 |
when: (files_with_incorrect_permissions.stdout_lines | length > 0)
|
|
|
44eea6 |
|
|
|
44eea6 |
From 83d241dceafb1b8d8829655b0cdeb44af1b01d2a Mon Sep 17 00:00:00 2001
|
|
|
44eea6 |
From: Gabe <redhatrises@gmail.com>
|
|
|
44eea6 |
Date: Fri, 6 Sep 2019 11:55:18 -0600
|
|
|
44eea6 |
Subject: [PATCH 5/5] Fix regex and escape correctly
|
|
|
44eea6 |
|
|
|
44eea6 |
---
|
|
|
44eea6 |
.../rpm_verification/rpm_verify_hashes/ansible/shared.yml | 2 +-
|
|
|
44eea6 |
.../rpm_verification/rpm_verify_ownership/ansible/shared.yml | 4 ++--
|
|
|
44eea6 |
.../rpm_verify_permissions/ansible/shared.yml | 2 +-
|
|
|
44eea6 |
3 files changed, 4 insertions(+), 4 deletions(-)
|
|
|
44eea6 |
|
|
|
44eea6 |
diff --git a/linux_os/guide/system/software/integrity/software-integrity/rpm_verification/rpm_verify_hashes/ansible/shared.yml b/linux_os/guide/system/software/integrity/software-integrity/rpm_verification/rpm_verify_hashes/ansible/shared.yml
|
|
|
44eea6 |
index 1ba29992ab..0dc09339f4 100644
|
|
|
44eea6 |
--- a/linux_os/guide/system/software/integrity/software-integrity/rpm_verification/rpm_verify_hashes/ansible/shared.yml
|
|
|
44eea6 |
+++ b/linux_os/guide/system/software/integrity/software-integrity/rpm_verification/rpm_verify_hashes/ansible/shared.yml
|
|
|
44eea6 |
@@ -26,7 +26,7 @@
|
|
|
44eea6 |
command: rpm -qf "{{ item }}"
|
|
|
44eea6 |
args:
|
|
|
44eea6 |
warn: False # Ignore ANSIBLE0006, we can't fetch packages with files with incorrect hash using rpm module
|
|
|
44eea6 |
- with_items: "{{ files_with_incorrect_hash.stdout_lines | map('regex_findall', '^[.]+[5]+.* (\/.*)', '\\1') | map('join') | select('match', '(\/.*)') | list | unique }}"
|
|
|
44eea6 |
+ with_items: "{{ files_with_incorrect_hash.stdout_lines | map('regex_findall', '^[.]+[5]+.* (\\/.*)', '\\1') | map('join') | select('match', '(\\/.*)') | list | unique }}"
|
|
|
44eea6 |
register: list_of_packages
|
|
|
44eea6 |
changed_when: False
|
|
|
44eea6 |
when:
|
|
|
44eea6 |
diff --git a/linux_os/guide/system/software/integrity/software-integrity/rpm_verification/rpm_verify_ownership/ansible/shared.yml b/linux_os/guide/system/software/integrity/software-integrity/rpm_verification/rpm_verify_ownership/ansible/shared.yml
|
|
|
44eea6 |
index 1d9720cb82..d02508808c 100644
|
|
|
44eea6 |
--- a/linux_os/guide/system/software/integrity/software-integrity/rpm_verification/rpm_verify_ownership/ansible/shared.yml
|
|
|
44eea6 |
+++ b/linux_os/guide/system/software/integrity/software-integrity/rpm_verification/rpm_verify_ownership/ansible/shared.yml
|
|
|
44eea6 |
@@ -15,13 +15,13 @@
|
|
|
44eea6 |
command: rpm -qf "{{ item }}"
|
|
|
44eea6 |
args:
|
|
|
44eea6 |
warn: False # Ignore ANSIBLE0006, we can't fetch packages with files with incorrect ownership using rpm module
|
|
|
44eea6 |
- with_items: "{{ files_with_incorrect_ownership.stdout_lines | map('regex_findall', '^[.]+[U|G]+.* (\/.*)', '\\1') | map('join') | select('match', '(\/.*)') | list | unique }}"
|
|
|
44eea6 |
+ with_items: "{{ files_with_incorrect_ownership.stdout_lines | map('regex_findall', '^[.]+[U|G]+.* (\\/.*)', '\\1') | map('join') | select('match', '(\\/.*)') | list | unique }}"
|
|
|
44eea6 |
register: list_of_packages
|
|
|
44eea6 |
changed_when: False
|
|
|
44eea6 |
when: (files_with_incorrect_ownership.stdout_lines | length > 0)
|
|
|
44eea6 |
|
|
|
44eea6 |
- name: "Correct file ownership with RPM"
|
|
|
44eea6 |
- command: "rpm --setperms '{{ item }}'"
|
|
|
44eea6 |
+ command: "rpm --quiet --setugids '{{ item }}'"
|
|
|
44eea6 |
args:
|
|
|
44eea6 |
warn: False # Ignore ANSIBLE0006, we can't correct ownership using rpm module
|
|
|
44eea6 |
with_items: "{{ list_of_packages.results | map(attribute='stdout_lines') | list | unique }}"
|
|
|
44eea6 |
diff --git a/linux_os/guide/system/software/integrity/software-integrity/rpm_verification/rpm_verify_permissions/ansible/shared.yml b/linux_os/guide/system/software/integrity/software-integrity/rpm_verification/rpm_verify_permissions/ansible/shared.yml
|
|
|
44eea6 |
index 149dbf9fb7..55a37a4235 100644
|
|
|
44eea6 |
--- a/linux_os/guide/system/software/integrity/software-integrity/rpm_verification/rpm_verify_permissions/ansible/shared.yml
|
|
|
44eea6 |
+++ b/linux_os/guide/system/software/integrity/software-integrity/rpm_verification/rpm_verify_permissions/ansible/shared.yml
|
|
|
44eea6 |
@@ -15,7 +15,7 @@
|
|
|
44eea6 |
command: rpm -qf "{{ item }}"
|
|
|
44eea6 |
args:
|
|
|
44eea6 |
warn: False # Ignore ANSIBLE0006, we can't fetch packages with files with incorrect permissions using rpm module
|
|
|
44eea6 |
- with_items: "{{ files_with_incorrect_permissions.stdout_lines | map('regex_findall', '^[.]+[M]+.* (\/.*)', '\\1') | map('join') | select('match', '(\/.*)') | list | unique }}"
|
|
|
44eea6 |
+ with_items: "{{ files_with_incorrect_permissions.stdout_lines | map('regex_findall', '^[.]+[M]+.* (\\/.*)', '\\1') | map('join') | select('match', '(\\/.*)') | list | unique }}"
|
|
|
44eea6 |
register: list_of_packages
|
|
|
44eea6 |
changed_when: False
|
|
|
44eea6 |
when: (files_with_incorrect_permissions.stdout_lines | length > 0)
|