ENGINE-420: fixed bug in setting user as PEP user (fpr wasn't yet present) ENGINE-420
authorKrista Bennett <krista@pep-project.org>
Fri, 13 Apr 2018 18:33:38 +0200
branchENGINE-420
changeset 2599b02405e4e373
parent 2598 eaf109aa1e6c
child 2600 8fc17cbaa30f
ENGINE-420: fixed bug in setting user as PEP user (fpr wasn't yet present)
src/message_api.c
test/convenience_scripts/DANGER_delete_keys_silently_w_pattern.py
     1.1 --- a/src/message_api.c	Fri Apr 13 14:49:27 2018 +0200
     1.2 +++ b/src/message_api.c	Fri Apr 13 18:33:38 2018 +0200
     1.3 @@ -2737,12 +2737,16 @@
     1.4      
     1.5      PEP_STATUS status = 
     1.6              is_me(session, sender) ? myself(session, sender) : update_identity(session, sender);
     1.7 -    
     1.8 +
     1.9      if (EMPTYSTR(sender->fpr) || strcmp(sender->fpr, keylist->value) != 0) {
    1.10          free(sender->fpr);
    1.11          sender->fpr = strdup(keylist->value);
    1.12          if (!sender->fpr)
    1.13              return PEP_OUT_OF_MEMORY;
    1.14 +        status = set_pgp_keypair(session, sender->fpr);
    1.15 +        if (status != PEP_STATUS_OK)
    1.16 +            return status;
    1.17 +            
    1.18          status = get_trust(session, sender);
    1.19          
    1.20          if (status == PEP_CANNOT_FIND_IDENTITY || sender->comm_type == PEP_ct_unknown) {
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/convenience_scripts/DANGER_delete_keys_silently_w_pattern.py	Fri Apr 13 18:33:38 2018 +0200
     2.3 @@ -0,0 +1,32 @@
     2.4 +import argparse
     2.5 +import gnupg
     2.6 +import os
     2.7 +import subprocess
     2.8 +
     2.9 +parser = argparse.ArgumentParser()
    2.10 +parser.add_argument("pattern")
    2.11 +parser.add_argument("--priv", "-p", help="also delete associated private keys", action='store_true')
    2.12 +
    2.13 +args = parser.parse_args()
    2.14 +
    2.15 +homedir = os.path.join(os.path.expanduser('~'),".gnupg")
    2.16 +print("GNUPGHOME=" + homedir + "\n")
    2.17 +
    2.18 +try:
    2.19 +    gpg = gnupg.GPG(gnupghome=homedir) 
    2.20 +except TypeError:
    2.21 +    gpg = gnupg.GPG(homedir=homedir)
    2.22 +
    2.23 +if not args.pattern:
    2.24 +    raise Exception("No pattern? How'd you do that?")
    2.25 +    
    2.26 +public_keys = gpg.list_keys(keys=args.pattern) # same as gpg.list_keys(False)
    2.27 +
    2.28 +for key in public_keys:
    2.29 +    print("Deleting keys...\n")
    2.30 +    for uid in key['uids']:
    2.31 +        print(uid + " ")
    2.32 +    print(key['fingerprint'] + "\n")
    2.33 +    if args.priv:
    2.34 +        gpg.delete_keys(key['fingerprint'], True)
    2.35 +    gpg.delete_keys(key['fingerprint'])