mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-01 08:24:21 +01:00
Merge bitcoin/bitcoin#27302: init: Error if ignored bitcoin.conf file is found
eefe56967bbugfix: Fix incorrect debug.log config file path (Ryan Ofsky)3746f00be1init: Error if ignored bitcoin.conf file is found (Ryan Ofsky)398c3719b0lint: Fix lint-format-strings false positives when format specifiers have argument positions (Ryan Ofsky) Pull request description: Show an error on startup if a bitcoin datadir that is being used contains a `bitcoin.conf` file that is ignored. There are two cases where this could happen: - One case reported in [#27246 (comment)](https://github.com/bitcoin/bitcoin/issues/27246#issuecomment-1470006043) happens when a `bitcoin.conf` file in the default datadir (e.g. `$HOME/.bitcoin/bitcoin.conf`) has a `datadir=/path` line that sets different datadir containing a second `bitcoin.conf` file. Currently the second `bitcoin.conf` file is ignored with no warning. - Another way this could happen is if a `-conf=` command line argument points to a configuration file with a `datadir=/path` line and that path contains a `bitcoin.conf` file, which is currently ignored. This change only adds an error message and doesn't change anything about way settings are applied. It also doesn't trigger errors if there are redundant `-datadir` or `-conf` settings pointing at the same configuration file, only if they are pointing at different files and one file is being ignored. ACKs for top commit: pinheadmz: re-ACKeefe56967bwillcl-ark: re-ACKeefe56967bTheCharlatan: ACKeefe56967bTree-SHA512: 939a98a4b271b5263d64a2df3054c56fcde94784edf6f010d78693a371c38aa03138ae9cebb026b6164bbd898d8fd0845a61a454fd996e328fd7bcf51c580c2b
This commit is contained in:
@@ -12,13 +12,15 @@ import inspect
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import pathlib
|
||||
import random
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
|
||||
from . import coverage
|
||||
from .authproxy import AuthServiceProxy, JSONRPCException
|
||||
from typing import Callable, Optional
|
||||
from typing import Callable, Optional, Tuple
|
||||
|
||||
logger = logging.getLogger("TestFramework.utils")
|
||||
|
||||
@@ -419,6 +421,22 @@ def get_datadir_path(dirname, n):
|
||||
return os.path.join(dirname, "node" + str(n))
|
||||
|
||||
|
||||
def get_temp_default_datadir(temp_dir: pathlib.Path) -> Tuple[dict, pathlib.Path]:
|
||||
"""Return os-specific environment variables that can be set to make the
|
||||
GetDefaultDataDir() function return a datadir path under the provided
|
||||
temp_dir, as well as the complete path it would return."""
|
||||
if sys.platform == "win32":
|
||||
env = dict(APPDATA=str(temp_dir))
|
||||
datadir = temp_dir / "Bitcoin"
|
||||
else:
|
||||
env = dict(HOME=str(temp_dir))
|
||||
if sys.platform == "darwin":
|
||||
datadir = temp_dir / "Library/Application Support/Bitcoin"
|
||||
else:
|
||||
datadir = temp_dir / ".bitcoin"
|
||||
return env, datadir
|
||||
|
||||
|
||||
def append_config(datadir, options):
|
||||
with open(os.path.join(datadir, "bitcoin.conf"), 'a', encoding='utf8') as f:
|
||||
for option in options:
|
||||
|
||||
Reference in New Issue
Block a user