diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2021-10-04 16:08:21 -0400 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2021-10-04 16:08:21 -0400 |
commit | d2128a8865db4544370599221edf231fab971999 (patch) | |
tree | b7990629aee63aa1a97d1d6652bcf3bde00f0072 | |
parent | a7653256be70d99c9f6749bf5872d2fb984ddc22 (diff) | |
download | patatt-d2128a8865db4544370599221edf231fab971999.tar.gz |
Always prefer files passed as params
When we receive both a stdin and the list of files, prefer the files
passed as params.
Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Link: https://lore.kernel.org/20211004194521.e2syd25qzrgn5mzg@meerkat.local/
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r-- | patatt/__init__.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/patatt/__init__.py b/patatt/__init__.py index 41b7dfd..6789151 100644 --- a/patatt/__init__.py +++ b/patatt/__init__.py @@ -811,14 +811,14 @@ def get_public_key(source: str, keytype: str, identity: str, selector: str) -> T def _load_messages(cmdargs) -> dict: import sys - if not sys.stdin.isatty(): - messages = {'-': sys.stdin.buffer.read()} - elif len(cmdargs.msgfile): + if len(cmdargs.msgfile): # Load all message from the files passed to make sure they all parse correctly messages = dict() for msgfile in cmdargs.msgfile: with open(msgfile, 'rb') as fh: messages[msgfile] = fh.read() + elif not sys.stdin.isatty(): + messages = {'-': sys.stdin.buffer.read()} else: logger.critical('E: Pipe a message to sign or pass filenames with individual messages') raise RuntimeError('Nothing to do') |