diff options
author | Tobias Brunner <tobias@strongswan.org> | 2015-07-27 19:16:08 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2015-08-17 18:58:14 +0200 |
commit | 6927d6224ef32e4b34ad188d772c320515e76a63 (patch) | |
tree | f25cd3098c441b791746c6034c53af94f868df4b /src/libcharon/plugins/sql/sql_config.c | |
parent | fffee7c7597dcb8aa6fb6b60e1f197b4dd726f44 (diff) | |
download | strongswan-6927d6224ef32e4b34ad188d772c320515e76a63.tar.bz2 strongswan-6927d6224ef32e4b34ad188d772c320515e76a63.tar.xz |
sql: Also do a reversed ID match
This is required for the case where IDr is not sent (i.e. is %any).
The backend manager does the same.
Fixes #1044.
Diffstat (limited to 'src/libcharon/plugins/sql/sql_config.c')
-rw-r--r-- | src/libcharon/plugins/sql/sql_config.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/libcharon/plugins/sql/sql_config.c b/src/libcharon/plugins/sql/sql_config.c index c47c7c0f8..ce24d180a 100644 --- a/src/libcharon/plugins/sql/sql_config.c +++ b/src/libcharon/plugins/sql/sql_config.c @@ -324,6 +324,14 @@ static peer_cfg_t *get_peer_cfg_by_id(private_sql_config_t *this, int id) } /** + * Check if the two IDs match (the first one is optional) + */ +static inline bool id_matches(identification_t *id, identification_t *sql_id) +{ + return !id || id->matches(id, sql_id) || sql_id->matches(sql_id, id); +} + +/** * Build a peer config from an SQL query */ static peer_cfg_t *build_peer_cfg(private_sql_config_t *this, enumerator_t *e, @@ -352,8 +360,7 @@ static peer_cfg_t *build_peer_cfg(private_sql_config_t *this, enumerator_t *e, local_id = identification_create_from_encoding(l_type, l_data); remote_id = identification_create_from_encoding(r_type, r_data); - if ((me && !me->matches(me, local_id)) || - (other && !other->matches(other, remote_id))) + if (!id_matches(me, local_id) || !id_matches(other, remote_id)) { local_id->destroy(local_id); remote_id->destroy(remote_id); |