David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 1 | /* key-ui.h: key userspace interface stuff |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * |
| 3 | * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved. |
| 4 | * Written by David Howells (dhowells@redhat.com) |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
| 10 | */ |
| 11 | |
| 12 | #ifndef _LINUX_KEY_UI_H |
| 13 | #define _LINUX_KEY_UI_H |
| 14 | |
| 15 | #include <linux/key.h> |
| 16 | |
| 17 | /* the key tree */ |
| 18 | extern struct rb_root key_serial_tree; |
| 19 | extern spinlock_t key_serial_lock; |
| 20 | |
| 21 | /* required permissions */ |
| 22 | #define KEY_VIEW 0x01 /* require permission to view attributes */ |
| 23 | #define KEY_READ 0x02 /* require permission to read content */ |
| 24 | #define KEY_WRITE 0x04 /* require permission to update / modify */ |
| 25 | #define KEY_SEARCH 0x08 /* require permission to search (keyring) or find (key) */ |
| 26 | #define KEY_LINK 0x10 /* require permission to link */ |
| 27 | #define KEY_ALL 0x1f /* all the above permissions */ |
| 28 | |
| 29 | /* |
| 30 | * the keyring payload contains a list of the keys to which the keyring is |
| 31 | * subscribed |
| 32 | */ |
| 33 | struct keyring_list { |
David Howells | 76d8aea | 2005-06-23 22:00:49 -0700 | [diff] [blame] | 34 | struct rcu_head rcu; /* RCU deletion hook */ |
| 35 | unsigned short maxkeys; /* max keys this list can hold */ |
| 36 | unsigned short nkeys; /* number of keys currently held */ |
| 37 | unsigned short delkey; /* key to be unlinked by RCU */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | struct key *keys[0]; |
| 39 | }; |
| 40 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | /* |
| 42 | * check to see whether permission is granted to use a key in the desired way |
| 43 | */ |
David Howells | 468ed2b | 2005-10-07 15:07:38 +0100 | [diff] [blame] | 44 | extern int key_task_permission(const key_ref_t key_ref, |
| 45 | struct task_struct *context, |
| 46 | key_perm_t perm); |
| 47 | |
David Howells | 664cceb | 2005-09-28 17:03:15 +0100 | [diff] [blame] | 48 | static inline int key_permission(const key_ref_t key_ref, key_perm_t perm) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | { |
David Howells | 468ed2b | 2005-10-07 15:07:38 +0100 | [diff] [blame] | 50 | return key_task_permission(key_ref, current, perm); |
David Howells | 3e30148 | 2005-06-23 22:00:56 -0700 | [diff] [blame] | 51 | } |
| 52 | |
David Howells | 664cceb | 2005-09-28 17:03:15 +0100 | [diff] [blame] | 53 | extern key_ref_t lookup_user_key(struct task_struct *context, |
| 54 | key_serial_t id, int create, int partial, |
| 55 | key_perm_t perm); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | |
| 57 | extern long join_session_keyring(const char *name); |
| 58 | |
| 59 | extern struct key_type *key_type_lookup(const char *type); |
| 60 | extern void key_type_put(struct key_type *ktype); |
| 61 | |
| 62 | #define key_negative_timeout 60 /* default timeout on a negative key's existence */ |
| 63 | |
| 64 | |
| 65 | #endif /* _LINUX_KEY_UI_H */ |