0

enter image description here

I'm using emacs on a console (emacs -nw). I use sql-mode, and when connecting to postgresql, it asks me to enter a password on a buffer, where password is visible.

If I customize-group and set the password option in sql-postgre-login-params list, it asks for password on the minibuffer, but also asks for password on a buffer.

How can customize sql-mode to get asked for password only on the minibuffer?

Thanks in advance.

Edit: the Emacs version: GNU Emacs 24.3.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.10)

quimm2003
  • 871
  • 6
  • 8

2 Answers2

0

What emacs version are you using? This happened to me when I used emacs23, if that's the case, you have several options.

  • Update to emacs 24. It hides passwords automatically.

  • If this happens once or twice, you could use M-x send-invisible (RET) password (RET)

  • If this happens a lot, try:

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

makeMonday
  • 2,303
  • 4
  • 25
  • 43
  • I'm using Emacs 24.3.1. I can't use the second solution because the sql-postgres prompts for it. The third one does not work. Thanks. – quimm2003 Mar 07 '14 at 11:29
  • I am trying to reproduce the issue, I'm not being able to set a PostgreSQL DB, but I am able to get to the `*SQL*` buffer in `(SQLi[Postgres])` mode. There `send-invisible` works for me. Are you trying to use that command once you are in that prompt? :-/ – makeMonday Mar 07 '14 at 12:26
  • I can't get a buffer from `sql-postgres` whithout being immediately prompted to write login parameters, so I can't use `send-invisible`... – quimm2003 Mar 07 '14 at 15:29
0

Found a temporary solution to this problem.

According to psql man page:

-W, --password
Force psql to prompt for a password before connecting to a database. This option is never essential, since psql will automatically prompt for a password if the server demands password authentication. However, psql will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing -W to avoid the extra connection attempt.

So, connecting to postgres database through psql when a connection needs a password will ever prompt for a password in a buffer.

A temporary solution might be set the -w option on psql call to not ask for a password. Then, it gets the password from the ~/.pgpass file. This file has 0600 permissions so it is insecure. But works for me right now.

In the .emacs file:

(custom-set-variables
        '(sql-postgres-options (quote ("-P" "pager=off" "-w"))))

A better solution might be using ssl certificates, which I will explore.

Thank you all for your help.

quimm2003
  • 871
  • 6
  • 8