KEYS: Remove key_type::match in favour of overriding default by match_preparse
A previous patch added a ->match_preparse() method to the key type. This is allowed to override the function called by the iteration algorithm. Therefore, we can just set a default that simply checks for an exact match of the key description with the original criterion data and allow match_preparse to override it as needed. The key_type::match op is then redundant and can be removed, as can the user_match() function. Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: Vivek Goyal <vgoyal@redhat.com>
This commit is contained in:
@@ -176,9 +176,8 @@ static void dns_resolver_free_preparse(struct key_preparsed_payload *prep)
|
||||
* The domain name may be a simple name or an absolute domain name (which
|
||||
* should end with a period). The domain name is case-independent.
|
||||
*/
|
||||
static int
|
||||
dns_resolver_match(const struct key *key,
|
||||
const struct key_match_data *match_data)
|
||||
static int dns_resolver_cmp(const struct key *key,
|
||||
const struct key_match_data *match_data)
|
||||
{
|
||||
int slen, dlen, ret = 0;
|
||||
const char *src = key->description, *dsp = match_data->raw_data;
|
||||
@@ -209,6 +208,16 @@ no_match:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Preparse the match criterion.
|
||||
*/
|
||||
static int dns_resolver_match_preparse(struct key_match_data *match_data)
|
||||
{
|
||||
match_data->lookup_type = KEYRING_SEARCH_LOOKUP_ITERATE;
|
||||
match_data->cmp = dns_resolver_cmp;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Describe a DNS key
|
||||
*/
|
||||
@@ -243,7 +252,7 @@ struct key_type key_type_dns_resolver = {
|
||||
.preparse = dns_resolver_preparse,
|
||||
.free_preparse = dns_resolver_free_preparse,
|
||||
.instantiate = generic_key_instantiate,
|
||||
.match = dns_resolver_match,
|
||||
.match_preparse = dns_resolver_match_preparse,
|
||||
.revoke = user_revoke,
|
||||
.destroy = user_destroy,
|
||||
.describe = dns_resolver_describe,
|
||||
|
Reference in New Issue
Block a user