bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#13124: 24.1; shell-mode does not hide sudo password prompts


From: Kenichi Handa
Subject: bug#13124: 24.1; shell-mode does not hide sudo password prompts
Date: Thu, 13 Dec 2012 23:14:19 +0900

In article <2937464.OIdV3OoAVt@fluss>, Arne Babenhauserheide <arne_bab@web.de> 
writes:

> I installed emacs for a collegue and the visible password is the major reason 
> why he switches to the quite inconvenient term/ansi-term mode instead of 
> shell.

> So I think it is very relevant: It’s a matter of good defaults to never show 
> the Password your user types. Especially not (quasi-)root passwords.

It seems to be difficult to setup
comint-password-prompt-regexp for all variations of prompts
for password.  How about using this kind of code (incomplete)?

(defun shell-enter-password ()
  (interactive)
  (let* ((inhibit-field-text-motion t)
         (prompt (buffer-substring (line-beginning-position) (point))))
    (if (and (not (string-match comint-password-prompt-regexp prompt))
             (y-or-n-p (format "Remember \"%s\" as a password prompt for the 
future session? " prompt)))
        ;; Insert a proper code to add PROMPT to comint-password-prompt-regexp
        ;; and save it in .emacs.
        nil)
    (send-invisible prompt)))

(define-key shell-mode-map "\C-cp" 'shell-enter-password)

One can type C-c p when the shell buffer displays a prompt
for password without letting user enter a password in the
minibuffer.

---
Kenichi Handa
handa@gnu.org





reply via email to

[Prev in Thread] Current Thread [Next in Thread]