key-ui.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* key-ui.h: key userspace interface stuff
  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. #ifndef _LINUX_KEY_UI_H
  12. #define _LINUX_KEY_UI_H
  13. #include <linux/key.h>
  14. /* the key tree */
  15. extern struct rb_root key_serial_tree;
  16. extern spinlock_t key_serial_lock;
  17. /* required permissions */
  18. #define KEY_VIEW 0x01 /* require permission to view attributes */
  19. #define KEY_READ 0x02 /* require permission to read content */
  20. #define KEY_WRITE 0x04 /* require permission to update / modify */
  21. #define KEY_SEARCH 0x08 /* require permission to search (keyring) or find (key) */
  22. #define KEY_LINK 0x10 /* require permission to link */
  23. #define KEY_SETATTR 0x20 /* require permission to change attributes */
  24. #define KEY_ALL 0x3f /* all the above permissions */
  25. /*
  26. * the keyring payload contains a list of the keys to which the keyring is
  27. * subscribed
  28. */
  29. struct keyring_list {
  30. struct rcu_head rcu; /* RCU deletion hook */
  31. unsigned short maxkeys; /* max keys this list can hold */
  32. unsigned short nkeys; /* number of keys currently held */
  33. unsigned short delkey; /* key to be unlinked by RCU */
  34. struct key *keys[0];
  35. };
  36. /*
  37. * check to see whether permission is granted to use a key in the desired way
  38. */
  39. extern int key_task_permission(const key_ref_t key_ref,
  40. struct task_struct *context,
  41. key_perm_t perm);
  42. static inline int key_permission(const key_ref_t key_ref, key_perm_t perm)
  43. {
  44. return key_task_permission(key_ref, current, perm);
  45. }
  46. extern key_ref_t lookup_user_key(struct task_struct *context,
  47. key_serial_t id, int create, int partial,
  48. key_perm_t perm);
  49. extern long join_session_keyring(const char *name);
  50. extern struct key_type *key_type_lookup(const char *type);
  51. extern void key_type_put(struct key_type *ktype);
  52. #define key_negative_timeout 60 /* default timeout on a negative key's existence */
  53. #endif /* _LINUX_KEY_UI_H */