lbrynet container should always check for mounted wallet volume #55

Closed
opened 2019-04-24 19:43:32 +02:00 by EnigmaCurry · 3 comments
EnigmaCurry commented 2019-04-24 19:43:32 +02:00 (Migrated from github.com)

Issue relevant for 1.0 master branch

This issue may only be relevant for pre 1.0 milestone release of these docker containers please keep this in mind when reading the rest of this issue and it's subsequent conversation.

Description of the problem:

The lbrynet container should never allow the creation of a wallet that is not mounted external to the container, otherwise there is the potential to lose funds.

How to replicate:

$ sudo docker run --rm -it lbrynet-x86_64 lbrynet start --api 127.0.0.1:5279
2019-04-24 17:40:42,686 INFO     lbrynet.extras.daemon.Daemon:395: Starting LBRYNet Daemon
2019-04-24 17:40:42,687 INFO     lbrynet.extras.daemon.Daemon:397: Platform: {
  "processor": "x86_64",
  "python_version": "3.7.1",
  "platform": "Linux-4.19.34-1-MANJARO-x86_64-with-Ubuntu-18.04-bionic",
  "os_release": "4.19.34-1-MANJARO",
  "os_system": "Linux",
  "lbrynet_version": "0.36.0",
  "build": "release",
  "distro": {
    "id": "ubuntu",
    "version": "18.04",
    "version_parts": {
      "major": "18",
      "minor": "04",
      "build_number": ""
    },
    "like": "debian",
    "codename": "bionic"
  },
  "desktop": "Unknown"
}
2019-04-24 17:40:43,123 INFO     lbrynet.extras.daemon.Daemon:404: lbrynet API listening on TCP 127.0.0.1:5279
2019-04-24 17:40:43,269 INFO     lbrynet.extras.daemon.Components:561: detecting external ip
2019-04-24 17:40:43,271 INFO     lbrynet.extras.daemon.Components:78: Loading databases
2019-04-24 17:40:43,272 WARNING  lbrynet.extras.daemon.Components:81: db_revision file not found. Creating it
2019-04-24 17:40:43,273 INFO     torba.client.basedatabase:187: connecting to database: /home/lbrynet/.local/share/lbry/lbrynet/lbrynet.sqlite
2019-04-24 17:40:43,274 INFO     lbrynet.extras.daemon.exchange_rate_manager:212: Starting exchange rate manager
2019-04-24 17:40:43,542 INFO     torba.client.basenetwork:88: Successfully connected to SPV wallet server: lbryumx1.lbry.io:50001
2019-04-24 17:40:43,571 INFO     lbrynet.extras.daemon.Components:194: remote height: 556719, local height: 0
2019-04-24 17:40:48,234 INFO     lbrynet.extras.daemon.Components:160: fetched headers from s3, now verifying integrity after download.
2019-04-24 17:40:58,336 WARNING  lbrynet.extras.daemon.Components:497: upnp discovery failed: M-SEARCH for 172.17.0.1:1900 timed out
2019-04-24 17:40:58,338 WARNING  lbrynet.extras.daemon.Components:511: unable to get external ip from UPnP, checking lbry.io fallback
2019-04-24 17:40:58,455 ERROR    lbrynet.extras.daemon.Components:576: failed to setup upnp
2019-04-24 17:40:58,908 INFO     lbrynet.extras.daemon.Components:340: start the dht
2019-04-24 17:40:58,910 INFO     lbrynet.extras.daemon.Components:365: Started the dht
2019-04-24 17:40:58,910 INFO     lbrynet.extras.daemon.Components:266: Starting torba wallet
2019-04-24 17:40:58,911 INFO     lbrynet.wallet.manager:153: Wallet at /home/lbrynet/.local/share/lbry/lbryum/wallets/default_wallet is empty, generating a default account.

Checklist:

- [] I included a debugpaste link debugpastes only last 90 days from last time they were loaded in a browser.[Inclusion of debugpaste is WIP]

  • [] I made sure there are no duplicates of this report (Use Search)
  • I made sure I am using an up-to-date version of the container.
  • I Made sure the bug/error is not caused by any other application.
  • [] I have updated the wallet address in this issue from the one included to my own as I like getting paid for doing good and fun things in this world such as contributing to LBRY.
