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

Improve .bashrc and .bash_profile integration #20

Open
drwonky opened this issue Mar 10, 2022 · 2 comments
Open

Improve .bashrc and .bash_profile integration #20

drwonky opened this issue Mar 10, 2022 · 2 comments

Comments

@drwonky
Copy link

drwonky commented Mar 10, 2022

There are several issues I encountered with bash integration:

  • The mc-agent-env file was being created with default permissions instead of specific permissions (yes, umask could be changed, but we're talking defaults here)
  • The PID of the agent was being printed during login because pgrep was not redirected to /dev/null
  • The /tmp directory was being littered with agent directories when a logout would terminate the agent

Here is the code snippet I settled on for my .bash_profile:

if ! pgrep -u "$USER" mc-agent > /dev/null; then
    #remove old agent directories
    find /tmp -name 'moolticute-ssh-agent*' -user ${USER} -type d -prune -exec rm -r {} ';' 2>/dev/null
    #create the agent env file with user read/write permissions only
    mc-agent | install -m 600 /dev/stdin ~/.mc-agent-env
fi
#send pgrep output to /dev/null so console isn't littered with random PIDs
if pgrep -u "$USER" mc-agent > /dev/null && grep -q 'SSH_AUTH_SOCK=' ~/.mc-agent-env; then
    # once mc-agent started successfully override gnome-keyring ssh component
    eval "$(<~/.mc-agent-env)"
fi
@raoulh
Copy link
Owner

raoulh commented Mar 10, 2022

Hi, could you provide a PR for your changes to https://github.com/raoulh/mc-agent/blob/master/docs/mc-agent.md ?
thanks

@drwonky
Copy link
Author

drwonky commented Mar 10, 2022

Yeah, I'll fork/branch/commit/PR it tomorrow.

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

2 participants