src/keymanagement.c
branchENGINE-293
changeset 2304 3bd45e2b8f92
parent 2303 e7b3fa443f3e
child 2305 f617e0acae94
     1.1 --- a/src/keymanagement.c	Mon Dec 04 18:23:14 2017 +0100
     1.2 +++ b/src/keymanagement.c	Tue Dec 05 10:00:48 2017 +0100
     1.3 @@ -125,7 +125,6 @@
     1.4          }
     1.5          snprintf(identity->user_id, strlen(identity->address) + 6,
     1.6                   "TOFU_%s", identity->address);
     1.7 -        }
     1.8      }
     1.9   
    1.10      status = get_identity(session,
    1.11 @@ -443,7 +442,7 @@
    1.12  
    1.13      if (!(session && identity && !EMPTYSTR(identity->address) &&
    1.14              (EMPTYSTR(identity->user_id) ||
    1.15 -            (own_id && strcmp(identity->user_id, own_id) == 0)))
    1.16 +            (own_id && strcmp(identity->user_id, own_id) == 0))))
    1.17          return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    1.18  
    1.19      identity->comm_type = PEP_ct_pEp;
    1.20 @@ -1078,7 +1077,7 @@
    1.21              status = get_identity(session, my_user_id, address, &my_id);
    1.22              
    1.23              if (status == PEP_STATUS_OK && my_id) {
    1.24 -                if (my_id->fpr && strcasecmp(my_id->fpr, fpr) == 0)) {
    1.25 +                if (my_id->fpr && strcasecmp(my_id->fpr, fpr) == 0) {
    1.26                      // We're done. It was already here.
    1.27                      // FIXME: Do we check trust/revocation/?
    1.28                      goto pep_free;
    1.29 @@ -1092,22 +1091,20 @@
    1.30              if (my_id) {
    1.31                  free(my_id->fpr);
    1.32                  my_id->fpr = my_user_id;
    1.33 -                my_user_id->comm_type = PEP_ct_pEp;
    1.34 +                my_id->comm_type = PEP_ct_pEp;
    1.35 +                my_id->me = true; // just in case? 
    1.36              }
    1.37              else { // Else, we need a new identity
    1.38 -                status = new_identity(session, address, fpr, my_user_id, NULL, &my_id); 
    1.39 +                my_id = new_identity(address, fpr, my_user_id, NULL); 
    1.40                  if (status != PEP_STATUS_OK)
    1.41                      goto pep_free; 
    1.42 -                my_user_id->me = true;
    1.43 -                my_user_id->comm_type = PEP_ct_pEp;
    1.44 +                my_id->me = true;
    1.45 +                my_id->comm_type = PEP_ct_pEp;
    1.46              }
    1.47          }
    1.48          else {
    1.49              // I think the prerequisite should be that at least one own identity
    1.50              // already in the DB, so REALLY look at this.
    1.51 -            // status = new_identity(session, address, fpr, "PEP_OWN_USERID", NULL); 
    1.52 -            // my_user_id->me = true;
    1.53 -            // my_user_id->comm_type = PEP_ct_pEp;
    1.54              return PEP_CANNOT_FIND_IDENTITY;
    1.55          }
    1.56