(Note: I would normally use gpg versions of these files but for debugging I've scrapped gpg until I can get it working without encrypting!)
I'd like to store my username/password credentials securely for use with Emacs for database logins - using the sql-postgres interactive command.
According to the 27.1 release notes I should be able to store database connection details in ~/.emacs.d/sql-wallet
, and I should be able to use the netrc format which I've successfully used in my ~/.authinfo
file.
By default, the wallet file is expected to be in the 'user-emacs-directory', named "sql-wallet" or ".sql-wallet", with ".json" (JSON) or no (NETRC) suffix.
However, I have been unable to make this work using netrc, json, or by adding the database details directly to my authinfo file.
I have tried various different formats for the netrc file, including the traditional:
machine HOST login NAME password VALUE port NUMBER
And on inspection of the source in sql.el
, I've also tried various variations on this, which revolved around various permutations of the above with the below:
product DATABASE-TYPE server DATABASE-ADDRESS database DATABASE-SCHEMA-NAME user USERNAME secret PASSWORD
None of them seem to work. To be 100% clear on the above the lowercase words are hardcoded strings in the file, and the upper-case words are supplied by me as the details of my specific connection.
Trying to debug this - I can see that sql-auth-source-search-wallet
is being called with sensible values prompted from sql-postgres
.
However the call to auth-source-search
as far as I can tell is bombing out with:
auth-source-backend-parse: invalid backend spec: 126
auth-source-backend-parse: invalid backend spec: 47
auth-source-backend-parse: invalid backend spec: 46
auth-source-backend-parse: invalid backend spec: 101
...and so on
Which suggests that it can't parse my netrc file.
I've used .authinfo
to great effect to connect to REST, SSH, e-mail, etc - and it's always worked flawlessly, so I don't think I'm doing anything obviously or fundamentally wrong.
Google is throwing up near-zero hits on using this to connect to a database tho - I'm wondering if anyone has got this working, and what was the exact format of the netrc or json file they used to achieve this?
Or any other ideas?
P.S. I'm aware I can just store the details in cleartext in my init file using the custom interface to give defaults for everything, including the password - but for obvious reasons I don't want to do this on a shared server!