Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

[develop] <wallet_plugin> Preemptively create the wallet directory to prevent exception #8490

Merged
merged 3 commits into from
Feb 28, 2020

Conversation

johndebord
Copy link
Contributor

@johndebord johndebord commented Jan 22, 2020

Preemptively create the wallet directory before set_dir is called (which erroneously attempts to lock the file wallet.lock in a non-existent directory). This change eliminates the problem of requiring that the user must explicitly create the directory before using keosd.


Valid behavior using the current directory as a relative path [release/2.0.x]:

~/2eoss/releases/2.0.x/build/bin $ tree
.
├── cleos
├── eosio-blocklog
├── keosd
└── nodeos

0 directories, 4 files
~/2eoss/releases/2.0.x/build/bin $ ./keosd --data-dir ./ --config-dir ./ --wallet-dir ./&
[keosd] 13443
~/2eoss/releases/2.0.x/build/bin $ info  2020-01-22T22:43:14.663 thread-0  wallet_plugin.cpp:38          plugin_initialize    ] initializing wallet plugin
warn  2020-01-22T22:43:14.665 thread-0  se_wallet.cpp:279             check_signed         ] Application does not have a valid signature; Secure Enclave support disabled
info  2020-01-22T22:43:14.666 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/node/get_supported_apis
info  2020-01-22T22:43:14.666 thread-0  wallet_api_plugin.cpp:69      plugin_startup       ] starting wallet_api_plugin
info  2020-01-22T22:43:14.666 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/create
info  2020-01-22T22:43:14.666 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/create_key
info  2020-01-22T22:43:14.666 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/get_public_keys
info  2020-01-22T22:43:14.666 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/import_key
info  2020-01-22T22:43:14.670 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/list_keys
info  2020-01-22T22:43:14.670 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/list_wallets
info  2020-01-22T22:43:14.670 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/lock
info  2020-01-22T22:43:14.670 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/lock_all
info  2020-01-22T22:43:14.670 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/open
info  2020-01-22T22:43:14.670 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/remove_key
info  2020-01-22T22:43:14.670 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/set_timeout
info  2020-01-22T22:43:14.686 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/sign_digest
info  2020-01-22T22:43:14.686 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/sign_transaction
info  2020-01-22T22:43:14.686 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/unlock

~/2eoss/releases/2.0.x/build/bin $ tree
.
├── cleos
├── config.ini
├── eosio-blocklog
├── keosd
├── keosd.sock
├── nodeos
└── wallet.lock

0 directories, 7 files
~/2eoss/releases/2.0.x/build/bin $ killall keosd
~/2eoss/releases/2.0.x/build/bin $ tree
.
├── cleos
├── config.ini
├── eosio-blocklog
├── keosd
└── nodeos

0 directories, 5 files
~/2eoss/releases/2.0.x/build/bin $ 

Erroneous behavior using new directories as relative paths [release/2.0.x]:

~/2eoss/releases/2.0.x/build/bin $ tree
.
├── cleos
├── eosio-blocklog
├── keosd
└── nodeos

0 directories, 4 files
~/2eoss/releases/2.0.x/build/bin $ ./keosd --data-dir ./data-dir --config-dir ./config-dir --wallet-dir ./wallet-dir&
[keosd] 13459
~/2eoss/releases/2.0.x/build/bin $ info  2020-01-22T22:44:31.290 thread-0  wallet_plugin.cpp:38          plugin_initialize    ] initializing wallet plugin
warn  2020-01-22T22:44:31.291 thread-0  se_wallet.cpp:279             check_signed         ] Application does not have a valid signature; Secure Enclave support disabled
warn  2020-01-22T22:44:31.292 thread-0  wallet_plugin.cpp:64          plugin_initialize    ] 3120000 wallet_exception: Wallet exception
Failed to open wallet lock file at /Users/john.debord/2eoss/releases/2.0.x/build/bin/./data-dir/./wallet-dir/wallet.lock
    {"f":"/Users/john.debord/2eoss/releases/2.0.x/build/bin/./data-dir/./wallet-dir/wallet.lock"}
    thread-0  wallet_manager.cpp:299 initialize_lock
Failed to initialize

~/2eoss/releases/2.0.x/build/bin $ tree
.
├── cleos
├── config-dir
│   └── config.ini
├── eosio-blocklog
├── keosd
└── nodeos

1 directory, 5 files
~/2eoss/releases/2.0.x/build/bin $ killall keosd
No matching processes belonging to you were found
~/2eoss/releases/2.0.x/build/bin $ 

Valid behavior using the current directory as a relative path [preemptive-wallet-dir-creation]:

~/2eoss/experimental/build/bin $ tree
.
├── cleos
├── eosio-blocklog
├── keosd
└── nodeos

