Do Not Disable Wayland in GDM
Description
GDM runs the login screen and the user sessions on Wayland unless
WaylandEnable is set to false under the
[daemon] section of /etc/gdm/custom.conf. Make sure
that it is not, for example by leaving WaylandEnable unset or by
setting:
[daemon]
WaylandEnable=true
Rationale
Under the X Window System, any client connected to the display can read the
input and the windows of the other clients, so one compromised application
can log keystrokes typed into another. Wayland isolates clients from each
other.
Shell script
The following script can be run on the host to remediate the issue.
#!/bin/bash
# Remediation is applicable only in certain platforms
if rpm --quiet -q gdm; then
if grep -qPi '^\s*WaylandEnable\s*=' "/etc/gdm/custom.conf" 2>/dev/null; then
# Try find '[daemon]' and 'WaylandEnable' in '/etc/gdm/custom.conf', if it exists, set
# to 'true', if it isn't here, add it, if '[daemon]' doesn't exist, add it there
if grep -qzosP '[[:space:]]*\[daemon]([^\n\[]*\n+)+?[[:space:]]*WaylandEnable' '/etc/gdm/custom.conf'; then
sed -i "s/WaylandEnable[^(\n)]*/WaylandEnable=true/" '/etc/gdm/custom.conf'
elif grep -qs '[[:space:]]*\[daemon]' '/etc/gdm/custom.conf'; then
sed -i "/[[:space:]]*\[daemon]/a WaylandEnable=true" '/etc/gdm/custom.conf'
else
if test -d "/etc/gdm"; then
printf '%s\n' '[daemon]' "WaylandEnable=true" >> '/etc/gdm/custom.conf'
else
echo "Config file directory '/etc/gdm' doesnt exist, not remediating, assuming non-applicability." >&2
fi
fi
fi
else
>&2 echo 'Remediation is not applicable, nothing was done'
fi
Ansible playbook
The following playbook can be run with Ansible to remediate the issue.
- name: Gather the package facts
package_facts:
manager: auto
tags:
- CCE-88860-2
- gnome_gdm_enable_wayland
- low_complexity
- medium_disruption
- medium_severity
- no_reboot_needed
- unknown_strategy
- name: Do Not Disable Wayland in GDM - Find WaylandEnable in /etc/gdm/custom.conf
ansible.builtin.lineinfile:
path: /etc/gdm/custom.conf
regexp: ^\s*WaylandEnable\s*=
state: absent
check_mode: true
changed_when: false
failed_when: false
register: gdm_wayland_enable
when: '"gdm" in ansible_facts.packages'
tags:
- CCE-88860-2
- gnome_gdm_enable_wayland
- low_complexity
- medium_disruption
- medium_severity
- no_reboot_needed
- unknown_strategy
- name: Do Not Disable Wayland in GDM - Set WaylandEnable to true
community.general.ini_file:
path: /etc/gdm/custom.conf
section: daemon
option: WaylandEnable
value: 'true'
no_extra_spaces: true
when:
- '"gdm" in ansible_facts.packages'
- gdm_wayland_enable.found is defined and gdm_wayland_enable.found > 0
tags:
- CCE-88860-2
- gnome_gdm_enable_wayland
- low_complexity
- medium_disruption
- medium_severity
- no_reboot_needed
- unknown_strategy