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

Reduce unnecessary tmux sessions #301

Open
dglinder opened this issue Sep 17, 2024 · 0 comments
Open

Reduce unnecessary tmux sessions #301

dglinder opened this issue Sep 17, 2024 · 0 comments

Comments

@dglinder
Copy link

In this task within the fix-cat2.yml playbook, specifically line 3340:

RHEL8-STIG/tasks/fix-cat2.yml

Lines 3332 to 3344 in 461d572

- name: "MEDIUM | RHEL-08-020041 | PATCH | RHEL 8 must ensure session control is automatically started at shell initialization. | Set tmux.sh if file exists"
ansible.builtin.blockinfile:
path: /etc/profile.d/tmux.sh
marker: "# <!-- {mark} ANSIBLE LOCKDOWN RHEL-08-020041 MANAGED BLOCK -->"
block: |
if [ "$PS1" ]; then
parent=$(ps -o ppid= -p $$)
name=$(ps -o comm= -p $parent)
case "$name" in (sshd|login) exec tmux ;; esac
fi
create: true
when:
- rhel_08_020041

The system is configured to execute tmux at this line:

case "$name" in (sshd|login) exec tmux ;; esac

In situations where a person is logged, gets disconnected, and re-connects, the system executes a new tmux session.

This creates confusion as the user tries to reconnect to their previous sessions (if they are tmux savvy), or additional frustration as they (believe) they have lost their previous work (probably not true).

Changing this line to this:

case "$name" in (sshd|login) tmux a || exec tmux ;; esac

...will run tmux a to re-attach to the users pre-existing session if it exists, but if it doesn't then the exec tmux will execute the new tmux session as required.

This is related to #232 and whenever that issue is resolved, this would be a welcome enhancement to the handling of the tmux sessions for any of us who are in the command line on systems with intermittent connectivity issues.

@dglinder dglinder changed the title Reduce multiple tmux sessions Reduce unnecessary tmux sessions Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant