[slime-devel] password handling

Christian Lynbech christian.lynbech at ericsson.com
Mon Jun 6 09:28:06 UTC 2005

Is there a simple way to stuff strings back into slime?

Suppose one has a function for connecting to a database. This
connection will need a password and suppose further that one is a bit
conscious about saving the password in clear text inside the source
file ro typing it directly into the slime repl buffer (where it also
would appear in cleartext).

For shell buffers, I have solved this problem by indentifying the
shell modes filter function and (this on the meacs side) adding the

    (defadvice term-emulate-terminal (after term-emulate-terminal-advice activate)
      "Advice `term-emulate-terminal' to prompt for passwords.
    The variable `term-password-regexp' determines how to match prompt strings.
    The variable `term-password-handling' determines whether passwords are actually
    handled or not."
      (if (and term-password-handling (string-match term-password-regexp str))
          (term-read-password (match-string 0 str))))

Together with the function:

    (defun term-read-password (&optional prompt)
      "Read a password and send it to the buffers process.
    Optional argument PROMPT specifies alternative prompt string."
      (process-send-string nil (my-read-passwd (or prompt "Password: ")))
      (process-send-string nil "\n"))

this allows emacs to recognise that a password is needed, prompt for
the password in the minibuffer using 'read-passwd' and the send the
password directly to the inferior process without the password
appearing directly in the buffer.

I am not claiming this to be perfect security but I think it is a
little better than nothing.

Now I would like to retrofit this functionality to slime, but as the
lisp process is not running directly within the slime repl buffer I am
somewhat unsure on how to best hook in to the I/O flow.

(Some stuff has been left out for brevity, let me know if you need the
full emacs code.)

Christian Lynbech       | christian #\@ defun #\. dk
Hit the philistines three times over the head with the Elisp reference manual.
                                        - petonic at hal.com (Michael A. Petonic)

More information about the slime-devel mailing list