From 9302507257a49e06ffa88c68ee64f387fae9deaf Mon Sep 17 00:00:00 2001 From: Matt Hamilton Date: Mon, 21 Dec 2015 20:34:55 -0500 Subject: [PATCH] use sane dir if $TMPDIR is not set --- modules/ssh/init.zsh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/ssh/init.zsh b/modules/ssh/init.zsh index c4ca68a..eaabdf2 100644 --- a/modules/ssh/init.zsh +++ b/modules/ssh/init.zsh @@ -7,8 +7,16 @@ if (( ! ${+commands[ssh-agent]} )); then return 1 fi -local ssh_env=${TMPDIR:-/tmp}/ssh-agent.env -local ssh_sock=${TMPDIR:-/tmp}/ssh-agent.sock +# use a sane temp dir; creating 1k ssh-* files in /tmp is crazy +if [[ ${TMPDIR} ]]; then + local ssh_env=${TMPDIR}/ssh-agent.env + local ssh_sock=${TMPDIR}/ssh-agent.sock +else + # create a sane tmp dir at /tmp/username + mkdir -p /tmp/${USER} + local ssh_env=/tmp/${USER} + local ssh_sock=/tmp/${USER} +fi # start ssh-agent if not already running if [[ ! -S ${SSH_AUTH_SOCK} ]]; then