0 directories, 4 files
~/2eoss/experimental/build/bin $ ./keosd --data-dir ./ --config-dir ./ --wallet-dir ./&
[keosd] 13569
~/2eoss/experimental/build/bin $ info  2020-01-22T22:48:39.647 thread-0  wallet_plugin.cpp:38          plugin_initialize    ] initializing wallet plugin
warn  2020-01-22T22:48:39.649 thread-0  se_wallet.cpp:279             check_signed         ] Application does not have a valid signature; Secure Enclave support disabled
info  2020-01-22T22:48:39.650 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/node/get_supported_apis
info  2020-01-22T22:48:39.650 thread-0  wallet_api_plugin.cpp:69      plugin_startup       ] starting wallet_api_plugin
info  2020-01-22T22:48:39.650 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/create
info  2020-01-22T22:48:39.650 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/create_key
info  2020-01-22T22:48:39.650 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/get_public_keys
info  2020-01-22T22:48:39.650 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/import_key
info  2020-01-22T22:48:39.651 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/list_keys
info  2020-01-22T22:48:39.688 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/list_wallets
info  2020-01-22T22:48:39.688 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/lock
info  2020-01-22T22:48:39.688 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/lock_all
info  2020-01-22T22:48:39.688 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/open
info  2020-01-22T22:48:39.688 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/remove_key
info  2020-01-22T22:48:39.688 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/set_timeout
info  2020-01-22T22:48:39.688 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/sign_digest
info  2020-01-22T22:48:39.729 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/sign_transaction
info  2020-01-22T22:48:39.729 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/unlock

~/2eoss/experimental/build/bin $ tree
.
├── cleos
├── config.ini
├── eosio-blocklog
├── keosd
├── keosd.sock
├── nodeos
└── wallet.lock

0 directories, 7 files
~/2eoss/experimental/build/bin $ killall keosd
~/2eoss/experimental/build/bin $ tree
.
├── cleos
├── config.ini
├── eosio-blocklog
├── keosd
└── nodeos

0 directories, 5 files
~/2eoss/experimental/build/bin $ 

Valid behavior using new directories as relative paths [preemptive-wallet-dir-creation]:

~/2eoss/experimental/build/bin $ tree
.
├── cleos
├── eosio-blocklog
├── keosd
└── nodeos

0 directories, 4 files
~/2eoss/experimental/build/bin $ ./keosd --data-dir ./data-dir --config-dir ./config-dir --wallet-dir ./wallet-dir&
[keosd] 13588
~/2eoss/experimental/build/bin $ info  2020-01-22T22:50:28.155 thread-0  wallet_plugin.cpp:38          plugin_initialize    ] initializing wallet plugin
warn  2020-01-22T22:50:28.157 thread-0  se_wallet.cpp:279             check_signed         ] Application does not have a valid signature; Secure Enclave support disabled
info  2020-01-22T22:50:28.158 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/node/get_supported_apis
info  2020-01-22T22:50:28.159 thread-0  wallet_api_plugin.cpp:69      plugin_startup       ] starting wallet_api_plugin
info  2020-01-22T22:50:28.159 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/create
info  2020-01-22T22:50:28.159 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/create_key
info  2020-01-22T22:50:28.159 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/get_public_keys
info  2020-01-22T22:50:28.159 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/import_key
info  2020-01-22T22:50:28.159 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/list_keys
info  2020-01-22T22:50:28.190 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/list_wallets
info  2020-01-22T22:50:28.190 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/lock
info  2020-01-22T22:50:28.190 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/lock_all
info  2020-01-22T22:50:28.190 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/open
info  2020-01-22T22:50:28.190 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/remove_key
info  2020-01-22T22:50:28.190 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/set_timeout
info  2020-01-22T22:50:28.190 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/sign_digest
info  2020-01-22T22:50:28.224 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/sign_transaction
info  2020-01-22T22:50:28.224 thread-0  http_plugin.cpp:697           add_handler          ] add api url: /v1/wallet/unlock

~/2eoss/experimental/build/bin $ tree
.
├── cleos
├── config-dir
│   └── config.ini
├── data-dir
│   ├── keosd.sock
│   └── wallet-dir
│       └── wallet.lock
├── eosio-blocklog
├── keosd
└── nodeos

3 directories, 7 files
~/2eoss/experimental/build/bin $ killall keosd
~/2eoss/experimental/build/bin $ tree
.
├── cleos
├── config-dir
│   └── config.ini
├── data-dir
│   └── wallet-dir
├── eosio-blocklog
├── keosd
└── nodeos

3 directories, 5 files
~/2eoss/experimental/build/bin $ 

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants