Subject: bug#2817: [PATCH] Emacs CVS:
comint-password-prompt-regexp - support ssh-keygen




Added support for ssh-keygen(1) prompt and changed to new format because
the old one was hard to decipher and keep track on.

The enw one is easier to maintaintain. The tester 'dolist' can be used
to verify new prompts as the variable is changed.

Jari

2009-03-29 Jari Aalto <jari.aalto@xxxxxxxxx>

* comint.el (comint-password-prompt-regexp): Rewrite using
regexp-opt. Add ssh-keygen check. Add dolist block to test new
regexp.

>From 804b37d9bdcffc4980af4f075ee804ea6a8471d2 Mon Sep 17 00:00:00 2001
From: Jari Aalto <jari.aalto@xxxxxxxxx>
Date: Sun, 29 Mar 2009 19:13:06 +0300
Subject: [PATCH] lisp/comint.el: comint.el (comint-password-prompt-regexp):
Rewrite using regexp-opt

---
lisp/comint.el | 71 +++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 58 insertions(+), 13 deletions(-)

diff --git a/lisp/comint.el b/lisp/comint.el
index 5bff986..155dfde 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -328,25 +328,70 @@ This variable is buffer-local."
:type 'boolean
:group 'comint)

-;; AIX puts the name of the person being su'd to in front of the prompt.
-;; kinit prints a prompt like `Password for devnull@xxxxxxx: '.
-;; ksu prints a prompt like `Kerberos password for devnull/root@xxxxxxx: '.
-;; ssh-add prints a prompt like `Enter passphrase: '.
-;; plink prints a prompt like `Passphrase for key "root@xxxxxxx": '.
-;; Ubuntu's sudo prompts like `[sudo] password for user:'
-;; Some implementations of passwd use "Password (again)" as the 2nd prompt.
-;; Something called "perforce" uses "Enter password:".
(defcustom comint-password-prompt-regexp
- "\\(\\(Enter \\|[Oo]ld \\|[Nn]ew \\|'s \\|login \\|\
-Kerberos \\|CVS \\|UNIX \\| SMB \\|LDAP \\|\\[sudo] \\|^\\)\
-\[Pp]assword\\( (again)\\)?\\|\
-pass phrase\\|\\(Enter \\|Repeat \\|Bad \\)?[Pp]assphrase\\)\
-\\(?:, try again\\)?\\(?: for [^:]+\\)?:\\s *\\'"
+ (concat
+ "^\\("
+ (regexp-opt
+ '(;; AIX puts the name of the person being su'd to in front of the prompt.
+ "'s"
+ "Bad"
+ "CVS"
+ "Enter same"
+ "Enter"
+ "Kerberos"
+ "LDAP"
+ "Login"
+ "New"
+ "Old"
+ "Repeat"
+ "SMB"
+ "UNIX"
+ "[sudo]"
+ "bad"
+ "login"
+ "new"
+ "old"
+ "repeat"))
+ " +\\)?"
+ (regexp-opt
+ '("password"
+ "Password"
+ "passphrase"
+ "pass phrase"
+ "Passphrase"
+ "Pass phrase"))
+ "\\("
+ "\\(?:, try \\)?\\( *again\\)?\\(?: for [^:]+\\)?:\\|"
+ " (empty for no passphrase):\\|"
+ " (again)\\|"
+ " for key"
+ "\\)"
+ )
"Regexp matching prompts for passwords in the inferior process.
This is used by `comint-watch-for-password-prompt'."
:type 'regexp
:group 'comint)

+(when nil
+
+ ;; Tester. Run C-x C-e at the end to test new prompts or after
+ ;; changes to comint-password-prompt-regexp
+
+ (dolist (str '("Password for devnull@xxxxxxx: " ; knit
+ "Kerberos password for devnull/root@xxxxxxx: " ; ksu
+ "Enter passphrase: " ; ssh-add
+ "Enter passphrase (empty for no passphrase): " ; ssh-keygen
+ "Enter same passphrase again: " ; ssh-keygen
+ "Passphrase for key root@xxxxxxx: " ; plink
+ "[sudo] password for user:" ; Ubuntu sudo
+ ;; some implementation of passwd(1) as the 2nd prompt
+ "Password (again)"
+ "Enter password:")) ; perforce
+ (unless (string-match comint-password-prompt-regexp str)
+ (error "Did not match: %s" str)))
+
+ )
+
;; Here are the per-interpreter hooks.
(defvar comint-get-old-input (function comint-get-old-input-default)
"Function that returns old text in Comint mode.
--
1.6.1.3



Privacy