-
Notifications
You must be signed in to change notification settings - Fork 38.6k
util: Check if specified config file cannot be opened #22622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
e4a85aa to
127b460
Compare
|
ACK 127b460 I agree that failing to read an explicitly specified config file should fail initialization. Tested that starting with a non-openable config file throws an error. |
|
Concept ACK |
|
tACK 127b460 Tested on macOS v11.4 Patch works as described. I got the following error from testing both cases: config file doesn't exist and config file is inaccessible (due to permissions): $ bitcoind -datadir=/tmp/bitcoin -regtest -conf=/tmp/bitcoin/regtest/bitcoin.conf
Error: Error reading configuration file: specified config file "/tmp/bitcoin/regtest/bitcoin.conf" could not be opened. |
|
Concept ACK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK. Makes sense to fail the initial startup if the config is inaccessible instead of using the default one (which the user might/might not want)
Tested on Manjaro Linux v21.1.0 . The PR patch works as described :)
theStack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested ACK 127b460
Checked that starting src/bitcoind -conf=doesnt_exist leads to the newly introduced error message (running OpenBSD 6.9 here). Also tested that running the extended test in the second commit fails on master branch.
…pened 127b460 test: Check if specified config file cannot be opened (nthumann) 6bb5470 util: Check if specified config file cannot be opened (nthumann) Pull request description: Fixes bitcoin#22612. When running e.g. `./src/bitcoind -datadir=/tmp/bitcoin -regtest -conf=/tmp/bitcoin/regtest/bitcoin.conf` and the specified config cannot be opened (doesn't exist, permission denied, ...), the initialization silently uses the default config. As voidburn already noted: > I can't think of a situation in which a config file is specified explicitly (in the startup options, as per service unit linked above), but inaccessible, where the fail condition should be to keep booting using defaults instead. With this patch applied, the initialization will fail immediately, if the specified config file cannot be opened. If no config file is explicitly specified, the behavior is unchanged. This not only affects `bitcoind`, but also `bitcoin-cli` and `bitcoin-qt`. In the example below the datadir is accessible, but the config file is not due to insufficient permissions: ``` $ ./src/bitcoind -datadir=/tmp/bitcoin -regtest --debug=1 -conf=/tmp/bitcoin/regtest/bitcoin.conf Error: Error reading configuration file: specified config file "/tmp/bitcoin/regtest/bitcoin.conf" could not be opened. ``` ACKs for top commit: 0xB10C: ACK 127b460 Zero-1729: tACK 127b460 theStack: Tested ACK 127b460 Tree-SHA512: 4fe487921485426f1d1da8d256c388af517b984b639d776aec7b159b3e23b669824093d3bdd31139d9415ed5f5de405b3e6a51b110c8ab471f12b9c99ac67cc1
Fixes #22612.
When running e.g.
./src/bitcoind -datadir=/tmp/bitcoin -regtest -conf=/tmp/bitcoin/regtest/bitcoin.confand the specified config cannot be opened (doesn't exist, permission denied, ...), the initialization silently uses the default config.As voidburn already noted:
With this patch applied, the initialization will fail immediately, if the specified config file cannot be opened. If no config file is explicitly specified, the behavior is unchanged. This not only affects
bitcoind, but alsobitcoin-cliandbitcoin-qt.In the example below the datadir is accessible, but the config file is not due to insufficient permissions: