#1075791 python3-dkim: Implement a verbose switch for dkimverify

Package:
python3-dkim
Source:
python3-dkim
Submitter:
Uwe Kleine-König
Date:
2024-07-05 13:51:06 UTC
Severity:
normal
Tags:
#1075791#5
Date:
2024-07-05 07:33:29 UTC
From:
To:
Package: python3-dkim
Version: 1.1.6-1
Severity: wishlist
Tags: upstream patch
X-Debbugs-Cc: ukleinek@debian.org

Hello,

On failure dkimverify just emits a generic oneline description that
there is an error, but no further details. To debug a problem this is
little helpful.

The following patch improves the situation:

From 57d26736af66d67df071afdd9b8cec545b54effd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= <ukleinek@debian.org>
Date: Fri, 5 Jul 2024 09:28:51 +0200
Subject: [PATCH] dkimverify: Implement a --verbose switch

There are already fragments for debug output, this doesn't work though.
`'-v' in sys.argv` is always false because if you pass `-v` the argument
parser exits with an error message.
---
 dkim/dkimverify.py | 5 ++++-
 man/dkimverify.1   | 3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/dkim/dkimverify.py b/dkim/dkimverify.py
index 2ca90d539a44..c2c0291957b6 100644
--- a/dkim/dkimverify.py
+++ b/dkim/dkimverify.py
@@ -34,15 +34,18 @@ def main():
         epilog="message to be verified follows commands on stdin")
     parser.add_argument('--index', metavar='N', type=int, default=0,
         help='Index of DKIM signature header to verify: default=0')
+    parser.add_argument('-v', '--verbose', default=False, action='store_true',
+        help='Add some debugging output')
     args=parser.parse_args()
     if sys.version_info[0] >= 3:
         # Make sys.stdin a binary stream.
         sys.stdin = sys.stdin.detach()

     message = sys.stdin.read()
-    verbose = '-v' in sys.argv
+    verbose = args.verbose
     if verbose:
         import logging
+        logging.basicConfig(level=logging.DEBUG)
         d = dkim.DKIM(message, logger=logging)
     else:
         d = dkim.DKIM(message)
diff --git a/man/dkimverify.1 b/man/dkimverify.1
index 2b13d89f0c99..836eb203664b 100644
--- a/man/dkimverify.1
+++ b/man/dkimverify.1
@@ -142,11 +142,12 @@ code 0 if the signature verifies successfully. Otherwise, it returns with exit
 code 1.

 .SH "USAGE"
-usage: dkimverify.py [\-h] [\-\-index N] <message
+usage: dkimverify.py [\-h] [\-\-index N] [\-\-verbose] <message

 optional arguments:
   \-h, \-\-help  show this help message and exit
   \-\-index N   Index of DKIM signature header to verify: default=0
+  \-\-verbose   Emit diagnostic output

 .SH "AUTHORS"
 This version of \fBdkimverify\fR was written by Greg Hewgill <greg@hewgill.com>.

#1075791#10
Date:
2024-07-05 13:47:50 UTC
From:
To:
...

Thanks.  I've committed this to the upstream repository.  It will be in the
next upstream release.

Scott K