Переглянути джерело

Add keyctl to tmux key clearing hook

Taddeus Kroes 2 тижнів тому
батько
коміт
d1ebb6025b
4 змінених файлів з 9 додано та 7 видалено
  1. 1 1
      install.sh
  2. 4 2
      scripts/tmux-clear-keys.sh
  3. 3 3
      tmux.clear-keys.conf
  4. 1 1
      tmux.conf

+ 1 - 1
install.sh

@@ -21,7 +21,7 @@ ln -sf $DIR/bashrc ~/.bashrc
 # tmux
 ln -sf $DIR/tmux.conf ~/.tmux.conf
 if [ $INSTALL_ALL -eq 1 ]; then
-    ln -sf $DIR/tmux.ssh-agent.conf ~/.tmux.ssh-agent.conf
+    ln -sf $DIR/tmux.clear-keys.conf ~/.tmux.clear-keys.conf
 fi
 
 # vim

+ 4 - 2
scripts/tmux-clear-ssh-agent.sh → scripts/tmux-clear-keys.sh

@@ -5,6 +5,8 @@ set -e
 #exec > >(tee -a /tmp/tmux-timer.log) 2>&1
 sleep "${1-0}"
 if [ $(tmux list-clients | wc -l) -eq 0 ]; then
-    export SSH_AUTH_SOCK="/run/user/$(id -u)/openssh_agent"
-    exec ssh-add -D
+    if which keyctl >/dev/null; then
+        keyctl purge user
+    fi
+    SSH_AUTH_SOCK="/run/user/$(id -u)/openssh_agent" exec ssh-add -D
 fi

+ 3 - 3
tmux.ssh-agent.conf → tmux.clear-keys.conf

@@ -1,7 +1,7 @@
 # clear SSH agent shortly after detaching, unless reattached in the meantime
-set-hook -g client-detached 'run-shell "~/config/scripts/tmux-clear-ssh-agent.sh 180 &"'
-set-hook -g session-closed 'run-shell "~/config/scripts/tmux-clear-ssh-agent.sh 60 &"'
-set-hook -g client-attached 'run-shell "pkill -f tmux-clear-ssh-agent.sh || true"'
+set-hook -g client-detached 'run-shell "~/config/scripts/tmux-clear-keys.sh 180 &"'
+set-hook -g session-closed 'run-shell "~/config/scripts/tmux-clear-keys.sh 60 &"'
+set-hook -g client-attached 'run-shell "pkill -f tmux-clear-keys.sh || true"'
 
 # ensure the SSH_AUTH_SOCK is updated when re-attaching
 set -g update-environment "SSH_AUTH_SOCK"

+ 1 - 1
tmux.conf

@@ -26,4 +26,4 @@ bind j select-pane -D
 bind k select-pane -U
 bind l select-pane -R
 
-source-file -q ~/.tmux.ssh-agent.conf
+source-file -q ~/.tmux.clear-keys.conf