Skip to content

Commit

Permalink
fix #1403
Browse files Browse the repository at this point in the history
Handle the case where atheme had a successor, but didn't correctly
elect them as founder (?)
  • Loading branch information
slingamn committed Dec 7, 2020
1 parent b95afa1 commit 468b5a4
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions distrib/atheme/atheme2json.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,31 @@ def convert(infile):
chdata['amode'][username] = 'h'
elif 'v' in flags or 'V' in flags:
chdata['amode'][username] = 'v'
elif 'S' in flags:
# take the first entry as the successor
if not chdata.get('successor'):
chdata['successor'] = username
else:
pass

# do some basic integrity checks
def validate_user(name):
if not name:
return False
return bool(out['users'].get(name))

invalid_channels = []

for chname, chdata in out['channels'].items():
founder = chdata.get('founder')
if founder not in out['users']:
raise ValueError("no user corresponding to channel founder", chname, chdata.get('founder'))
if not validate_user(chdata.get('founder')):
if validate_user(chdata.get('successor')):
chdata['founder'] = chdata['successor']
else:
invalid_channels.append(chname)

for chname in invalid_channels:
logging.warning("Unable to find a valid founder for channel %s, discarding it", chname)
del out['channels'][chname]

return out

Expand Down

0 comments on commit 468b5a4

Please sign in to comment.