bitcoind writes files to current working dir instead of default data dir when access to other data dir in bitcoin.conf is not permitted #12011

issue philippgille opened this issue on December 24, 2017
  1. philippgille commented at 6:10 PM on December 24, 2017: none

    Description

    I compiled bitcoin from source (tag v0.15.1), created a bitcoin.conf in /home/myuser/.bitcoin and in the configuration file I unintentionally configured a datadir directory didn't exist and whose parent directory ownership was set to root:root because I previously had to mount it with sudo.

    When running bitcoind -printtoconsole an error message was shown similar to #11825, basically saying that bitcoind didn't have permissions for the configured directory.

    Now instead of writing the files (blocks and chainstate directories, as well as the files db.log, debug.log, fee_estimates.dat, .lock and wallet.dat) to the default data directory (/home/myuser/.bitcoin), the files were written to the current working directory.

    I'd expect the files to be written to the default datadir if the configured datadir doesn't have the correct permissions.

    Further info

    bitcoin.conf:

    rpcuser=<redacted>
    rpcpassword=<redacted>
    datadir=/mnt/path/to/bitcoin
    txindex=1
    

    Output when running bitcoind -printtoconsole while the configured datadir has the wrong permissions (the many newlines are part of the actual output):

    myuser@myhost:~/some/path$ bitcoind -printtoconsole
    2017-12-24 18:05:29
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    2017-12-24 18:05:29 Bitcoin version v0.15.1
    2017-12-24 18:05:29 InitParameterInteraction: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1
    2017-12-24 18:05:29 Assuming ancestors of block 0000000000000000003b9ce759c2a087d52abc4266f8f4ebd6d768b89defa50a have valid signatures.
    2017-12-24 18:05:29 Setting nMinimumChainWork=000000000000000000000000000000000000000000723d3581fe1bd55373540a
    2017-12-24 18:05:29 Using the 'standard' SHA256 implementation
    2017-12-24 18:05:29 Using RdRand as an additional entropy source
    2017-12-24 18:05:29 Default data directory /home/myuser/.bitcoin
    2017-12-24 18:05:29 Using data directory
    2017-12-24 18:05:29 Using config file bitcoin.conf
    2017-12-24 18:05:29 Using at most 125 automatic connections (1024 file descriptors available)
    2017-12-24 18:05:29 Using 16 MiB out of 32/2 requested for signature cache, able to store 524288 elements
    2017-12-24 18:05:29 Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements
    2017-12-24 18:05:29 Using 4 threads for script verification
    2017-12-24 18:05:29 scheduler thread start
    2017-12-24 18:05:29 HTTP: creating work queue of depth 16
    2017-12-24 18:05:29 Config options rpcuser and rpcpassword will soon be deprecated. Locally-run instances may remove rpcuser to use cookie-based auth, or may be replaced with rpcauth. Please see share/rpcuser for rpcauth auth generation.
    2017-12-24 18:05:29 HTTP: starting 4 worker threads
    2017-12-24 18:05:29 init message: Verifying wallet(s)...
    2017-12-24 18:05:29 Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
    2017-12-24 18:05:29 Using wallet wallet.dat
    2017-12-24 18:05:29 CDBEnv::Open: LogDir=database ErrorFile=db.log
    2017-12-24 18:05:29 Cache configuration:
    2017-12-24 18:05:29 * Using 56.2MiB for block index database
    2017-12-24 18:05:29 * Using 8.0MiB for chain state database
    2017-12-24 18:05:29 * Using 385.8MiB for in-memory UTXO set (plus up to 286.1MiB of unused mempool space)
    2017-12-24 18:05:29 init message: Loading block index...
    2017-12-24 18:05:29 Opening LevelDB in blocks/index
    2017-12-24 18:05:29 Opened LevelDB successfully
    2017-12-24 18:05:29 Using obfuscation key for blocks/index: 0000000000000000
    2017-12-24 18:05:29 LoadBlockIndexDB: last block file = 0
    2017-12-24 18:05:29 LoadBlockIndexDB: last block file info: CBlockFileInfo(blocks=0, size=0, heights=0...0, time=1970-01-01...1970-01-01)
    2017-12-24 18:05:29 Checking all blk files are present...
    2017-12-24 18:05:29 LoadBlockIndexDB: transaction index enabled
    2017-12-24 18:05:29 Initializing databases...
    2017-12-24 18:05:29 Opening LevelDB in chainstate
    2017-12-24 18:05:29 Opened LevelDB successfully
    2017-12-24 18:05:29 Using obfuscation key for chainstate: <redacted>
    2017-12-24 18:05:29 init message: Rewinding blocks...
    2017-12-24 18:05:29  block index               9ms
    2017-12-24 18:05:29 init message: Loading wallet...
    2017-12-24 18:05:29 nFileVersion = 150100
    2017-12-24 18:05:29 Keys: 2002 plaintext, 0 encrypted, 2002 w/ metadata, 2002 total
    2017-12-24 18:05:29  wallet                   58ms
    2017-12-24 18:05:29 setKeyPool.size() = 2000
    2017-12-24 18:05:29 mapWallet.size() = 0
    2017-12-24 18:05:29 mapAddressBook.size() = 1
    2017-12-24 18:05:29
    
    ************************
    EXCEPTION: N5boost10filesystem16filesystem_errorE
    boost::filesystem::space: Operation not permitted
    bitcoin in AppInit()
    
    
    
    ************************
    EXCEPTION: N5boost10filesystem16filesystem_errorE
    boost::filesystem::space: Operation not permitted
    bitcoin in AppInit()
    
    2017-12-24 18:05:29 scheduler thread interrupt
    2017-12-24 18:05:29 Shutdown: In progress...
    2017-12-24 18:05:29 *** System error while flushing: boost::filesystem::space: Operation not permitted
    2017-12-24 18:05:29 Error: Error: A fatal internal error occurred, see debug.log for details
    Error: Error: A fatal internal error occurred, see debug.log for details
    2017-12-24 18:05:29 *** System error while flushing: boost::filesystem::space: Operation not permitted
    2017-12-24 18:05:29 Error: Error: A fatal internal error occurred, see debug.log for details
    Error: Error: A fatal internal error occurred, see debug.log for details
    2017-12-24 18:05:29 Shutdown: done
    
  2. jnewbery commented at 5:07 PM on April 2, 2018: member

    I can't reproduce this. When I configure datadir to be a directory that I don't have permissions for, I see the same exceptions as you:

    2018-04-02T17:01:29Z 
    
    ************************
    EXCEPTION: N5boost10filesystem16filesystem_errorE       
    boost::filesystem::create_directory: Permission denied: "/home/ubuntu/fakebitcoin/blocks"       
    bitcoin in AppInit()       
    
    
    
    ************************
    EXCEPTION: N5boost10filesystem16filesystem_errorE       
    boost::filesystem::create_directory: Permission denied: "/home/ubuntu/fakebitcoin/blocks"       
    bitcoin in AppInit()       
    
    2018-04-02T17:01:29Z Shutdown: In progress...
    2018-04-02T17:01:29Z DeleteAuthCookie: Unable to remove random auth cookie file: boost::filesystem::create_directory: Permission denied: "/home/ubuntu/fakebitcoin/regtest"
    2018-04-02T17:01:29Z Shutdown: Unable to remove pidfile: boost::filesystem::remove: Permission denied: "/home/ubuntu/fakebitcoin/regtest/bitcoind.pid"
    2018-04-02T17:01:29Z Shutdown: done
    

    However, I don't see any of the files you see in my local directory (and I can't really see how they would be - the boost::filesystem::space: Operation not permitted error happens before AppInitMain, so I don't see how those files could have been written).

    A couple of questions:

    • are you sure those files weren't sitting around from before?
    • are you still able to reproduce this? Are you able to reproduce on v0.16?
  3. fanquake closed this on Sep 6, 2018

  4. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 18:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me