TMAegisБета
Другие правила для linux

Linux distributions

TMA-ALMA9-5.4.3.2

Ensure default user shell timeout is configured

СреднийУровень 1Автоматическаяlinux

Описание

TMOUT is a shell environment variable that sets an interactive shell's idle timeout, in seconds: after TMOUT seconds with no input, the shell exits. TMOUT=<n> sets the timeout to n seconds (a value of 0 disables it); marking the variable readonly prevents a user from overriding it during the session, and exporting it applies it to the user's shell environment.

Как проверяется

Метод проверки: Команда оболочки

shell
alt0() { o=$(bash -c '#!/usr/bin/env bash
{
   l_max=900
   a_files=()
   while IFS= read -r l_file; do a_files+=("$l_file"); done < <(grep -Pls -- '"'"'^([^#\n\r]+)?\bTMOUT\b'"'"' \
      /etc/*bashrc /etc/profile /etc/profile.d/*.sh /etc/profile.d/sh.local \
      /usr/etc/profile.d/*.sh /usr/etc/profile.d/sh.local 2>/dev/null)
   l_set=0
   for l_file in "${a_files[@]}"; do
      l_val="$(grep -Po -- '"'"'^([^#\n\r]+)?\bTMOUT=\d+\b'"'"' "$l_file" | awk -F= '"'"'{v=$2} END{if (NR>0) print v}'"'"')"
      [ -z "$l_val" ] && continue
      l_set=1
      l_ro="$(grep -P -- '"'"'^\h*(typeset\h\- xr\hTMOUT=\d+|([^#\n\r]+)?\breadonly\h+TMOUT\b)'"'"' "$l_file")"
      l_exp="$(grep -P -- '"'"'^\h*(typeset\h\- xr\hTMOUT=\d+|([^#\n\r]+)?\bexport\b([^#\n\r]+\b)?TMOUT\b)'"'"' "$l_file")"
      [ "$l_val" -gt 0 ] && [ "$l_val" -le "$l_max" ] || echo "$l_file: TMOUT=$l_val is out of range (must be >0 and <=$l_max)"
      [ -n "$l_ro" ]  || echo "$l_file: TMOUT is not marked readonly"
      [ -n "$l_exp" ] || echo "$l_file: TMOUT is not exported"
   done
   [ "$l_set" -eq 0 ] && echo "TMOUT is not set in any shell initialization file"
}' 2>&1); [ -z "$o" ] || { echo "step1: $o" | head -c 300; return 1; }; }; if alt0; then echo compliant; fi
Ожидаемый вывод
compliant

Как исправляется

Метод исправления: Рекомендация или патч инфраструктуры

Configure TMOUT in a single file. Because best practice marks TMOUT readonly, a second assignment from a later-sourced file produces a "TMOUT: readonly variable" error at every login, so it must be set exactly once. 1. Run the following command to locate any existing TMOUT assignments in the shell initialization files: # grep -PHrs -- '\bTMOUT\b' /etc/profile /etc/profile.d/ /etc/bashrc /etc/*bashrc 2. In each file returned in step one, remove or comment out the TMOUT lines so TMOUT is no longer set in more than one location. 3. Create a single drop-in file in /etc/profile.d/ that sets, marks readonly, and exports TMOUT in one statement, using a value greater than 0 and no greater than 900 s…

Свойства

Операционные системы
almalinux-9
Теги
cis-convertedlinux
Источник
CIS AlmaLinux OS 9 Benchmark v3.0.0 - 5.4.3.2

Проверить этот хост

Выполните команду на компьютере, аудит которого вам разрешён. Сканирование работает только на чтение.

shell
tmaegis scan --target linux