N Winkel <nw1...@outlook.com> writes: > Hi Michael,
Hi Neri, > So everything looks fine to me. The question remains: Did you see > the fingerprint prompt in the echo area in case 2 and 3? > > I did not when I tried this earlier, using C-x C-f or `M-x find-file`, > however when I tried just now evaluating the lisp expression from the > *scratch* buffer it showed just fine. > > I assume this has something to do with having called from the echo > area? It is taken over just fine when the password prompt comes > though. > This is strange though as other messages are sometimes shown to the > side of whatever is being typed in the echo area… Well, likely this is because I was too lazy when writing the PoC for the feature. I have just used (message ...) in order to show the fingerprint prompt. (message ...) is very volatile, any other message following it will overwrite the echo buffer. Appended is a patch which makes the message more persistent, using with-temp-message and friends. Please test. The good news is, that the feature seems to work already as expected. In general, at least. > Best regards, Neri. Best regards, Michael.
diff --git a/lisp/tramp.el b/lisp/tramp.el index 863422a6..2685d8f9 100644 --- a/lisp/tramp.el +++ b/lisp/tramp.el @@ -703,12 +703,51 @@ The regexp should match at end of buffer." "No supported authentication methods left to try!" (: "Login " (| "Incorrect" "incorrect")) (: "Connection " (| "refused" "closed")) - (: "Received signal " (+ digit))) + (: "Received signal " (+ digit)) + ;; Fingerprint. + "Verification timed out" + "Failed to match fingerprint" + "An unknown error occurred") (* nonl)) "Regexp matching a `login failed' message. The regexp should match at end of buffer." :type 'regexp) +;; <https://gitlab.freedesktop.org/libfprint/fprintd/-/blob/master/pam/fingerprint-strings.h?ref_type=heads> +(defcustom tramp-fingerprint-prompt-regexp + (rx (| "Place your finger on" + "Swipe your finger across" + "Place your left thumb on" + "Swipe your left thumb across" + "Place your left index finger on" + "Swipe your left index finger across" + "Place your left middle finger on" + "Swipe your left middle finger across" + "Place your left ring finger on" + "Swipe your left ring finger across" + "Place your left little finger on" + "Swipe your left little finger across" + "Place your right thumb on" + "Swipe your right thumb across" + "Place your right index finger on" + "Swipe your right index finger across" + "Place your right middle finger on" + "Swipe your right middle finger across" + "Place your right ring finger on" + "Swipe your right ring finger across" + "Place your right little finger on" + "Swipe your right little finger across" + "Place your finger on the reader again" + "Swipe your finger again" + "Swipe was too short, try again" + "Your finger was not centred, try swiping your finger again" + "Remove your finger, and try swiping your finger again") + (* nonl) (* (any "\r\n"))) + "Regexp matching fingerprint prompts. +The regexp should match at end of buffer." + :version "30.2" + :type 'regexp) + (defcustom tramp-yesno-prompt-regexp (rx "Are you sure you want to continue connecting (yes/no" (? "/[fingerprint]") ")?" @@ -5693,6 +5732,27 @@ of." (narrow-to-region (point-max) (point-max)))) t) +(defcustom tramp-use-fingerprint t + "Whether fingerprint prompts shall be used for authentication." + :version "30.2" + :type 'boolean) + +(defun tramp-action-fingerprint (proc vec) + "Query the user for a fingerprint verification. +Interrupt the query if `tramp-use-fingerprint' is nil." + (with-current-buffer (process-buffer proc) + ;; (let ((point (point-max))) + (if tramp-use-fingerprint + (tramp-action-show-message proc vec) + ;; (process-send-string proc "")) + (interrupt-process proc) + ;; (sit-for 1 'nodisp) + ;; (tramp-accept-process-output proc) + ;; (tramp-message vec 6 "\n%s" (buffer-string)) + ;; Hide message. + (narrow-to-region (point-max) (point-max)))) + t) + (defun tramp-action-succeed (_proc _vec) "Signal success in finding shell prompt." (throw 'tramp-action 'ok)) @@ -5739,6 +5799,26 @@ The terminal type can be configured with `tramp-terminal-type'." (tramp-send-string vec (concat tramp-terminal-type tramp-local-end-of-line)) t) +(defun tramp-action-show-message (proc vec) + "Show the user a message for confirmation. +Wait, until the connection buffer changes." + (with-current-buffer (process-buffer proc) + (let ((cursor-in-echo-area t) + set-message-function clear-message-function tramp-dont-suspend-timers) + (with-tramp-suspended-timers + ;; Silence byte compiler. + (ignore set-message-function clear-message-function) + (tramp-message vec 6 "\n%s" (buffer-string)) + (goto-char (point-min)) + (tramp-check-for-regexp proc tramp-process-action-regexp) + (with-temp-message (concat (string-trim (match-string 0)) " ") + ;; Hide message in buffer. + (narrow-to-region (point-max) (point-max)) + ;; Wait for new output. + (while (length= (buffer-string) 0) + (tramp-accept-process-output proc)))))) + t) + (defun tramp-action-confirm-message (_proc vec) "Return RET in order to confirm the message." (tramp-message