<!--- WARNING VERY IMPORTANT COMMENTS TO FOLLOW --> <!--- Please keep in mind that this repository is not production ready yet --> <!--- This means that most functionality is not finalized as of yet. --> <!--- Incomplete reports might be marked as invalid. --> <!--- Please try to stick to a single issue per issue, grave yarding and issue hijacking will be dealt with accordingly. Repeat offenders may be barred from interaction with the repository. --> <!--- Markdown comments like the above can be deleted or left in so long as you include the information they request of you and are followed as best as possible --> <!--- We don't believe in gatekeeping so we want to be as accessible to as many people as possible however our jobs are made significantly easier with quality issue reporting. --> <!--- Do not change the next few lines. --> ## Issue relevant for 1.0 master branch This issue may only be relevant for pre 1.0 milestone release of these docker containers please keep this in mind when reading the rest of this issue and it's subsequent conversation. <!--- From here and below please fill out to the best of your ability leaving the beginning section in tact --> **Description of the problem:** <!--- start with a succinct and clear description of what you were trying to do and what happened instead. Keep in mind that we can't read your mind and you'll increase your odds of getting a successful resolution to your issue. Make sure that you're including the specific container your issue is in regards to and also keep in mind that reporting an application specific bug is to be done on the application specific repositories associated with the application itself not the Docker portion. --> The lbrynet container should never allow the creation of a wallet that is not mounted external to the container, otherwise there is the potential to lose funds. **How to replicate:** <!--- If you can reproduce the issue please tell us as detailed as possible step by step how to do that --> ``` $ sudo docker run --rm -it lbrynet-x86_64 lbrynet start --api 127.0.0.1:5279 2019-04-24 17:40:42,686 INFO lbrynet.extras.daemon.Daemon:395: Starting LBRYNet Daemon 2019-04-24 17:40:42,687 INFO lbrynet.extras.daemon.Daemon:397: Platform: { "processor": "x86_64", "python_version": "3.7.1", "platform": "Linux-4.19.34-1-MANJARO-x86_64-with-Ubuntu-18.04-bionic", "os_release": "4.19.34-1-MANJARO", "os_system": "Linux", "lbrynet_version": "0.36.0", "build": "release", "distro": { "id": "ubuntu", "version": "18.04", "version_parts": { "major": "18", "minor": "04", "build_number": "" }, "like": "debian", "codename": "bionic" }, "desktop": "Unknown" } 2019-04-24 17:40:43,123 INFO lbrynet.extras.daemon.Daemon:404: lbrynet API listening on TCP 127.0.0.1:5279 2019-04-24 17:40:43,269 INFO lbrynet.extras.daemon.Components:561: detecting external ip 2019-04-24 17:40:43,271 INFO lbrynet.extras.daemon.Components:78: Loading databases 2019-04-24 17:40:43,272 WARNING lbrynet.extras.daemon.Components:81: db_revision file not found. Creating it 2019-04-24 17:40:43,273 INFO torba.client.basedatabase:187: connecting to database: /home/lbrynet/.local/share/lbry/lbrynet/lbrynet.sqlite 2019-04-24 17:40:43,274 INFO lbrynet.extras.daemon.exchange_rate_manager:212: Starting exchange rate manager 2019-04-24 17:40:43,542 INFO torba.client.basenetwork:88: Successfully connected to SPV wallet server: lbryumx1.lbry.io:50001 2019-04-24 17:40:43,571 INFO lbrynet.extras.daemon.Components:194: remote height: 556719, local height: 0 2019-04-24 17:40:48,234 INFO lbrynet.extras.daemon.Components:160: fetched headers from s3, now verifying integrity after download. 2019-04-24 17:40:58,336 WARNING lbrynet.extras.daemon.Components:497: upnp discovery failed: M-SEARCH for 172.17.0.1:1900 timed out 2019-04-24 17:40:58,338 WARNING lbrynet.extras.daemon.Components:511: unable to get external ip from UPnP, checking lbry.io fallback 2019-04-24 17:40:58,455 ERROR lbrynet.extras.daemon.Components:576: failed to setup upnp 2019-04-24 17:40:58,908 INFO lbrynet.extras.daemon.Components:340: start the dht 2019-04-24 17:40:58,910 INFO lbrynet.extras.daemon.Components:365: Started the dht 2019-04-24 17:40:58,910 INFO lbrynet.extras.daemon.Components:266: Starting torba wallet 2019-04-24 17:40:58,911 INFO lbrynet.wallet.manager:153: Wallet at /home/lbrynet/.local/share/lbry/lbryum/wallets/default_wallet is empty, generating a default account. ``` **Checklist**: <!-- Make sure you have completed the following steps (put an "X" between of brackets): --> ~~- [] I included a `debugpaste` link debugpastes only last 90 days from last time they were loaded in a browser.[Inclusion of debugpaste is WIP]~~ - [] I made sure there are no duplicates of this report [(Use Search)](https://github.com/lbryio/lbry-docker/issues?utf8=%E2%9C%93&q=is%3Aissue) - [x] I made sure I am using an up-to-date version of the container. - [x] I Made sure the bug/error is not caused by any other application. - [] I have updated the wallet address in this issue from the one included to my own as I like getting paid for doing good and fun things in this world such as contributing to LBRY.
EnigmaCurry commented 2019-04-24 19:57:18 +02:00 (Migrated from github.com)

