From 8fc20d8eed8cf91fe9e5ee6427506a5bdef2c2ab Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Mon, 13 Dec 2021 02:07:56 -0500 Subject: [PATCH] fix the atheme side of #1864 Import stored certfps from Atheme as well. --- distrib/atheme/atheme2json.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/distrib/atheme/atheme2json.py b/distrib/atheme/atheme2json.py index 23766e00..1a4b3b17 100755 --- a/distrib/atheme/atheme2json.py +++ b/distrib/atheme/atheme2json.py @@ -1,5 +1,6 @@ #!/usr/bin/python3 +import binascii import json import logging import re @@ -19,6 +20,14 @@ CMODE_FLAG_TO_MODE = { 0x100: 't', # CMODE_TOPIC } +# attempt to interpret certfp as a hex-encoded SHA-256 fingerprint +def validate_certfp(certfp): + try: + dec = binascii.unhexlify(certfp) + except: + return False + return len(dec) == 32 + def convert(infile): out = { 'version': 1, @@ -70,6 +79,11 @@ def convert(infile): if parts[2] == 'private:usercloak': username = parts[1] out['users'][username]['vhost'] = parts[3] + elif category == 'MCFP': + username, certfp = parts[1], parts[2] + if validate_certfp(certfp): + user = out['users'][username] + user.setdefault('certfps', []).append(certfp.lower()) elif category == 'MC': # channel registration # MC #mychannel 1600134478 1600467343 +v 272 0 0