-
Notifications
You must be signed in to change notification settings - Fork 649
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
CLI wallet: avoid directly overwriting wallet file on exit #1109 #1195
Conversation
The logic looks fine, although naming new file as ".backup" is not so good. |
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.
AFAICS fc::ofstream does not throw nor otherwise communicate failure on write(), flush() or close().
we should create another issue for fc::ofstream IMHO |
It means we need to make sure the new (tmp) file is good before calling |
9fa9461
to
db840c8
Compare
review lost commits, now checking |
libraries/wallet/wallet.cpp
Outdated
} | ||
else | ||
{ | ||
disable_umask_protection(); |
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.
This is not necessary, because it already happens in the outer try/catch.
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.
Why it is not necessary ? I've tested & checked it and we won't get into outer try/catch code after throwing exception here that's why I've placed disable_umask_protection
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.
Using throw without specifying an exception is only allowed in a catch clause, otherwise it will terminate instead of actually throwing, see below.
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.
yes, you're absolutely right ! I've checked it earlier, that's why I told you that disable_umask_protection
is necessary there before using throw
, if I will change throw
to fc::exception
subtype then I will remove disable_umask_protection
call. Just couldn't understand why you told that disable_umask_protection
isn't necessary before using throw
.
libraries/wallet/wallet.cpp
Outdated
else | ||
{ | ||
disable_umask_protection(); | ||
throw; |
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.
Please throw an fc::exception subtype with an appropriate error message.
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.
Then we also need to throw fc::exception
subtype in outer try/catch block ? right ?
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.
no, the outer catch should re-throw whatever it caught.
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.
yes sure, already done without any changes in outer try/catch block
4716300
to
0e86f4a
Compare
rebased already |
Travis-CI complains:
|
Perhaps the Travis-CI environment has different |
going to check ... Thanks ! |
I'm playing https://github.com/bitshares/bitshares-core/blob/travis-test1/.travis.yml to check if it's related to disk space. |
wow ! Thanks a lot ! I'm appreciate all your efforts ! |
Not a disk space issue.
|
|
Question: If saving fails, should the error message contain the JSON representing the wallet file? That might give the user another chance to save the data in an emergency situation, perhaps by screen-scraping it. |
@pmconrad makes sense. |
Wallet file contains no secret. No password, no plain private key. |
just for the info wallet file contains next info:
so no secret is here, just encrypted keys and empty
|
but what about |
in my case |
I'd say, remove the password before dumping. |
libraries/wallet/wallet.cpp
Outdated
_wallet.ws_password = ""; | ||
wlog("wallet file ${data}", ("data", fc::json::to_pretty_string( _wallet ) ) ); | ||
_wallet.ws_password = ws_password; | ||
if (&_wallet != nullptr) |
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.
&_wallet can never be null. It's a struct member of *this.
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.
it fixed travis error with violation memory access in cli_test as was before, strange behavior of travis that's why I've added this check
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.
The travis error is unrelated, please undo this change.
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.
ok sure
…ss violation in cli_test
909f0bc
to
d0c7a94
Compare
This is still not ready yet. Pushing to next release. |
can we merge this PR and close related issue ? or this is not still ready and need some changes and improvements ? if YES, then which changes and improvements in your opinion ? Thanks ! |
Thanks! |
PR for #1109