Now running that same command with a volume makes all the difference:

$ sudo docker run --rm -it -v wallet:/home/lbrynet lbrynet-x86_64 lbrynet start --api 127.0.0.1:5279
2019-04-24 17:52:10,753 INFO     lbrynet.extras.daemon.Daemon:395: Starting LBRYNet Daemon
2019-04-24 17:52:10,754 INFO     lbrynet.extras.daemon.Daemon:397: Platform: {
  "processor": "x86_64",
  "python_version": "3.7.1",
  "platform": "Linux-4.19.34-1-MANJARO-x86_64-with-Ubuntu-18.04-bionic",
  "os_release": "4.19.34-1-MANJARO",
  "os_system": "Linux",
  "lbrynet_version": "0.36.0",
  "build": "release",
  "distro": {
    "id": "ubuntu",
    "version": "18.04",
    "version_parts": {
      "major": "18",
      "minor": "04",
      "build_number": ""
    },
    "like": "debian",
    "codename": "bionic"
  },
  "desktop": "Unknown"
}
2019-04-24 17:52:11,214 INFO     lbrynet.extras.daemon.Daemon:404: lbrynet API listening on TCP 127.0.0.1:5279
2019-04-24 17:52:11,355 INFO     lbrynet.extras.daemon.Components:561: detecting external ip
2019-04-24 17:52:11,466 INFO     lbrynet.extras.daemon.Components:78: Loading databases
2019-04-24 17:52:11,467 INFO     torba.client.basedatabase:187: connecting to database: /home/lbrynet/.local/share/lbry/lbrynet/lbrynet.sqlite
2019-04-24 17:52:11,467 INFO     lbrynet.extras.daemon.exchange_rate_manager:212: Starting exchange rate manager
2019-04-24 17:52:11,542 INFO     torba.client.basenetwork:88: Successfully connected to SPV wallet server: lbryumx1.lbry.io:50001
2019-04-24 17:52:11,582 INFO     lbrynet.extras.daemon.Components:194: remote height: 556721, local height: 556721
2019-04-24 17:52:26,541 WARNING  lbrynet.extras.daemon.Components:497: upnp discovery failed: M-SEARCH for 172.17.0.1:1900 timed out
2019-04-24 17:52:26,542 WARNING  lbrynet.extras.daemon.Components:511: unable to get external ip from UPnP, checking lbry.io fallback
2019-04-24 17:52:26,674 ERROR    lbrynet.extras.daemon.Components:576: failed to setup upnp
2019-04-24 17:52:27,108 INFO     lbrynet.extras.daemon.Components:266: Starting torba wallet
2019-04-24 17:52:27,151 INFO     lbrynet.extras.daemon.Components:340: start the dht
2019-04-24 17:52:27,151 INFO     lbrynet.extras.daemon.Components:365: Started the dht
2019-04-24 17:52:27,152 INFO     torba.client.basedatabase:187: connecting to database: /home/lbrynet/.local/share/lbry/lbryum/lbc_mainnet/blockchain.db
2019-04-24 17:52:27,152 INFO     lbrynet.dht.node:115: DHT node listening on UDP 0.0.0.0:4444
2019-04-24 17:52:27,218 INFO     torba.client.basenetwork:88: Successfully connected to SPV wallet server: lbryumx1.lbry.io:50001
2019-04-24 17:52:27,218 INFO     torba.client.baseledger:247: Subscribing and updating accounts.
2019-04-24 17:52:27,249 INFO     torba.client.baseledger:133: lbc_mainnet: added BlockHeightEvent(height=556722, change=1) header blocks, final height 556722
2019-04-24 17:52:27,414 INFO     lbrynet.wallet.ledger:82: Loaded account baz6tRPQcyZTkfCyaR9jRxUpfvA8QSSZXb with 0.0 LBC, 20 receiving addresses (gap: 20), 6 change addresses (gap: 6), 0 channels, 0 certificates and 0 claims. 

So how to enforce this? I think it can be accomplished through an ENTRYPOINT that checks to see if the directory is mounted, if not it aborts with an error message. If the check succeeds, it passes all of its arguments on to lbrynet. Thus it would always require the directory to be mounted before ever running lbrynet.

#!/bin/bash

mountpoint=/home/lbrynet

if ! grep -qs ".* $mountpoint " /proc/mounts; then
    echo "$mountpoint not mounted, refusing to run."
    exit 1
else
    `$@`
