src/message_api.c
branchENGINE-294
changeset 2548 3bfda8f2136e
parent 2545 684e48c565db
child 2549 5fc5d6be0b36
     1.1 --- a/src/message_api.c	Wed Feb 28 10:31:50 2018 +0100
     1.2 +++ b/src/message_api.c	Wed Feb 28 12:24:48 2018 +0100
     1.3 @@ -6,6 +6,7 @@
     1.4  
     1.5  #include "platform.h"
     1.6  #include "mime.h"
     1.7 +#include "blacklist.h"
     1.8  
     1.9  #include <assert.h>
    1.10  #include <string.h>
    1.11 @@ -1533,6 +1534,26 @@
    1.12                  _il->ident->comm_type = PEP_ct_key_not_found;
    1.13                  _status = PEP_STATUS_OK;
    1.14              }
    1.15 +            bool is_blacklisted = false;
    1.16 +            if (_il->ident->fpr) {
    1.17 +                _status = blacklist_is_listed(session, _il->ident->fpr, &is_blacklisted);
    1.18 +                if (_status != PEP_STATUS_OK) {
    1.19 +                    // DB error
    1.20 +                    status = PEP_UNENCRYPTED;
    1.21 +                    goto pep_error;
    1.22 +                }
    1.23 +                if (is_blacklisted) {
    1.24 +                    bool user_default, ident_default, address_default; 
    1.25 +                    _status = get_valid_pubkey(session, _il->ident,
    1.26 +                                               &ident_default, &user_default,
    1.27 +                                               &address_default,
    1.28 +                                               true);
    1.29 +                    if (_status != PEP_STATUS_OK || _il->ident->fpr == NULL) {
    1.30 +                        _il->ident->comm_type = PEP_ct_key_not_found;
    1.31 +                        _status = PEP_STATUS_OK;                        
    1.32 +                    }
    1.33 +                }    
    1.34 +            }
    1.35              if (!has_pep_user && !EMPTYSTR(_il->ident->user_id))
    1.36                  is_pep_user(session, _il->ident, &has_pep_user);
    1.37          }
    1.38 @@ -1565,6 +1586,26 @@
    1.39                      _il->ident->comm_type = PEP_ct_key_not_found;
    1.40                      _status = PEP_STATUS_OK;
    1.41                  }
    1.42 +                bool is_blacklisted = false;
    1.43 +                if (_il->ident->fpr) {
    1.44 +                    _status = blacklist_is_listed(session, _il->ident->fpr, &is_blacklisted);
    1.45 +                    if (_status != PEP_STATUS_OK) {
    1.46 +                        // DB error
    1.47 +                        status = PEP_UNENCRYPTED;
    1.48 +                        goto pep_error;
    1.49 +                    }
    1.50 +                    if (is_blacklisted) {
    1.51 +                        bool user_default, ident_default, address_default; 
    1.52 +                        _status = get_valid_pubkey(session, _il->ident,
    1.53 +                                                   &ident_default, &user_default,
    1.54 +                                                   &address_default,
    1.55 +                                                   true);
    1.56 +                        if (_status != PEP_STATUS_OK || _il->ident->fpr == NULL) {
    1.57 +                            _il->ident->comm_type = PEP_ct_key_not_found;
    1.58 +                            _status = PEP_STATUS_OK;                        
    1.59 +                        }
    1.60 +                    }    
    1.61 +                }
    1.62                  if (!has_pep_user && !EMPTYSTR(_il->ident->user_id))
    1.63                      is_pep_user(session, _il->ident, &has_pep_user);
    1.64              }
    1.65 @@ -1596,6 +1637,26 @@
    1.66                      _il->ident->comm_type = PEP_ct_key_not_found;
    1.67                      _status = PEP_STATUS_OK;
    1.68                  }
    1.69 +                bool is_blacklisted = false;
    1.70 +                if (_il->ident->fpr) {
    1.71 +                    _status = blacklist_is_listed(session, _il->ident->fpr, &is_blacklisted);
    1.72 +                    if (_status != PEP_STATUS_OK) {
    1.73 +                        // DB error
    1.74 +                        status = PEP_UNENCRYPTED;
    1.75 +                        goto pep_error;
    1.76 +                    }
    1.77 +                    if (is_blacklisted) {
    1.78 +                        bool user_default, ident_default, address_default; 
    1.79 +                        _status = get_valid_pubkey(session, _il->ident,
    1.80 +                                                   &ident_default, &user_default,
    1.81 +                                                   &address_default,
    1.82 +                                                   true);
    1.83 +                        if (_status != PEP_STATUS_OK || _il->ident->fpr == NULL) {
    1.84 +                            _il->ident->comm_type = PEP_ct_key_not_found;
    1.85 +                            _status = PEP_STATUS_OK;                        
    1.86 +                        }
    1.87 +                    }    
    1.88 +                }
    1.89                  if (!has_pep_user && !EMPTYSTR(_il->ident->user_id))
    1.90                      is_pep_user(session, _il->ident, &has_pep_user);
    1.91              }
    1.92 @@ -2919,7 +2980,22 @@
    1.93                  status = update_identity(session, il->ident);
    1.94              else
    1.95                  status = myself(session, il->ident);
    1.96 -                
    1.97 +            
    1.98 +            bool is_blacklisted = false;
    1.99 +            if (il->ident->fpr) {
   1.100 +                status = blacklist_is_listed(session, il->ident->fpr, &is_blacklisted);
   1.101 +                if (is_blacklisted) {
   1.102 +                    bool user_default, ident_default, address_default; 
   1.103 +                    status = get_valid_pubkey(session, il->ident,
   1.104 +                                              &ident_default, &user_default,
   1.105 +                                              &address_default,
   1.106 +                                              true);
   1.107 +                    if (status != PEP_STATUS_OK || il->ident->fpr == NULL) {
   1.108 +                        il->ident->comm_type = PEP_ct_key_not_found;
   1.109 +                    }
   1.110 +                }    
   1.111 +            }
   1.112 +    
   1.113              // check for the return statuses which might not a representative
   1.114              // value in the comm_type
   1.115              if (status == PEP_ILLEGAL_VALUE || status == PEP_CANNOT_SET_PERSON ||