# Ensure access to /etc/motd is configured

Necessity: The '/etc/motd' (Message of the Day) file is displayed to users upon logging in via a command-line interface. If this file is writable by non-privileged users, an attacker could modify it to display malicious or misleading information. This could be used for social engineering attacks, such as tricking an administrator into running a malicious command, or to spread disinformation within an organization. Securing this file ensures the integrity of the information presented to all users and prevents its misuse.

Auditing and Remediation: The audit script verifies that the ownership and permissions of '/etc/motd' are set correctly. It checks that the file is owned by the 'root' user and group and has permissions that prevent unauthorized modification. The remediation script uses the standard 'chown' and 'chmod' commands to enforce the secure ownership and permissions on the file.

Recommended State Rationale: The recommended state for all levels (Basic, Moderate, and Strict) is ownership by 'root:root' with permissions set to '644' (-rw-r--r--). This configuration adheres to the principle of least privilege. It ensures that only the superuser (root) can modify the file, while all other users can read it, which is necessary for it to be displayed at login. There is no more secure or functional configuration; therefore, this standard is consistently applied across all hardening levels.

## Recommended State Configuration

| Security Level | Value |
|----------------|-------|
| **Basic** | `['root:root 644']` |
| **Moderate** | `['root:root 644']` |
| **Strict** | `['root:root 644']` |
| **Type** | `ENUM` |

## Audit Script Working

Bash script that uses the 'stat' command to check the ownership and permissions of the '/etc/motd' file. The script must output the result in the format 'owner:group permissions_octal' (e.g., 'root:root 644'), and nothing else.

## Remediation Script Working

Bash script that accepts a single string argument in the format 'owner:group permissions_octal' (e.g., 'root:root 644'). The script must use 'chown' to set the owner and group, and 'chmod' to set the permissions for '/etc/motd' based on the argument. The script must return 'true' on success and 'false' on failure.

