merged in ENGINE-596 sync
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Fri, 15 Nov 2019 12:12:15 +0100
branchsync
changeset 418992c23e4ab031
parent 4185 074b6139ab46
parent 4188 8e4a262aa1ea
child 4192 10899f62dba5
merged in ENGINE-596
     1.1 --- a/build-mac/pEpEngine.xcodeproj/project.pbxproj	Fri Nov 15 10:51:17 2019 +0100
     1.2 +++ b/build-mac/pEpEngine.xcodeproj/project.pbxproj	Fri Nov 15 12:12:15 2019 +0100
     1.3 @@ -147,6 +147,7 @@
     1.4  		431F04B722733A7E00CCE960 /* key_reset.h in Headers */ = {isa = PBXBuildFile; fileRef = 431F04B222733A7E00CCE960 /* key_reset.h */; };
     1.5  		43370833203C075A004E6547 /* sqlite3.c in Sources */ = {isa = PBXBuildFile; fileRef = 4337082D203C075A004E6547 /* sqlite3.c */; };
     1.6  		43370834203C075A004E6547 /* sqlite3.h in Headers */ = {isa = PBXBuildFile; fileRef = 43370832203C075A004E6547 /* sqlite3.h */; };
     1.7 +		433CD798237EB65000F73AE4 /* GroupKeysAndClose.c in Sources */ = {isa = PBXBuildFile; fileRef = 433CD793237EB65000F73AE4 /* GroupKeysAndClose.c */; };
     1.8  		438C43B52167752C00C7425B /* labeled_int_list.h in Headers */ = {isa = PBXBuildFile; fileRef = 438C43AF2167752C00C7425B /* labeled_int_list.h */; };
     1.9  		438C43B62167752C00C7425B /* labeled_int_list.c in Sources */ = {isa = PBXBuildFile; fileRef = 438C43B42167752C00C7425B /* labeled_int_list.c */; };
    1.10  		43E4FBB22362C05600BC01F4 /* NegotiationRequestGrouped.c in Sources */ = {isa = PBXBuildFile; fileRef = 43E4FBAD2362C05600BC01F4 /* NegotiationRequestGrouped.c */; };
    1.11 @@ -375,6 +376,7 @@
    1.12  		431F04B222733A7E00CCE960 /* key_reset.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = key_reset.h; path = ../src/key_reset.h; sourceTree = "<group>"; };
    1.13  		4337082D203C075A004E6547 /* sqlite3.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = sqlite3.c; path = ../src/sqlite3.c; sourceTree = "<group>"; };
    1.14  		43370832203C075A004E6547 /* sqlite3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = sqlite3.h; path = ../src/sqlite3.h; sourceTree = "<group>"; };
    1.15 +		433CD793237EB65000F73AE4 /* GroupKeysAndClose.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = GroupKeysAndClose.c; path = ../asn.1/GroupKeysAndClose.c; sourceTree = "<group>"; };
    1.16  		438C43962167582400C7425B /* sync_api.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = sync_api.h; path = ../src/sync_api.h; sourceTree = "<group>"; };
    1.17  		438C43AF2167752C00C7425B /* labeled_int_list.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = labeled_int_list.h; path = ../src/labeled_int_list.h; sourceTree = "<group>"; };
    1.18  		438C43B42167752C00C7425B /* labeled_int_list.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = labeled_int_list.c; path = ../src/labeled_int_list.c; sourceTree = "<group>"; };
    1.19 @@ -482,6 +484,7 @@
    1.20  		6406CE811CE382F400C14D77 /* asn.1 */ = {
    1.21  			isa = PBXGroup;
    1.22  			children = (
    1.23 +				433CD793237EB65000F73AE4 /* GroupKeysAndClose.c */,
    1.24  				43E4FBB32362C29100BC01F4 /* GroupHandshake.c */,
    1.25  				43E4FBAD2362C05600BC01F4 /* NegotiationRequestGrouped.c */,
    1.26  				15B037A822B2B822002D664C /* asn_application.h */,
    1.27 @@ -984,6 +987,7 @@
    1.28  				15B0380D22B2B822002D664C /* CommitReject.c in Sources */,
    1.29  				15B0380B22B2B822002D664C /* NativeInteger.c in Sources */,
    1.30  				154918B322B940200091B6D6 /* Sync_impl.c in Sources */,
    1.31 +				433CD798237EB65000F73AE4 /* GroupKeysAndClose.c in Sources */,
    1.32  				15B037E322B2B822002D664C /* GroupKeys.c in Sources */,
    1.33  				15B037B122B2B822002D664C /* NegotiationRequest.c in Sources */,
    1.34  				15B037FC22B2B822002D664C /* Hex.c in Sources */,
     2.1 --- a/src/identity_list.c	Fri Nov 15 10:51:17 2019 +0100
     2.2 +++ b/src/identity_list.c	Fri Nov 15 12:12:15 2019 +0100
     2.3 @@ -134,3 +134,20 @@
     2.4  
     2.5      return len;
     2.6  }
     2.7 +
     2.8 +PEP_STATUS set_all_userids_in_list(identity_list* id_list, const char* user_id) {
     2.9 +    identity_list* curr_list = id_list;
    2.10 +    
    2.11 +    while (curr_list) {
    2.12 +        if (curr_list->ident) {
    2.13 +            free(curr_list->ident->user_id);
    2.14 +            curr_list->ident->user_id = NULL;
    2.15 +            char* dup_userid = strdup(user_id);
    2.16 +            if (dup_userid == NULL)
    2.17 +                return PEP_OUT_OF_MEMORY;
    2.18 +            curr_list->ident->user_id = dup_userid;    
    2.19 +        }    
    2.20 +        curr_list = id_list->next;
    2.21 +    }
    2.22 +    return PEP_STATUS_OK;
    2.23 +}
     3.1 --- a/src/identity_list.h	Fri Nov 15 10:51:17 2019 +0100
     3.2 +++ b/src/identity_list.h	Fri Nov 15 12:12:15 2019 +0100
     3.3 @@ -83,7 +83,10 @@
     3.4  //      length of identity_list in number of elements
     3.5  
     3.6  DYNAMIC_API int identity_list_length(const identity_list *id_list);
     3.7 -    
     3.8 +
     3.9 +// Internal
    3.10 +PEP_STATUS set_all_userids_in_list(identity_list* id_list, const char* user_id);
    3.11 +
    3.12  #ifdef __cplusplus
    3.13  }
    3.14  #endif
     4.1 --- a/src/map_asn1.h	Fri Nov 15 10:51:17 2019 +0100
     4.2 +++ b/src/map_asn1.h	Fri Nov 15 12:12:15 2019 +0100
     4.3 @@ -80,4 +80,3 @@
     4.4  #ifdef __cplusplus
     4.5  }
     4.6  #endif
     4.7 -
     5.1 --- a/src/pEpEngine.c	Fri Nov 15 10:51:17 2019 +0100
     5.2 +++ b/src/pEpEngine.c	Fri Nov 15 12:12:15 2019 +0100
     5.3 @@ -5382,3 +5382,20 @@
     5.4      session->debug_color = ansi_color;
     5.5  #endif
     5.6  }
     5.7 +
     5.8 +PEP_STATUS set_all_userids_to_own(PEP_SESSION session, identity_list* id_list) {
     5.9 +    static char* ownid = NULL;
    5.10 +    PEP_STATUS status = PEP_STATUS_OK;
    5.11 +    if (!ownid) {
    5.12 +        status = get_default_own_userid(session, &ownid);
    5.13 +    }    
    5.14 +    if (status == PEP_STATUS_OK) {
    5.15 +        if (ownid) {
    5.16 +            status = set_all_userids_in_list(id_list, ownid);
    5.17 +        }
    5.18 +        else {
    5.19 +            status = PEP_UNKNOWN_ERROR;
    5.20 +        }
    5.21 +    }
    5.22 +    return status;    
    5.23 +}
     6.1 --- a/src/pEpEngine.h	Fri Nov 15 10:51:17 2019 +0100
     6.2 +++ b/src/pEpEngine.h	Fri Nov 15 12:12:15 2019 +0100
     6.3 @@ -1422,6 +1422,9 @@
     6.4                       const char *fpr, 
     6.5                       char **sign, 
     6.6                       size_t *sign_size);
     6.7 +                     
     6.8 +PEP_STATUS set_all_userids_to_own(PEP_SESSION session, 
     6.9 +                                  identity_list* id_list);
    6.10  
    6.11  #ifdef __cplusplus
    6.12  }
     7.1 --- a/sync/cond_act_sync.yml2	Fri Nov 15 10:51:17 2019 +0100
     7.2 +++ b/sync/cond_act_sync.yml2	Fri Nov 15 12:12:15 2019 +0100
     7.3 @@ -368,6 +368,11 @@
     7.4          free(user_id);
     7.5          return PEP_OUT_OF_MEMORY;
     7.6      }
     7.7 +    status = set_all_userids_to_own(session, il);
     7.8 +    if (status != PEP_STATUS_OK) {
     7.9 +        free(user_id);
    7.10 +        return status;
    7.11 +    }
    7.12      
    7.13      identity_list *oil = session->sync_state.own.identities;
    7.14  
    7.15 @@ -452,6 +457,12 @@
    7.16      if (!il)
    7.17          return PEP_OUT_OF_MEMORY;
    7.18  
    7.19 +    status = set_all_userids_to_own(session, il);
    7.20 +    if (status != PEP_STATUS_OK) {
    7.21 +        free(user_id);
    7.22 +        return status;
    7.23 +    }
    7.24 +
    7.25      for (identity_list *_il = il; _il && _il->ident ; _il = _il->next) {
    7.26          // replace partner's user_id with own user_id
    7.27          free(_il->ident->user_id);
     8.1 --- a/sync/gen_message_func.ysl2	Fri Nov 15 10:51:17 2019 +0100
     8.2 +++ b/sync/gen_message_func.ysl2	Fri Nov 15 12:12:15 2019 +0100
     8.3 @@ -318,6 +318,11 @@
     8.4                      &session->«$state».«@name», NULL);
     8.5              if (!il)
     8.6                  return PEP_OUT_OF_MEMORY;
     8.7 +
     8.8 +            PEP_STATUS own_idents_status = set_all_userids_to_own(session, il);
     8.9 +            if (own_idents_status != PEP_STATUS_OK)
    8.10 +                return own_idents_status;
    8.11 +                
    8.12              IdentityList_t *_il = IdentityList_from_identity_list(il,
    8.13                      &msg->choice.«yml:lcase(../../@name)».choice.«$message_name».«@name»);
    8.14              free_identity_list(il);
    8.15 @@ -398,6 +403,11 @@
    8.16                      &msg->choice.«yml:lcase(../../@name)».choice.«$message_name».«@name», NULL);
    8.17              if (!il)
    8.18                  return PEP_OUT_OF_MEMORY;
    8.19 +                
    8.20 +            PEP_STATUS own_idents_status = set_all_userids_to_own(session, il);
    8.21 +            if (own_idents_status != PEP_STATUS_OK)
    8.22 +                return own_idents_status;
    8.23 +                
    8.24              IdentityList_t *_il = IdentityList_from_identity_list(il,
    8.25                      &session->«yml:lcase(../../../@name)»_state.«yml:lcase(../../@name)».«@name»);
    8.26              free_identity_list(il);
    8.27 @@ -427,4 +437,3 @@
    8.28  ||
    8.29  
    8.30  }
    8.31 -