2014-03-06 44 views
0

enter image description here的Emacs與SQL模式-nw在迷你緩衝區

我使用emacs控制檯(emacs的-nw)上不問密碼。我使用sql-mode,當連接到postgresql時,它會要求我在緩衝區中輸入密碼,其中密碼可見。

如果我在sql-postgre-login-params列表中設置了自定義組和密碼選項,它會在minibuffer上請求密碼,但也會在緩衝區上請求密碼。

如何定製sql-mode以僅在minibuffer上詢問密碼?

在此先感謝。

編輯:Emacs的版本:GNU Emacs的24.3.1(x86_64的未知Linux的GNU的,GTK +版本10年2月24日)

回答

0

找到一個臨時的解決了這個問題。

根據psql的手冊頁:

-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.

因此,通過PSQL連接到Postgres數據庫連接時需要密碼永遠不會提示輸入緩衝區的一個密碼。

臨時解決方案可能會在psql調用中設置-w選項來不要求輸入密碼。然後,它從~/.pgpass文件獲取密碼。此文件具有0600權限,因此它是不安全的。但現在適合我。

.emacs文件:

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

更好的解決方案可能會使用SSL證書,我將探討。

謝謝大家的幫助。

0

什麼emacs的版本是您使用?這發生在我使用emacs23時,如果是這種情況,你有幾個選項。

  • 更新到emacs 24.它自動隱藏密碼。

  • 如果發生這種情況一次或兩次,你可以使用M-x send-invisible (RET) password (RET)

  • 如果這種情況發生了很多,嘗試:

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

+0

我正在使用Emacs 24.3.1。我不能使用第二個解決方案,因爲sql-postgres會提示它。第三個不起作用。謝謝。 – quimm2003

+0

我想重現這個問題,我無法設置PostgreSQL數據庫,但是我可以在'(SQLi [Postgres])模式下進入'* SQL *'緩衝區。有「隱形」的作品適合我。您是否在嘗試使用該命令? : -/ – makeMonday

+0

我無法從'sql-postgres'獲得緩衝區而不立即提示寫入登錄參數,因此我無法使用'send-invisible' ... – quimm2003