# Ensure access to /etc/motd is configured

The '/etc/motd' (Message of the Day) file displays a banner to all users upon logging in. Its configuration is crucial for maintaining system integrity and communicating authorized information.

**Necessity:** If '/etc/motd' is writable by non-privileged users, it can be defaced or used to display misleading or malicious information, potentially tricking users into compromising their credentials or executing harmful commands. Proper permissions prevent unauthorized modification, ensuring the banner remains a trusted source of information from system administrators.

**Auditing and Remediation:** The audit script verifies the current access controls by checking the file's octal permission mode and its user/group ownership. The remediation script uses the 'chmod' and 'chown' commands to enforce the specified permissions and ownership, securing the file against unauthorized access.

**Recommended State Rationale:**
- **Basic (`644 root:root`):** This is the standard secure configuration. It sets the owner to 'root' and allows only root to write to the file. All other users are granted read-only access, which is necessary for the login process to display the banner. This prevents any tampering by non-administrative users.
- **Moderate (`640 root:root`):** This state enhances security by removing read permissions for 'others'. Access is restricted to the root user and members of the 'root' group. This follows the principle of least privilege by preventing users outside the administrative group from reading the file directly.
- **Strict (`600 root:root`):** This is the most restrictive state, granting read and write permissions exclusively to the root user. It ensures maximum confidentiality and integrity of the banner's content, as no other user can access the file in any way. The login process, which typically runs with elevated privileges, can still display the message to the user.

## Recommended State Configuration

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

## Audit Script Working

Bash script that inspects the file permissions and ownership of '/etc/motd'. The script must use the 'stat' command to retrieve the octal permissions and the user/group owner (e.g., '644 root:root'). The output must be a single string containing only this value, with no additional text or formatting.

## Remediation Script Working

Bash script that accepts a single positional command-line argument specifying the desired state for '/etc/motd' in the format 'permissions owner:group' (e.g., '644 root:root'). The script must parse this argument to set the file permissions using 'chmod' and the ownership using 'chown'. The script must output 'true' on successful application of both settings, and 'false' if either operation fails.