fi
Now running that same command with a volume makes all the difference: ``` $ sudo docker run --rm -it -v wallet:/home/lbrynet lbrynet-x86_64 lbrynet start --api 127.0.0.1:5279 2019-04-24 17:52:10,753 INFO lbrynet.extras.daemon.Daemon:395: Starting LBRYNet Daemon 2019-04-24 17:52:10,754 INFO lbrynet.extras.daemon.Daemon:397: Platform: { "processor": "x86_64", "python_version": "3.7.1", "platform": "Linux-4.19.34-1-MANJARO-x86_64-with-Ubuntu-18.04-bionic", "os_release": "4.19.34-1-MANJARO", "os_system": "Linux", "lbrynet_version": "0.36.0", "build": "release", "distro": { "id": "ubuntu", "version": "18.04", "version_parts": { "major": "18", "minor": "04", "build_number": "" }, "like": "debian", "codename": "bionic" }, "desktop": "Unknown" } 2019-04-24 17:52:11,214 INFO lbrynet.extras.daemon.Daemon:404: lbrynet API listening on TCP 127.0.0.1:5279 2019-04-24 17:52:11,355 INFO lbrynet.extras.daemon.Components:561: detecting external ip 2019-04-24 17:52:11,466 INFO lbrynet.extras.daemon.Components:78: Loading databases 2019-04-24 17:52:11,467 INFO torba.client.basedatabase:187: connecting to database: /home/lbrynet/.local/share/lbry/lbrynet/lbrynet.sqlite 2019-04-24 17:52:11,467 INFO lbrynet.extras.daemon.exchange_rate_manager:212: Starting exchange rate manager 2019-04-24 17:52:11,542 INFO torba.client.basenetwork:88: Successfully connected to SPV wallet server: lbryumx1.lbry.io:50001 2019-04-24 17:52:11,582 INFO lbrynet.extras.daemon.Components:194: remote height: 556721, local height: 556721 2019-04-24 17:52:26,541 WARNING lbrynet.extras.daemon.Components:497: upnp discovery failed: M-SEARCH for 172.17.0.1:1900 timed out 2019-04-24 17:52:26,542 WARNING lbrynet.extras.daemon.Components:511: unable to get external ip from UPnP, checking lbry.io fallback 2019-04-24 17:52:26,674 ERROR lbrynet.extras.daemon.Components:576: failed to setup upnp 2019-04-24 17:52:27,108 INFO lbrynet.extras.daemon.Components:266: Starting torba wallet 2019-04-24 17:52:27,151 INFO lbrynet.extras.daemon.Components:340: start the dht 2019-04-24 17:52:27,151 INFO lbrynet.extras.daemon.Components:365: Started the dht 2019-04-24 17:52:27,152 INFO torba.client.basedatabase:187: connecting to database: /home/lbrynet/.local/share/lbry/lbryum/lbc_mainnet/blockchain.db 2019-04-24 17:52:27,152 INFO lbrynet.dht.node:115: DHT node listening on UDP 0.0.0.0:4444 2019-04-24 17:52:27,218 INFO torba.client.basenetwork:88: Successfully connected to SPV wallet server: lbryumx1.lbry.io:50001 2019-04-24 17:52:27,218 INFO torba.client.baseledger:247: Subscribing and updating accounts. 2019-04-24 17:52:27,249 INFO torba.client.baseledger:133: lbc_mainnet: added BlockHeightEvent(height=556722, change=1) header blocks, final height 556722 2019-04-24 17:52:27,414 INFO lbrynet.wallet.ledger:82: Loaded account baz6tRPQcyZTkfCyaR9jRxUpfvA8QSSZXb with 0.0 LBC, 20 receiving addresses (gap: 20), 6 change addresses (gap: 6), 0 channels, 0 certificates and 0 claims. ``` So how to enforce this? I think it can be accomplished through an ENTRYPOINT that checks to see if the directory is mounted, if not it aborts with an error message. If the check succeeds, it passes all of its arguments on to lbrynet. Thus it would always require the directory to be mounted before ever running lbrynet. ``` #!/bin/bash mountpoint=/home/lbrynet if ! grep -qs ".* $mountpoint " /proc/mounts; then echo "$mountpoint not mounted, refusing to run." exit 1 else `$@` fi ```
Leopere commented 2019-04-26 01:30:56 +02:00 (Migrated from github.com)

This feature's value add will be tremendous as it will help increase the likelihood of someone not just nuking their wallets when they upgrade a container.

This feature's value add will be tremendous as it will help increase the likelihood of someone not just nuking their wallets when they upgrade a container.
EnigmaCurry commented 2019-04-26 01:36:43 +02:00 (Migrated from github.com)

Fixed in #56

Fixed in #56
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: LBRYCommunity/lbry-docker#55
No description provided.