|
| 1 | +# platform = Oracle Linux 9,Red Hat Enterprise Linux 9,Red Hat Enterprise Linux 10,multi_platform_almalinux,multi_platform_fedora |
| 2 | +# reboot = false |
| 3 | +# strategy = restrict |
| 4 | +# complexity = low |
| 5 | +# disruption = low |
| 6 | + |
| 7 | +# Fix chrony-wait.service to use Unix socket instead of network socket |
| 8 | +# RHEL 9+ version with hardening directives (KCS 7064388) |
| 9 | +- name: "{{{ rule_title }}} - Check if chrony-wait.service exists" |
| 10 | + ansible.builtin.stat: |
| 11 | + path: /usr/lib/systemd/system/chrony-wait.service |
| 12 | + register: chrony_wait_service |
| 13 | + |
| 14 | +- name: "{{{ rule_title }}} - Replace chrony-wait.service to use Unix socket (KCS 7064388)" |
| 15 | + ansible.builtin.copy: |
| 16 | + dest: /etc/systemd/system/chrony-wait.service |
| 17 | + content: | |
| 18 | + [Unit] |
| 19 | + Description=Wait for chrony to synchronize system clock(KCS 7064388) |
| 20 | + Documentation=man:chronyc(1) |
| 21 | + After=chronyd.service |
| 22 | + Requires=chronyd.service |
| 23 | + Before=time-sync.target |
| 24 | + Wants=time-sync.target |
| 25 | +
|
| 26 | + [Service] |
| 27 | + Type=oneshot |
| 28 | + # Wait for chronyd to update the clock and the remaining |
| 29 | + # correction to be less than 0.1 seconds |
| 30 | + ExecStart=/usr/bin/chronyc waitsync 0 0.1 0.0 1 |
| 31 | + # Wait for at most 3 minutes |
| 32 | + TimeoutStartSec=180 |
| 33 | + RemainAfterExit=yes |
| 34 | + StandardOutput=null |
| 35 | +
|
| 36 | + CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE |
| 37 | + CapabilityBoundingSet=~CAP_BLOCK_SUSPEND CAP_KILL CAP_LEASE CAP_LINUX_IMMUTABLE |
| 38 | + CapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE CAP_MKNOD CAP_SYS_ADMIN |
| 39 | + CapabilityBoundingSet=~CAP_SYS_BOOT CAP_SYS_CHROOT CAP_SYS_MODULE CAP_SYS_PACCT |
| 40 | + CapabilityBoundingSet=~CAP_SYS_PTRACE CAP_SYS_RAWIO CAP_SYS_TTY_CONFIG CAP_WAKE_ALARM |
| 41 | + DevicePolicy=closed |
| 42 | + #DynamicUser=yes |
| 43 | + IPAddressAllow=localhost |
| 44 | + IPAddressDeny=any |
| 45 | + LockPersonality=yes |
| 46 | + MemoryDenyWriteExecute=yes |
| 47 | + PrivateDevices=yes |
| 48 | + ProcSubset=pid |
| 49 | + ProtectClock=yes |
| 50 | + ProtectControlGroups=yes |
| 51 | + ProtectHome=yes |
| 52 | + ProtectHostname=yes |
| 53 | + ProtectKernelLogs=yes |
| 54 | + ProtectKernelModules=yes |
| 55 | + ProtectKernelTunables=yes |
| 56 | + ProtectProc=invisible |
| 57 | + ProtectSystem=strict |
| 58 | + RestrictAddressFamilies=AF_UNIX |
| 59 | + RestrictNamespaces=yes |
| 60 | + RestrictRealtime=yes |
| 61 | + SystemCallArchitectures=native |
| 62 | + SystemCallFilter=@system-service |
| 63 | + SystemCallFilter=~@privileged @resources |
| 64 | + UMask=0777 |
| 65 | +
|
| 66 | + [Install] |
| 67 | + WantedBy=multi-user.target |
| 68 | + mode: '0644' |
| 69 | + when: chrony_wait_service.stat.exists |
| 70 | + |
| 71 | +- name: "{{{ rule_title }}} - Reload systemd daemon and enable chrony-wait.service" |
| 72 | + ansible.builtin.systemd: |
| 73 | + name: chrony-wait.service |
| 74 | + daemon_reload: yes |
| 75 | + enabled: yes |
| 76 | + when: chrony_wait_service.stat.exists |
0 commit comments