Skip to contentSkip to conversation

A random collection of patches to export-keyring

PATCH Applied Uwe Kleine-König 2 participants 6 messages Jun 13, 2025

lore
Share & tools
lore
#0 lore raw

v2 cover A random collection of patches to export-keyring

Hello,

the only change since (implicit) v1 (available at
https://lore.kernel.org/tools/ef678713de0a9aec1c1f07d92faa29e1f5b5e4e5.1749804735.git.u.kleine-koenig@baylibre.com
) is that I added an S-o-b line for me (thanks git rebase --signoff!) now that there is a DCO document for wotmate.

Best regards
Uwe

Uwe Kleine-König (4):
export-keyring: Skip graph generation if the trust path didn't change
export-keyring: Improve logging
export-keyring: Add cmdline option --verbose
export-keyring: Add an option to ignore the linter check

 export-keyring.py   | 28 +++++++++++++++++++---------
 wotmate/__init__.py |  4 ++--
 2 files changed, 21 insertions(+), 11 deletions(-)

base-commit: b2ea16b5c4d9b283151fd5ec512cd624bba3d82c

Signature · 1 line
2.49.0
#1 lore raw

PATCH v2 1/4 export-keyring: Skip graph generation if the trust path didn't change

It can happen that a key changes without affecting the trust paths. That might be a new (or expired) subkey or a new signature that doesn't matter for the trust paths. So always compare the trust txt file with the new paths to prevent noop changes in the svg representation.

---
 export-keyring.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
export-keyring.py +3 -4
index e6550f8ba429..686c77cabb16 100755
@@ -146,16 +146,15 @@ if __name__ == '__main__':
         key_paths_repr = kpblock.encode()
 
         txtgraphout = os.path.join(graphdir, "%s.txt" % kid)
-        trust_changed = key_changed
         if not os.path.exists(txtgraphout):
             logger.debug('Forcing generation of the text graph for %s', kid)
             trust_changed = True
-        elif not key_changed:
+        else:
             # Load it up and see if trust relationships changed
             with open(txtgraphout, 'rb') as fin:
                 old_key_paths_repr = fin.read()
-                if key_paths_repr != old_key_paths_repr:
-                    trust_changed = True
+                trust_changed = (key_paths_repr != old_key_paths_repr)
+                if trust_changed:
                     logger.debug('Trust changes detected for %s', kid)
 
         if not (key_changed or trust_changed):
Signature · 1 line
2.49.0
#2 lore raw

PATCH v2 2/4 export-keyring: Improve logging

In reply to Uwe Kleine-König

Issue message about not updating a key at info level and add another helpful debug message.

---
 export-keyring.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
export-keyring.py +3 -1
index 686c77cabb16..23736f610c79 100755
@@ -133,7 +133,7 @@ if __name__ == '__main__':
             if key_already_exists:
                 logger.debug('%s has an to invalid WoT, but already exists, so still update it', kid)
             else:
-                logger.debug('Skipping %s due to invalid WoT', kid)
+                logger.info('Skipping %s due to invalid WoT', kid)
                 continue
 
         kpblock = ''
@@ -157,6 +157,8 @@ if __name__ == '__main__':
                 if trust_changed:
                     logger.debug('Trust changes detected for %s', kid)
 
+        logger.debug(f'{kid} {key_changed=} {trust_changed=} {key_already_exists=} {len(key_paths)=}')
+
         if not (key_changed or trust_changed):
             logger.debug('No changes detected for %s', kid)
             continue
Signature · 1 line
2.49.0
#3 lore raw

PATCH v2 3/4 export-keyring: Add cmdline option --verbose

In reply to Uwe Kleine-König

This enables emitting log messages at debug level.

---
 export-keyring.py   | 5 ++++-
 wotmate/__init__.py | 4 ++--
 2 files changed, 6 insertions(+), 3 deletions(-)
export-keyring.py +4 -1
index 23736f610c79..14d190c83db1 100755
@@ -28,6 +28,9 @@ if __name__ == '__main__':
     ap.add_argument('--quiet', action='store_true',
                     default=False,
                     help='Be quiet and only output errors')
