Merge sync
authorNeal H. Walfield <neal@pep.foundation>
Thu, 21 Mar 2019 14:49:53 +0100
branchsync
changeset 3372ead25cd77c67
parent 3371 a9c437dd9eff
parent 3367 f23745b102eb
child 3373 0a9edfdb43a7
Merge
     1.1 --- a/src/message_api.c	Thu Mar 21 14:35:14 2019 +0100
     1.2 +++ b/src/message_api.c	Thu Mar 21 14:49:53 2019 +0100
     1.3 @@ -3284,7 +3284,6 @@
     1.4          identity_list **private_il
     1.5      )
     1.6  {
     1.7 -    
     1.8      assert(session);
     1.9      assert(src);
    1.10      assert(dst);
    1.11 @@ -3857,24 +3856,8 @@
    1.12          const char *data;
    1.13          char *sync_fpr = NULL;
    1.14          PEP_STATUS tmpstatus = base_extract_message(session, msg, &size, &data, &sync_fpr);
    1.15 -        if (!tmpstatus && size && data) {
    1.16 -        //    if ((*keylist && strcasecmp(msg->from->fpr, (*keylist)->value))
    1.17 -        //            || (sync_fpr && strcasecmp(msg->from->fpr, sync_fpr))) {
    1.18 -                pEp_identity *_from = identity_dup(msg->from);
    1.19 -                if (!_from) {
    1.20 -                    free_message(*dst);
    1.21 -                    *dst = NULL;
    1.22 -                    free_stringlist(*keylist);
    1.23 -                    *keylist = NULL;
    1.24 -                    free(sync_fpr);
    1.25 -                    return PEP_OUT_OF_MEMORY;
    1.26 -                }
    1.27 -                if (session->sync_state.common.from)
    1.28 -                    free_identity(session->sync_state.common.from);
    1.29 -                session->sync_state.common.from = _from;
    1.30 -                signal_Sync_message(session, *rating, data, size, sync_fpr);
    1.31 -        //    }
    1.32 -        }
    1.33 +        if (!tmpstatus && size && data)
    1.34 +            signal_Sync_message(session, *rating, data, size, msg->from, sync_fpr);
    1.35          free(sync_fpr);
    1.36      }
    1.37  
     2.1 --- a/src/pEpEngine.c	Thu Mar 21 14:35:14 2019 +0100
     2.2 +++ b/src/pEpEngine.c	Thu Mar 21 14:49:53 2019 +0100
     2.3 @@ -1778,7 +1778,12 @@
     2.4          const char *comment
     2.5      )
     2.6  {
     2.7 -//    PEP_STATUS status = PEP_STATUS_OK;
     2.8 +#ifndef NDEBUG
     2.9 +    fprintf(stdout, "\n*** %s %s %s %s\n", title, entity, description, comment);
    2.10 +    session->service_log = true;
    2.11 +#endif
    2.12 +
    2.13 +    // PEP_STATUS status = PEP_STATUS_OK;
    2.14      // int result;
    2.15      // 
    2.16      // assert(session);
     3.1 --- a/sync/cond_act_sync.yml2	Thu Mar 21 14:35:14 2019 +0100
     3.2 +++ b/sync/cond_act_sync.yml2	Thu Mar 21 14:49:53 2019 +0100
     3.3 @@ -136,6 +136,14 @@
     3.4              return PEP_OUT_OF_MEMORY;
     3.5          }
     3.6  
     3.7 +        free(partner->fpr);
     3.8 +        partner->fpr = strdup(session->sync_state.common.signature_fpr);
     3.9 +        if (!partner->fpr) {
    3.10 +            free_identity(me);
    3.11 +            free_identity(partner);
    3.12 +            return PEP_OUT_OF_MEMORY;
    3.13 +        }
    3.14 +
    3.15          status = session->notifyHandshake(me, partner, «$type»);
    3.16          if (status)
    3.17              return status;
     4.1 --- a/sync/gen_message_func.ysl2	Thu Mar 21 14:35:14 2019 +0100
     4.2 +++ b/sync/gen_message_func.ysl2	Thu Mar 21 14:49:53 2019 +0100
     4.3 @@ -41,6 +41,7 @@
     4.4  struct «@name»_state_s {
     4.5      struct common_state_s {
     4.6          pEp_identity *from;
     4.7 +        char *signature_fpr;
     4.8      } common;
     4.9  
    4.10      `` apply "fsm", mode=state
     5.1 --- a/sync/gen_statemachine.ysl2	Thu Mar 21 14:35:14 2019 +0100
     5.2 +++ b/sync/gen_statemachine.ysl2	Thu Mar 21 14:49:53 2019 +0100
     5.3 @@ -198,7 +198,8 @@
     5.4                      PEP_rating rating,
     5.5                      const char *data,
     5.6                      size_t size,
     5.7 -                    const char *fpr
     5.8 +                    const pEp_identity *from,
     5.9 +                    const char *signature_fpr
    5.10                  );
    5.11  
    5.12              #ifdef __cplusplus
    5.13 @@ -311,7 +312,8 @@
    5.14                      PEP_rating rating,
    5.15                      const char *data,
    5.16                      size_t size,
    5.17 -                    const char *fpr
    5.18 +                    const pEp_identity *from,
    5.19 +                    const char *signature_fpr
    5.20                  )
    5.21              {
    5.22                  assert(session && data && size);
    5.23 @@ -324,12 +326,19 @@
    5.24                  PEP_STATUS status = PEP_STATUS_OK;
    5.25                  «@name»_event_t *ev = NULL;
    5.26  
    5.27 -                if (fpr) {
    5.28 -                    if (session->«yml:lcase(@name)»_state.common.from->fpr)
    5.29 -                        free(session->«yml:lcase(@name)»_state.common.from->fpr);
    5.30 -                    session->«yml:lcase(@name)»_state.common.from->fpr = strdup(fpr);
    5.31 -                    assert(session->«yml:lcase(@name)»_state.common.from->fpr);
    5.32 -                    if (!session->«yml:lcase(@name)»_state.common.from->fpr) {
    5.33 +                if (from) {
    5.34 +                    free_identity(session->«yml:lcase(@name)»_state.common.from);
    5.35 +                    session->«yml:lcase(@name)»_state.common.from = identity_dup(from);
    5.36 +                    if (!session->«yml:lcase(@name)»_state.common.from) {
    5.37 +                        status = PEP_OUT_OF_MEMORY;
    5.38 +                        goto the_end;
    5.39 +                    }
    5.40 +                }
    5.41 +
    5.42 +                if (signature_fpr) {
    5.43 +                    free(session->«yml:lcase(@name)»_state.common.signature_fpr);
    5.44 +                    session->«yml:lcase(@name)»_state.common.signature_fpr = strdup(signature_fpr);
    5.45 +                    if (!session->«yml:lcase(@name)»_state.common.signature_fpr) {
    5.46                          status = PEP_OUT_OF_MEMORY;
    5.47                          goto the_end;
    5.48                      }
    5.49 @@ -631,7 +640,7 @@
    5.50              for "message[@security='unencrypted']" {
    5.51              ||
    5.52                      case «../@name»__payload_PR_«yml:mixedCase(@name)»:
    5.53 -                        if (!fpr) {
    5.54 +                        if (!signature_fpr) {
    5.55                              status = PEP_«yml:ucase(ancestor::protocol/@name)»_ILLEGAL_MESSAGE;
    5.56                              goto the_end;
    5.57                          }
    5.58 @@ -886,10 +895,10 @@
    5.59              if (!session)
    5.60                  return invalid_state;
    5.61  
    5.62 +            if (state == None)
    5.63 +                state = «@name»_state_Init;
    5.64 +
    5.65              switch (state) {
    5.66 -                case None:
    5.67 -                    return «@name»_state_Init;
    5.68 -                
    5.69                  `` apply "state", 2, mode=fsm
    5.70                  default:
    5.71                      «@name»_ERR_LOG_INT("invalid state", state);
    5.72 @@ -929,7 +938,7 @@
    5.73                  default:
    5.74                      // ignore events not handled here
    5.75                      «../@name»_SERVICE_LOG("ignoring event", KeySync_event_name(event));
    5.76 -                    break;
    5.77 +                    return invalid_event;
    5.78              }
    5.79              break;
    5.80