rnpgp / rnp

RNP: high performance C++ OpenPGP library used by Mozilla Thunderbird
https://www.rnpgp.org
Other
194 stars 55 forks source link

rnp prompts for input and reads from stdin when it should prefer /dev/tty #572

Closed dewyatt closed 4 years ago

dewyatt commented 6 years ago

Description

I believe things like this should try to read from /dev/tty if avail, and stdin otherwise: https://github.com/riboseinc/rnp/blob/7bafcf181962c12075e92d64b12ca377e91c37ff/src/lib/rnp.c#L1225

See rnp_getpass for an example or ttyio.c from GnuPG for a more complete solution.

On the output side (https://github.com/riboseinc/rnp/issues/542), things like this should output to stderr or /dev/tty: https://github.com/riboseinc/rnp/blob/7bafcf181962c12075e92d64b12ca377e91c37ff/src/lib/rnp.c#L1224

Steps to Reproduce

  1. touch out.gpg
  2. echo test | src/rnp/rnp --sign --output=out.gpg

Expected Behavior

It should warn about the overwrite and prompt for a filename, then proceed.

Actual Behavior

It prompts for a filename but the user does not get a chance to input it since it tries to read from the pipe.

ni4 commented 6 years ago

@dewyatt Agree, actually we also should move all such code parts to CLI level, so input from user will be handled by CLI not library.