diff options
| author | Michael Albinus | 2021-07-24 13:58:03 +0200 |
|---|---|---|
| committer | Michael Albinus | 2021-07-24 13:58:03 +0200 |
| commit | 9ad1f71c39eda81237df048cc170bee6e4216d97 (patch) | |
| tree | 2ce8af8e91a6e60e91d54fdd7ba5d98f95d54d2c | |
| parent | d8a4a5ac7c3cbccf938febc4cafb521a1daa165a (diff) | |
| download | emacs-9ad1f71c39eda81237df048cc170bee6e4216d97.tar.gz emacs-9ad1f71c39eda81237df048cc170bee6e4216d97.zip | |
Add Tramp support for yubikey (bug#49714)
* lisp/net/tramp.el (tramp-yubikey-regexp): New defcustom.
(tramp-action-show-and-confirm-message): New defun.
* lisp/net/tramp-sh.el (tramp-actions-before-shell)
(tramp-actions-copy-out-of-band): Add `tramp-yubikey-regexp' action.
| -rw-r--r-- | lisp/net/tramp-sh.el | 2 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 23 |
2 files changed, 25 insertions, 0 deletions
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index f94508303df..41ab1045c24 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -519,6 +519,7 @@ shell from reading its init file." | |||
| 519 | (tramp-yn-prompt-regexp tramp-action-yn) | 519 | (tramp-yn-prompt-regexp tramp-action-yn) |
| 520 | (tramp-terminal-prompt-regexp tramp-action-terminal) | 520 | (tramp-terminal-prompt-regexp tramp-action-terminal) |
| 521 | (tramp-antispoof-regexp tramp-action-confirm-message) | 521 | (tramp-antispoof-regexp tramp-action-confirm-message) |
| 522 | (tramp-yubikey-regexp tramp-action-show-and-confirm-message) | ||
| 522 | (tramp-process-alive-regexp tramp-action-process-alive)) | 523 | (tramp-process-alive-regexp tramp-action-process-alive)) |
| 523 | "List of pattern/action pairs. | 524 | "List of pattern/action pairs. |
| 524 | Whenever a pattern matches, the corresponding action is performed. | 525 | Whenever a pattern matches, the corresponding action is performed. |
| @@ -536,6 +537,7 @@ corresponding PATTERN matches, the ACTION function is called.") | |||
| 536 | '((tramp-password-prompt-regexp tramp-action-password) | 537 | '((tramp-password-prompt-regexp tramp-action-password) |
| 537 | (tramp-wrong-passwd-regexp tramp-action-permission-denied) | 538 | (tramp-wrong-passwd-regexp tramp-action-permission-denied) |
| 538 | (tramp-copy-failed-regexp tramp-action-permission-denied) | 539 | (tramp-copy-failed-regexp tramp-action-permission-denied) |
| 540 | (tramp-yubikey-regexp tramp-action-show-and-confirm-message) | ||
| 539 | (tramp-process-alive-regexp tramp-action-out-of-band)) | 541 | (tramp-process-alive-regexp tramp-action-out-of-band)) |
| 540 | "List of pattern/action pairs. | 542 | "List of pattern/action pairs. |
| 541 | This list is used for copying/renaming with out-of-band methods. | 543 | This list is used for copying/renaming with out-of-band methods. |
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 093335a77b5..24953f751e9 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -698,6 +698,15 @@ The regexp should match at end of buffer." | |||
| 698 | :version "27.1" | 698 | :version "27.1" |
| 699 | :type 'regexp) | 699 | :type 'regexp) |
| 700 | 700 | ||
| 701 | ;; Yubikey requires the user physically to touch the device with their | ||
| 702 | ;; finger. We must tell it to the user. | ||
| 703 | (defcustom tramp-yubikey-regexp | ||
| 704 | (regexp-quote "Confirm user presence for key .*") | ||
| 705 | "Regular expression matching yubikey confirmation message. | ||
| 706 | The regexp should match at end of buffer." | ||
| 707 | :version "28.1" | ||
| 708 | :type 'regexp) | ||
| 709 | |||
| 701 | (defcustom tramp-operation-not-permitted-regexp | 710 | (defcustom tramp-operation-not-permitted-regexp |
| 702 | (concat "\\(" "preserving times.*" "\\|" "set mode" "\\)" ":\\s-*" | 711 | (concat "\\(" "preserving times.*" "\\|" "set mode" "\\)" ":\\s-*" |
| 703 | (regexp-opt '("Operation not permitted") t)) | 712 | (regexp-opt '("Operation not permitted") t)) |
| @@ -4669,6 +4678,20 @@ The terminal type can be configured with `tramp-terminal-type'." | |||
| 4669 | (tramp-send-string vec tramp-local-end-of-line) | 4678 | (tramp-send-string vec tramp-local-end-of-line) |
| 4670 | t) | 4679 | t) |
| 4671 | 4680 | ||
| 4681 | (defun tramp-action-show-and-confirm-message (_proc vec) | ||
| 4682 | "Show the user a message for confirmation. | ||
| 4683 | Wait, until the user has entered RET." | ||
| 4684 | (save-window-excursion | ||
| 4685 | (let ((enable-recursive-minibuffers t) | ||
| 4686 | (stimers (with-timeout-suspend))) | ||
| 4687 | (with-current-buffer (tramp-get-connection-buffer vec) | ||
| 4688 | (tramp-message vec 6 "\n%s" (buffer-string)) | ||
| 4689 | (pop-to-buffer (current-buffer))) | ||
| 4690 | (read-string "Press ENTER to continue") | ||
| 4691 | ;; Reenable the timers. | ||
| 4692 | (with-timeout-unsuspend stimers))) | ||
| 4693 | t) | ||
| 4694 | |||
| 4672 | (defun tramp-action-process-alive (proc _vec) | 4695 | (defun tramp-action-process-alive (proc _vec) |
| 4673 | "Check, whether a process has finished." | 4696 | "Check, whether a process has finished." |
| 4674 | (unless (process-live-p proc) | 4697 | (unless (process-live-p proc) |