]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
KEYS: Make the key matching functions return bool
authorDavid Howells <dhowells@redhat.com>
Tue, 16 Sep 2014 16:36:08 +0000 (17:36 +0100)
committerDavid Howells <dhowells@redhat.com>
Tue, 16 Sep 2014 16:36:08 +0000 (17:36 +0100)
Make the key matching functions pointed to by key_match_data::cmp return bool
rather than int.

Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
crypto/asymmetric_keys/asymmetric_type.c
include/linux/key-type.h
net/dns_resolver/dns_key.c
security/keys/internal.h
security/keys/keyring.c
security/keys/process_keys.c

index 7c04989689757da3284da98c0e7b933143b89c1b..7755f918e8d9480b14db5da356fdcc37c36c1678 100644 (file)
@@ -59,8 +59,8 @@ EXPORT_SYMBOL_GPL(asymmetric_keyid_match);
  *     "id:<id>"       - request a key matching the ID
  *     "<subtype>:<id>" - request a key of a subtype
  */
-static int asymmetric_key_cmp(const struct key *key,
-                             const struct key_match_data *match_data)
+static bool asymmetric_key_cmp(const struct key *key,
+                              const struct key_match_data *match_data)
 {
        const struct asymmetric_key_subtype *subtype = asymmetric_key_subtype(key);
        const char *description = match_data->raw_data;
index c14816bd3b44f14db29787ec90bc3da5ef4a83f9..ff9f1d3942356ffd1f16ab777cb8c7ed201b35e8 100644 (file)
@@ -56,10 +56,12 @@ typedef int (*request_key_actor_t)(struct key_construction *key,
  * Preparsed matching criterion.
  */
 struct key_match_data {
-       /* Comparison function, defaults to type->match, but can be replaced by
-        * type->match_preparse(). */
-       int (*cmp)(const struct key *key,
-                  const struct key_match_data *match_data);
+       /* Comparison function, defaults to exact description match, but can be
+        * overridden by type->match_preparse().  Should return true if a match
+        * is found and false if not.
+        */
+       bool (*cmp)(const struct key *key,
+                   const struct key_match_data *match_data);
 
        const void      *raw_data;      /* Raw match data */
        void            *preparsed;     /* For ->match_preparse() to stash stuff */
index a07b9ba7e0b7bfaa351dc90750c3ca2590b816eb..31cd4fd754869b8e621f0c5ecbfa5bca855684a7 100644 (file)
@@ -176,8 +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_cmp(const struct key *key,
-                           const struct key_match_data *match_data)
+static bool 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;
index e66a16cb63e1ca223e71d7b3b66ca5c0f19180ea..b8960c4959a5e53635180054d27d788105ebf134 100644 (file)
@@ -127,8 +127,8 @@ struct keyring_search_context {
        struct timespec         now;
 };
 
-extern int key_default_cmp(const struct key *key,
-                          const struct key_match_data *match_data);
+extern bool key_default_cmp(const struct key *key,
+                           const struct key_match_data *match_data);
 extern key_ref_t keyring_search_aux(key_ref_t keyring_ref,
                                    struct keyring_search_context *ctx);
 
@@ -150,8 +150,8 @@ extern struct key *request_key_and_link(struct key_type *type,
                                        struct key *dest_keyring,
                                        unsigned long flags);
 
-extern int lookup_user_key_possessed(const struct key *key,
-                                    const struct key_match_data *match_data);
+extern bool lookup_user_key_possessed(const struct key *key,
+                                     const struct key_match_data *match_data);
 extern key_ref_t lookup_user_key(key_serial_t id, unsigned long flags,
                                 key_perm_t perm);
 #define KEY_LOOKUP_CREATE      0x01
index 253c9a0eb092e2add086d5da72f0811e11007534..8177010174f7b3d47773a43e48bf2b171b264c5f 100644 (file)
@@ -513,8 +513,8 @@ EXPORT_SYMBOL(keyring_alloc);
 /*
  * By default, we keys found by getting an exact match on their descriptions.
  */
-int key_default_cmp(const struct key *key,
-                   const struct key_match_data *match_data)
+bool key_default_cmp(const struct key *key,
+                    const struct key_match_data *match_data)
 {
        return strcmp(key->description, match_data->raw_data) == 0;
 }
index 08bd533d014fd87a31f5e3570c5e8b646b75252d..bd536cb221e237c6cab654b4d4d927daf3f27340 100644 (file)
@@ -489,8 +489,8 @@ found:
 /*
  * See if the key we're looking at is the target key.
  */
-int lookup_user_key_possessed(const struct key *key,
-                             const struct key_match_data *match_data)
+bool lookup_user_key_possessed(const struct key *key,
+                              const struct key_match_data *match_data)
 {
        return key == match_data->raw_data;
 }