diff options
Diffstat (limited to 'security/keys/key.c')
-rw-r--r-- | security/keys/key.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/security/keys/key.c b/security/keys/key.c index 99781b798312..a057e3311aad 100644 --- a/security/keys/key.c +++ b/security/keys/key.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* key.c: basic authentication token and access key management | 1 | /* key.c: basic authentication token and access key management |
2 | * | 2 | * |
3 | * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved. | 3 | * Copyright (C) 2004-6 Red Hat, Inc. All Rights Reserved. |
4 | * Written by David Howells (dhowells@redhat.com) | 4 | * Written by David Howells (dhowells@redhat.com) |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or | 6 | * This program is free software; you can redistribute it and/or |
@@ -271,7 +271,7 @@ struct key *key_alloc(struct key_type *type, const char *desc, | |||
271 | * its description */ | 271 | * its description */ |
272 | if (!not_in_quota) { | 272 | if (!not_in_quota) { |
273 | spin_lock(&user->lock); | 273 | spin_lock(&user->lock); |
274 | if (user->qnkeys + 1 >= KEYQUOTA_MAX_KEYS && | 274 | if (user->qnkeys + 1 >= KEYQUOTA_MAX_KEYS || |
275 | user->qnbytes + quotalen >= KEYQUOTA_MAX_BYTES | 275 | user->qnbytes + quotalen >= KEYQUOTA_MAX_BYTES |
276 | ) | 276 | ) |
277 | goto no_quota; | 277 | goto no_quota; |
@@ -795,12 +795,16 @@ key_ref_t key_create_or_update(key_ref_t keyring_ref, | |||
795 | goto error_3; | 795 | goto error_3; |
796 | } | 796 | } |
797 | 797 | ||
798 | /* search for an existing key of the same type and description in the | 798 | /* if it's possible to update this type of key, search for an existing |
799 | * destination keyring | 799 | * key of the same type and description in the destination keyring and |
800 | * update that instead if possible | ||
800 | */ | 801 | */ |
801 | key_ref = __keyring_search_one(keyring_ref, ktype, description, 0); | 802 | if (ktype->update) { |
802 | if (!IS_ERR(key_ref)) | 803 | key_ref = __keyring_search_one(keyring_ref, ktype, description, |
803 | goto found_matching_key; | 804 | 0); |
805 | if (!IS_ERR(key_ref)) | ||
806 | goto found_matching_key; | ||
807 | } | ||
804 | 808 | ||
805 | /* decide on the permissions we want */ | 809 | /* decide on the permissions we want */ |
806 | perm = KEY_POS_VIEW | KEY_POS_SEARCH | KEY_POS_LINK | KEY_POS_SETATTR; | 810 | perm = KEY_POS_VIEW | KEY_POS_SEARCH | KEY_POS_LINK | KEY_POS_SETATTR; |