Muli Ben-Yehuda's journal

August 31, 2003

OLS PGP key signing party aftermath

Filed under: Uncategorized — Muli Ben-Yehuda @ 5:45 PM

Finally finished signing all of the keys from the OLS PGP key signing party. According to the report, I’m number 58 in the OLS key ring, and according to the latest global key analysis report, I’m number 813 globally. Whee! I’m such a geek of meaningless statistics 🙂

making xemacs shell mode not display ssh passwords

Filed under: Uncategorized — Muli Ben-Yehuda @ 2:01 AM

I keep a list of things to code for fun. Things that annoy me, things
that I feel could be done better, things that have non trivial hack
value and things that people ask me to do. Tonight I fixed one of the
most annoying bugs on the list – yay me! For your geeky perusal
pleasure, here are the details, from an email I sent to friends who
might appreciate the fix:

I use xemacs's shell mode constantly, and the biggest qualm I had with
it is that sometimes it wouldn't hide ssh passwords and force me to
input them in clear text. I finally got fed up with it tonight and
fixed it. Here's how to fix it, in case you use shell mode as
well. (Oleg, you're cc'd as my (e)lisp guru for constructive criticism
;-))

First of all, it can be done manually, by calling M-x send-invisible
before inputting the password. But that's troublesome, and why do by
hand something that can be done automatically?

The right way to do it is to add these elisp snippets to your
.xemacs/init.el or equivalent: 

(add-hook 'comint-output-filter-functions
          'comint-watch-for-password-prompt)

; make shell mode recognize ssh password prompts 
(setq comint-password-prompt-regexp 
      "\\(\\([Oo]ld \\|[Nn]ew \\|^\\|'s \\)[Pp]assword\\|pass?phrase\\):\\s *\\'")

END QUOTE

the regexp above should be all on one line. 

Explanation: shell mode uses the comint module for processing process
output. In the comint module, there is a hook,
'comint-output-filter-functions' that is called on each line of
output. Whatever functions are part of that hook will be called on
each line of output. The first elisp snippet above adds
'comint-watch-for-password-prompt' to the functions to be called. 

'comint-watch-for-password-prompt' is a pretty simple function: 

(defun comint-watch-for-password-prompt (string)
  (if (string-match comint-password-prompt-regexp string)
      (send-invisible nil)))

That is, if the string we got as an input parameter matches the
regular expression commint-password-prompt-regexp, call
'send-invisible'. This is where the second snippet above comes into
play - it modifies the default password regexp to recognize ssh's
passwd prompt, which looks something like this

xxx@xxx.xxx's password: 

The regexp originally looked for (ignoring case for simplicity) 'old'
or 'new' or 'beginning of line' and then 'password'. I added "'s" to
the list of prefixes. 

Blog at WordPress.com.