Puppet Class: cis_security_hardening::rules::single_user_mode
- Defined in:
- manifests/rules/single_user_mode.pp
Summary
Ensure authentication required for single user modeOverview
Single user mode (rescue mode) is used for recovery when the system detects an issue during boot or by manual selection from the bootloader.
Rationale: Requiring authentication in single user mode (rescue mode) prevents an unauthorized user from rebooting the system into single user to gain root privileges without credentials.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'manifests/rules/single_user_mode.pp', line 20
class cis_security_hardening::rules::single_user_mode (
Boolean $enforce = false,
) {
if $enforce {
case $facts['os']['family'].downcase() {
'redhat': {
case $facts['os']['release']['major'] {
'9': {
# nothing to do
}
'8': {
file_line { 'su-rescue':
path => '/usr/lib/systemd/system/rescue.service',
line => 'ExecStart=-/usr/lib/systemd/systemd-sulogin-shell rescue',
match => '^ExecStart=',
}
file_line { 'su-emergency':
path => '/usr/lib/systemd/system/emergency.service',
line => 'ExecStart=-/usr/lib/systemd/systemd-sulogin-shell emergency',
match => '^ExecStart=',
}
}
'7': {
file_line { 'su-rescue':
path => '/usr/lib/systemd/system/rescue.service',
line => 'ExecStart=-/bin/sh -c "/sbin/sulogin; /usr/bin/systemctl --fail --no-block default"',
match => '^ExecStart=',
}
file_line { 'su-emergency':
path => '/usr/lib/systemd/system/emergency.service',
line => 'ExecStart=-/bin/sh -c "/sbin/sulogin; /usr/bin/systemctl --fail --no-block default"',
match => '^ExecStart=',
}
}
default: {
file_line { 'sulogin':
path => '/etc/sysconfig/init',
line => 'SINGLE=/sbin/sulogin',
match => '^SINGLE=',
append_on_no_match => true,
}
}
}
}
'suse': {
file_line { 'modify resuce':
ensure => present,
path => '/usr/lib/systemd/system/rescue.service',
match => '^ExecStart=-/usr/lib/systemd/systemd-sulogin-shell',
line => 'ExecStart=-/usr/lib/systemd/systemd-sulogin-shell rescure',
append_on_no_match => true,
}
file_line { 'modify emergency':
ensure => present,
path => '/usr/lib/systemd/system/emergency.service',
match => '^ExecStart=-/usr/lib/systemd/systemd-sulogin-shell',
line => 'ExecStart=-/usr/lib/systemd/systemd-sulogin-shell emergency',
append_on_no_match => true,
}
}
default: {
# Nothing to do yet
}
}
}
}
|