+    ap.add_argument('--verbose', action='store_true',
+                    default=False,
+                    help='emit extra logging')
     ap.add_argument('--fromkey',
                     help='Top key ID (if omitted, will use the key with ultimate trust)')
     ap.add_argument('--maxdepth', default=4, type=int,
@@ -69,7 +72,7 @@ if __name__ == '__main__':
     if cmdargs.gpgbin:
         wotmate.GPGBIN = cmdargs.gpgbin
 
-    logger = wotmate.get_logger(cmdargs.quiet)
+    logger = wotmate.get_logger(cmdargs.quiet, cmdargs.verbose)
 
     dbconn = sqlite3.connect(cmdargs.dbfile)
     c = dbconn.cursor()
wotmate/__init__.py +2 -2
index 8724931a8005..c88a209e1d59 100644
@@ -48,14 +48,14 @@ def get_uiddata_by_pubrow(c: sqlite3.Cursor, p_rowid: int):
     return get_pub_uid_by_pubrow(c, p_rowid)[1]
 
 
-def get_logger(quiet: bool = False) -> logging.Logger:
+def get_logger(quiet: bool = False, verbose: bool = False) -> logging.Logger:
     logger.setLevel(logging.DEBUG)
     ch = logging.StreamHandler()
     formatter = logging.Formatter('%(message)s')
     ch.setFormatter(formatter)
     if quiet:
         ch.setLevel(logging.CRITICAL)
-    else:
+    elif not verbose:
         ch.setLevel(logging.INFO)
 
     logger.addHandler(ch)
Signature · 1 line
2.49.0
#4 lore raw

PATCH v2 4/4 export-keyring: Add an option to ignore the linter check

In reply to Uwe Kleine-König

This is sensible to use in certain limited cases. One of these is to force certificates that don't pass the linter check to be cleaned.

---
 export-keyring.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
export-keyring.py +9 -3
index 14d190c83db1..773aa5f8ad83 100755
@@ -31,6 +31,9 @@ if __name__ == '__main__':
     ap.add_argument('--verbose', action='store_true',
                     default=False,
                     help='emit extra logging')
+    ap.add_argument('--ignore-linter', dest='ignore_linter', action='store_true',
+                    default=False,
+                    help='Also update keys that fail the Sequoia linter check')
     ap.add_argument('--fromkey',
                     help='Top key ID (if omitted, will use the key with ultimate trust)')
     ap.add_argument('--maxdepth', default=4, type=int,
@@ -173,10 +176,13 @@ if __name__ == '__main__':
             header = wotmate.gpg_run_command(args, with_colons=False)
             keyexport = header + b"\n\n" + keydata + b"\n"
 
+            # Only do this for newly added keys
             if not key_already_exists and not wotmate.lint(keydata):
-                # Only do this for newly added keys
-                logger.info('Skipping %s due to bad linter results', kid)
-                continue
+                if not cmdargs.ignore_linter:
+                    logger.info('Skipping %s due to bad linter results', kid)
+                    continue
+                else:
+                    logger.debug(f'{kid}: Ignore bad linter results')
 
             with open(keyout, 'wb') as fout:
                 fout.write(keyexport)
Signature · 1 line
2.49.0
#5 lore raw
In reply to Uwe Kleine-König
Quoted 9 lines · Uwe Kleine-König

the only change since (implicit) v1 (available at
https://lore.kernel.org/tools/ef678713de0a9aec1c1f07d92faa29e1f5b5e4e5.1749804735.git.u.kleine-koenig@baylibre.com
) is that I added an S-o-b line for me (thanks git rebase --signoff!) now that there is a DCO document for wotmate.

Best regards
Uwe

[...]

Applied, thanks!

[1/4] export-keyring: Skip graph generation if the trust path didn't change

      commit: 30a9c74f47ac20b28fcd0e4e46de64dbdb7e14d8
[2/4] export-keyring: Improve logging
      commit: a2061c22a60fbd6d1721d642c8b48ca3fe0f560f
[3/4] export-keyring: Add cmdline option --verbose
      commit: dc807b9d40be0025eba7370d0fefab635547ce2b
[4/4] export-keyring: Add an option to ignore the linter check
      commit: 449d09274759e22ea0a31bd90015d8551e2dc16f

Best regards,

Signature · 1 line
Konstantin Ryabitsev <[email protected]>