Package: signing-party
Version: 2.12-1
Severity: minor
Tags: patch
X-Debbugs-Cc: uklei...@debian.org

Hello,

when using a dedicated GNUPG_HOMEDIR for the keys of a party's
participants, it's convenient if gpgparticipants-filter emits all keys
when no filter is provided.

The following patch implements this feature:

>From e3d7d888e71643e0c77c6073cca707a4d9c230c0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= <uklei...@debian.org>
Date: Tue, 6 May 2025 19:02:19 +0200
Subject: [PATCH] gpgparticipants-filter: Make filter argument optional

Without arguments default to list all keys which matches the behavior
of `gpg --list-keys`.
---
 gpgparticipants/gpgparticipants-filter   | 22 ++++++++++------------
 gpgparticipants/gpgparticipants-filter.1 |  2 +-
 2 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/gpgparticipants/gpgparticipants-filter 
b/gpgparticipants/gpgparticipants-filter
index 8899a28e2635..5e016dd31b85 100755
--- a/gpgparticipants/gpgparticipants-filter
+++ b/gpgparticipants/gpgparticipants-filter
@@ -79,7 +79,7 @@ class KeyDataSet:
         return self.valid_flag not in ['e', 'r']
 
 
-def filter_to_gpg(filter_string, gpg_bin, set_homedir, homedir):
+def filter_to_gpg(filter_strings, gpg_bin, set_homedir, homedir):
     """
     Call gpg and return output.
     """
@@ -94,7 +94,7 @@ def filter_to_gpg(filter_string, gpg_bin, set_homedir, 
homedir):
         command.append("--homedir")
         command.append(homedir)
 
-    command.append(filter_string)
+    command.extend(filter_strings)
 
     with subprocess.Popen(command, stdout=subprocess.PIPE) as process:
         return process.stdout.readlines()
@@ -151,19 +151,17 @@ if __name__ == "__main__":
                         help='output version information and exit',
                         version="%(prog)s 
{version}".format(version=__version__)
                         )
-    parser.add_argument('filter', type=str, nargs='+', metavar="FILTER",
+    parser.add_argument('filter', type=str, nargs='*', metavar="FILTER",
                         help='input query, which will be passed to gpg (see 
gpg manual)')
 
     args = parser.parse_args()
-    key_data = []
-    for input_string in args.filter:
-        gpg_output = filter_to_gpg(
-            filter_string=input_string,
-            gpg_bin=args.gpg_binary,
-            set_homedir=args.homedir is not None,
-            homedir=args.homedir
-        )
-        key_data += key_data_sets_from(gpg_output)
+    gpg_output = filter_to_gpg(
+        filter_strings=args.filter,
+        gpg_bin=args.gpg_binary,
+        set_homedir=args.homedir is not None,
+        homedir=args.homedir
+    )
+    key_data = key_data_sets_from(gpg_output)
 
     for key in sorted_by_name(key_data):
         if key.is_valid() or args.all_keys:
diff --git a/gpgparticipants/gpgparticipants-filter.1 
b/gpgparticipants/gpgparticipants-filter.1
index ae6dac79e051..5b7288d9a83f 100644
--- a/gpgparticipants/gpgparticipants-filter.1
+++ b/gpgparticipants/gpgparticipants-filter.1
@@ -9,7 +9,7 @@ gpgparticipants-filter \- filters a list of key ids as input to 
gpgparticipants
 [\-d GPG_HOME]
 [\-a]
 [\-\-version]
-FILTER [FILTER ...]
+[FILTER ...]
 .SH DESCRIPTION
 This tool filters a list of key ids from your gpg keyring as input to
 gpgparticipants. It sorts the alphabetically list by the first uid of each

base-commit: 799c0dce0276aa006d28144f6dab634c54d4fb1e
prerequisite-patch-id: 483da042b20850de396e0c3227666400528d88e2

Note that this patch bases on v2.12 + the patch from
Debian bug #1104799.

Best regards
Uwe

-- 
2.47.2

Reply via email to