Skip to content

Commit

Permalink
core: Fix archive user updating their keys when using autoconfig
Browse files Browse the repository at this point in the history
Previously a user's key hash would be updated in the database but not in
the GPG keyring if the user already existed. This change will add the
key unconditionally if it is missing in the GPG keyring and ensure it
and the DB are in sync again.
  • Loading branch information
ximion committed Feb 29, 2024
1 parent f622aed commit 4f18c82
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/lkadmin/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ def update_uploaders(dir_path, auto=False, no_confirm=False):
if not no_confirm:
data_src = git_url if git_url else dir_path
proceed_answer = Confirm.ask(
'Update users with data from {}? This will DELETE and users not present in this directory!'.format(data_src)
'Update users with data from {}? This will DELETE all users not present in this directory!'.format(data_src)
)
if not proceed_answer:
return
Expand Down Expand Up @@ -671,7 +671,6 @@ def update_uploaders(dir_path, auto=False, no_confirm=False):
session.add(user)
user.name = uconf.get('name', '')
user.alias = uconf.get('alias', None)
user.pgp_fingerprints = fingerprints
user.is_human = uconf.get('is_human', True)
user.allow_source_uploads = uconf.get('allow_source_uploads', True)
user.allow_binary_uploads = uconf.get('allow_binary_uploads', False)
Expand All @@ -696,11 +695,9 @@ def update_uploaders(dir_path, auto=False, no_confirm=False):
# update GPG keys
for fpr in fingerprints:
used_fprs.add(fpr)
# check if we already have the key for existing users
if fpr in uploader_fprs:
continue
# check if the key was already added to the current user in the current import cycle
if fpr in user.pgp_fingerprints:
# Check if the key was already added to the current user in the current import cycle
# and if we have it in the global GPG keyring (and skip adding it again in that case)
if fpr in user.pgp_fingerprints and fpr in uploader_fprs:
continue
log.info('Importing key %s for %s', fpr, email)
import_key_file_for_uploader(user, os.path.join(uconf_root, fpr + '.asc'))
Expand Down

0 comments on commit 4f18c82

Please sign in to comment.