Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use opening parenthesis in the switch case condition of RHEL-08-020041 #10472

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<ind:textfilecontent54_object id="obj_configure_bashrc_tmux" version="1">
<ind:behaviors singleline="true" multiline="false" />
<ind:filepath operation="pattern match">^/etc/bashrc$|^/etc/profile\.d/.*$</ind:filepath>
<ind:pattern operation="pattern match">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</ind:pattern>
<ind:pattern operation="pattern match">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</ind:pattern>
<ind:instance datatype="int" operation="greater than or equal">1</ind:instance>
</ind:textfilecontent54_object>
</def-group>
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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

Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ 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

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