diff --git a/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/ansible/shared.yml b/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/ansible/shared.yml index bd7dbe984f5..f33344719fd 100644 --- a/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/ansible/shared.yml +++ b/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/ansible/shared.yml @@ -8,14 +8,14 @@ ansible.builtin.find: paths: '/etc' patterns: 'bashrc' - contains: '.*case "$name" in sshd|login) tmux ;; esac.*' + contains: '.*case "$name" in (sshd|login) tmux ;; esac.*' register: tmux_in_bashrc - name: "{{{ rule_title }}}: Determine if the Tmux launch script is present in /etc/profile.d/*.sh" ansible.builtin.find: paths: '/etc/profile.d' patterns: '*.sh' - contains: .*case "$name" in sshd|login) tmux ;; esac.* + contains: .*case "$name" in (sshd|login) tmux ;; esac.* register: tmux_in_profile_d - name: "{{{ rule_title }}}: Insert the correct script into /etc/profile.d/tmux.sh" @@ -25,7 +25,7 @@ if [ "$PS1" ]; then parent=$(ps -o ppid= -p $$) name=$(ps -o comm= -p $parent) - case "$name" in sshd|login) tmux ;; esac + case "$name" in (sshd|login) tmux ;; esac fi create: true when: diff --git a/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/bash/shared.sh b/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/bash/shared.sh index 80ab85d243d..efa03878236 100644 --- a/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/bash/shared.sh +++ b/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/bash/shared.sh @@ -4,12 +4,12 @@ # complexity = low # disruption = low -if ! grep -x ' case "$name" in sshd|login) tmux ;; esac' /etc/bashrc /etc/profile.d/*.sh; then +if ! grep -x ' case "$name" in (sshd|login) tmux ;; esac' /etc/bashrc /etc/profile.d/*.sh; then cat >> /etc/profile.d/tmux.sh <<'EOF' if [ "$PS1" ]; then parent=$(ps -o ppid= -p $$) name=$(ps -o comm= -p $parent) - case "$name" in sshd|login) tmux ;; esac + case "$name" in (sshd|login) tmux ;; esac fi EOF chmod 0644 /etc/profile.d/tmux.sh diff --git a/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/oval/shared.xml b/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/oval/shared.xml index deefb4e7d4d..1effab2b8cc 100644 --- a/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/oval/shared.xml +++ b/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/oval/shared.xml @@ -14,7 +14,7 @@ ^/etc/bashrc$|^/etc/profile\.d/.*$ - if \[ "\$PS1" \]; then\n\s+parent=\$\(ps -o ppid= -p \$\$\)\n\s+name=\$\(ps -o comm= -p \$parent\)\n\s+case "\$name" in sshd\|login\) tmux ;; esac\nfi + if \[ "\$PS1" \]; then\n\s+parent=\$\(ps -o ppid= -p \$\$\)\n\s+name=\$\(ps -o comm= -p \$parent\)\n\s+case "\$name" in \(?sshd\|login\) tmux ;; esac\nfi 1 diff --git a/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/rule.yml b/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/rule.yml index ebaf9005a71..e2eae90a471 100644 --- a/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/rule.yml +++ b/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/rule.yml @@ -64,7 +64,7 @@ fixtext: |- if [ "$PS1" ]; then parent=$(ps -o ppid= -p $$) name=$(ps -o comm= -p $parent) - case "$name" in sshd|login) tmux ;; esac + case "$name" in (sshd|login) tmux ;; esac fi Then, ensure a correct mode of /etc/profile.d/tmux.sh using this command: diff --git a/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/tests/correct_value.pass.sh b/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/tests/correct_value.pass.sh index b67b9ec0857..c5c95d4d720 100644 --- a/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/tests/correct_value.pass.sh +++ b/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/tests/correct_value.pass.sh @@ -5,6 +5,6 @@ cat >> /etc/bashrc <<'EOF' if [ "$PS1" ]; then parent=$(ps -o ppid= -p $$) name=$(ps -o comm= -p $parent) - case "$name" in sshd|login) tmux ;; esac + case "$name" in (sshd|login) tmux ;; esac fi EOF diff --git a/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/tests/correct_value_d_directory.pass.sh b/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/tests/correct_value_d_directory.pass.sh index c0ddc93e5ef..ef5bca78e5e 100644 --- a/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/tests/correct_value_d_directory.pass.sh +++ b/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/tests/correct_value_d_directory.pass.sh @@ -6,7 +6,7 @@ cat >> /etc/profile.d/00-complianceascode.conf <<'EOF' if [ "$PS1" ]; then parent=$(ps -o ppid= -p $$) name=$(ps -o comm= -p $parent) - case "$name" in sshd|login) tmux ;; esac + case "$name" in (sshd|login) tmux ;; esac fi EOF diff --git a/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/tests/correct_value_no_parenthesis.pass.sh b/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/tests/correct_value_no_parenthesis.pass.sh new file mode 100644 index 00000000000..b67b9ec0857 --- /dev/null +++ b/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/tests/correct_value_no_parenthesis.pass.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# packages = tmux + +cat >> /etc/bashrc <<'EOF' +if [ "$PS1" ]; then + parent=$(ps -o ppid= -p $$) + name=$(ps -o comm= -p $parent) + case "$name" in sshd|login) tmux ;; esac +fi +EOF diff --git a/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/tests/duplicate_value_multiple_files.pass.sh b/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/tests/duplicate_value_multiple_files.pass.sh index e63d3eaf263..8915a186fb9 100644 --- a/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/tests/duplicate_value_multiple_files.pass.sh +++ b/linux_os/guide/system/accounts/accounts-physical/screen_locking/console_screen_locking/configure_bashrc_tmux/tests/duplicate_value_multiple_files.pass.sh @@ -5,7 +5,7 @@ cat >> /etc/profile.d/00-complianceascode.conf <<'EOF' if [ "$PS1" ]; then parent=$(ps -o ppid= -p $$) name=$(ps -o comm= -p $parent) - case "$name" in sshd|login) tmux ;; esac + case "$name" in (sshd|login) tmux ;; esac fi EOF @@ -13,6 +13,6 @@ cat >> /etc/bashrc <<'EOF' if [ "$PS1" ]; then parent=$(ps -o ppid= -p $$) name=$(ps -o comm= -p $parent) - case "$name" in sshd|login) tmux ;; esac + case "$name" in (sshd|login) tmux ;; esac fi EOF