aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2021-10-04 16:08:21 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2021-10-04 16:08:21 -0400
commitd2128a8865db4544370599221edf231fab971999 (patch)
treeb7990629aee63aa1a97d1d6652bcf3bde00f0072
parenta7653256be70d99c9f6749bf5872d2fb984ddc22 (diff)
downloadpatatt-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__.py6
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')