Bug #4579
closedgetpass is obsolete
50%
Description
ndnsec uses getpass
.
getpass(3) manpage says:
This function is obsolete. Do not use it. If you want to read input without terminal echoing enabled, see the description of the ECHO flag in termios(3).
Updated by Junxiao Shi over 6 years ago
- Related to Bug #4157: ndnsec-export: confusing error message when getpass is unavailable added
Updated by Junxiao Shi over 6 years ago
- Status changed from New to In Progress
- Assignee set to Junxiao Shi
- Estimated time set to 3.00 h
I'll give it a try in hope of solving #4379-8 passphrase issue.
Updated by Davide Pesavento over 6 years ago
This is one of those deprecation warnings that stay there forever. Rolling our own version of getpass
is non-trivial and requires some rather low-level handling of signals and the terminal. It's considered obsolete because it is not thread-safe and it manipulates global signal state, and we don't really care about thread safety in ndnsec
.
Therefore I think this is a non-issue and should be rejected. We'll reconsider it when getpass
really gets removed (if it ever happens).
Updated by Junxiao Shi over 6 years ago
- % Done changed from 0 to 50
https://gerrit.named-data.net/4677 patchset2 has the solution but no unit tests yet.
I manually tested on Ubuntu 14.04.
The following works:
- When running in a console, there's no echo when operator types in a password.
- Empty password is rejected.
- When confirmation is requested, mismatched inputs are rejected.
- When calling from a script, passwords can be provided via stdin. This is essential for NFD integration tests.
The following does not work properly:
When input is longer than buffer size (currently 255 excluding NUL),
std::cin.getline
picks up enough characters for the first input, and the second input picks up the rest and newline character, so the confirmation step seems incorrect.vagrant@m0212:~/ndn-cxx-dev$ build/bin/ndnsec export /id1 Passphrase for the private key: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA Passphrase for the private key: Confirm: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA Passphrase for the private key: Confirm:
I do not have macOS box for testing, but I saw macOS also has termios API.
Updated by Junxiao Shi over 6 years ago
I think this is a non-issue
How else do you propose to solve #4379-8, and other use cases where it's necessary to export/import a private key from scripting?
Updated by Davide Pesavento over 6 years ago
Junxiao Shi wrote:
I think this is a non-issue
How else do you propose to solve #4379-8, and other use cases where it's necessary to export/import a private key from scripting?
I don't understand how that is related to getpass
being obsolete. Please elaborate.
Updated by Davide Pesavento over 6 years ago
Junxiao Shi wrote:
- Empty password is rejected.
Why? It should be up to the caller to decide whether empty secrets are accepted or not.
- When calling from a script, passwords can be provided via stdin. This is essential for NFD integration tests.
Whether you're running a script or not is irrelevant. What is important is whether the sessions is interactive or not, or whether stdin is connected to a tty.
- When input is longer than buffer size (currently 255 excluding NUL),
std::cin.getline
picks up enough characters for the first input, and the second input picks up the rest and newline character, so the confirmation step seems incorrect.
I don't understand this sentence.
Updated by Junxiao Shi over 6 years ago
I'm pointed out that reading password from stdin would not work with ndnsec-import -
(reading SafeBag from stdin). I'm thinking about a solution.
Updated by Davide Pesavento over 6 years ago
Junxiao Shi wrote:
I'm pointed out that reading password from stdin would not work with
ndnsec-import -
(reading SafeBag from stdin). I'm thinking about a solution.
I already (verbally) suggested a solution: add a command-line option. Alex suggested the exact same thing during yesterday's call. We also both agreed that this has nothing to do with getpass
being obsolete.
Updated by Junxiao Shi over 6 years ago
- Status changed from In Progress to Rejected
I'm pointed out that reading password from stdin would not work with
ndnsec-import -
(reading SafeBag from stdin). I'm thinking about a solution.I already suggested a solution: add a command-line option.
I'll create another issue for that.