Skip to content

Conversation

@Alex-van-der-Peet
Copy link
Contributor

I've attempted to implement issue #3902 as described in its discussion. Description:

If no username and password are provided through the conf file or command line and no conf file exists, one will be created and preconfigured with the username and password recommended in the original console message. The generated username and password will be set in memory too, so the RPC server is immediately accessible with these details.

If a conf file does exists but does not contain a username and password, the old error will show, as I felt it too forward to start modifying a user's existing conf file without their consent.

First attempt to contribute, please don't bite my head off.

@jonasschnelli
Copy link
Contributor

@Alex-van-der-Peet: your contribution are very welcome! Thanks.

This PR would make things more convenient, but, i have a strong feeling that the bitcoin.conf file should stay readonly. I think apps like bitcoin-core (critical security requirements) should not create config files automatically.

@laanwj
Copy link
Member

laanwj commented Jun 9, 2015

@gmaxwell and I had an interesting conversation about this once. The idea would be not to generate a bitcoin.conf - there are good reasons to keep config files read-only - but a special 'cookie' file for authentication. This file is generated with random content when the daemon starts. Read access to this file stored in the data directory controls who can access through RPC. This method would be active by default if no rpcpassword and rpcuser is specified.

This is similar to Tor's CookieAuthentication: see https://www.torproject.org/docs/tor-manual.html.en

@paveljanik
Copy link
Contributor

I think that we should only create the file when there is no such file.
We should not change the file if it doesn't contain rpcuser and password at all.

So NACK as it is right now.

@Alex-van-der-Peet
Copy link
Contributor Author

@paveljanik Eh? That is how it is implented though. No file -> create file, file -> do nothing.

Also, I might be having a moment of stupidity, but a read-only config file? How would that work exactly?

I checked the access rights of the created file in Ubuntu, I think they're correct.

@paveljanik
Copy link
Contributor

@Alex-van-der-Peet ups, sorry. I have reread again and yes, this is how it is implemented.
utACK

@luke-jr
Copy link
Member

luke-jr commented Jun 15, 2015

Commit description also needs to be fixed to actually describe the change being made.

@Alex-van-der-Peet Alex-van-der-Peet changed the title Attempted implementation of issue #3902 Create .conf file with RPC credentials if none exists. Jun 15, 2015
@sipa
Copy link
Member

sipa commented Jun 15, 2015

@laanwj I like that cookie idea!

@laanwj
Copy link
Member

laanwj commented Jul 6, 2015

I'll have a stab at implementing the cookie authentication.

@laanwj
Copy link
Member

laanwj commented Jul 7, 2015

See #6388

@sipa
Copy link
Member

sipa commented Jul 9, 2015

I prefer #6388's approach.

laanwj added a commit to laanwj/bitcoin that referenced this pull request Jul 13, 2015
When no `-rpcpassword` is specified, use a special 'cookie' file for
authentication. This file is generated with random content when the
daemon starts, and deleted when it exits. Read access to this file
controls who can access through RPC. By default this file is stored in
the data directory but it be overriden with `-rpccookiefile`.

This is similar to Tor CookieAuthentication: see
https://www.torproject.org/docs/tor-manual.html.en

Alternative to bitcoin#6258. Like that pull, this allows running bitcoind
without any manual configuration. However, daemons should ideally never write to
their configuration files, so I prefer this solution.
@laanwj
Copy link
Member

laanwj commented Jul 13, 2015

Closing in favor of #6388

@laanwj laanwj closed this Jul 13, 2015
luke-jr pushed a commit to luke-jr/bitcoin that referenced this pull request Oct 15, 2015
When no `-rpcpassword` is specified, use a special 'cookie' file for
authentication. This file is generated with random content when the
daemon starts, and deleted when it exits. Read access to this file
controls who can access through RPC. By default this file is stored in
the data directory but it be overriden with `-rpccookiefile`.

This is similar to Tor CookieAuthentication: see
https://www.torproject.org/docs/tor-manual.html.en

Alternative to bitcoin#6258. Like that pull, this allows running bitcoind
without any manual configuration. However, daemons should ideally never write to
their configuration files, so I prefer this solution.
luke-jr pushed a commit to luke-jr/bitcoin that referenced this pull request Dec 2, 2015
When no `-rpcpassword` is specified, use a special 'cookie' file for
authentication. This file is generated with random content when the
daemon starts, and deleted when it exits. Read access to this file
controls who can access through RPC. By default this file is stored in
the data directory but it be overriden with `-rpccookiefile`.

This is similar to Tor CookieAuthentication: see
https://www.torproject.org/docs/tor-manual.html.en

Alternative to bitcoin#6258. Like that pull, this allows running bitcoind
without any manual configuration. However, daemons should ideally never write to
their configuration files, so I prefer this solution.
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants