From f944f14d8b53c483c4538cf0f985308e187f43c3 Mon Sep 17 00:00:00 2001 From: Georg Pfuetzenreuter Date: Fri, 15 May 2026 23:56:26 +0200 Subject: [PATCH 1/2] fix: strip stdin When piping tools such as openssl or pwgen into "saltstack-age enc", the encrypted value would contain a trailing newline, causing unexpected results in Salt states interpreting the pillar values. Signed-off-by: Georg Pfuetzenreuter --- src/saltstack_age/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/saltstack_age/cli.py b/src/saltstack_age/cli.py index 6f445d4..7d34761 100644 --- a/src/saltstack_age/cli.py +++ b/src/saltstack_age/cli.py @@ -149,7 +149,7 @@ def get_recipients(arguments: Namespace) -> list[pyrage.x25519.Recipient]: def get_value(arguments: Namespace) -> str: - return arguments.value or sys.stdin.read() + return arguments.value or sys.stdin.read().rstrip() def determine_encryption_type( From 81c25e3cca87a46005c9a8d916c038aab75047a0 Mon Sep 17 00:00:00 2001 From: Georg Pfuetzenreuter Date: Sat, 16 May 2026 00:04:10 +0200 Subject: [PATCH 2/2] fix: gracefully handle interrupt When deciding not to proceed with the encryption from stdin, avoid a traceback upon Ctrl+C. Signed-off-by: Georg Pfuetzenreuter --- src/saltstack_age/cli.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/saltstack_age/cli.py b/src/saltstack_age/cli.py index 7d34761..2879b33 100644 --- a/src/saltstack_age/cli.py +++ b/src/saltstack_age/cli.py @@ -149,7 +149,10 @@ def get_recipients(arguments: Namespace) -> list[pyrage.x25519.Recipient]: def get_value(arguments: Namespace) -> str: - return arguments.value or sys.stdin.read().rstrip() + try: + return arguments.value or sys.stdin.read().rstrip() + except KeyboardInterrupt as exc: + raise SystemExit(-1) from exc def determine_encryption_type(