aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/key-ui.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/linux/key-ui.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/linux/key-ui.h')
-rw-r--r--include/linux/key-ui.h97
1 files changed, 97 insertions, 0 deletions
diff --git a/include/linux/key-ui.h b/include/linux/key-ui.h
new file mode 100644
index 000000000000..60cc7b762e78
--- /dev/null
+++ b/include/linux/key-ui.h
@@ -0,0 +1,97 @@
1/* key-ui.h: key userspace interface stuff for use by keyfs
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 */
18extern struct rb_root key_serial_tree;
19extern 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 */
33struct keyring_list {
34 unsigned maxkeys; /* max keys this list can hold */
35 unsigned nkeys; /* number of keys currently held */
36 struct key *keys[0];
37};
38
39
40/*
41 * check to see whether permission is granted to use a key in the desired way
42 */
43static inline int key_permission(const struct key *key, key_perm_t perm)
44{
45 key_perm_t kperm;
46
47 if (key->uid == current->fsuid)
48 kperm = key->perm >> 16;
49 else if (key->gid != -1 &&
50 key->perm & KEY_GRP_ALL &&
51 in_group_p(key->gid)
52 )
53 kperm = key->perm >> 8;
54 else
55 kperm = key->perm;
56
57 kperm = kperm & perm & KEY_ALL;
58
59 return kperm == perm;
60}
61
62/*
63 * check to see whether permission is granted to use a key in at least one of
64 * the desired ways
65 */
66static inline int key_any_permission(const struct key *key, key_perm_t perm)
67{
68 key_perm_t kperm;
69
70 if (key->uid == current->fsuid)
71 kperm = key->perm >> 16;
72 else if (key->gid != -1 &&
73 key->perm & KEY_GRP_ALL &&
74 in_group_p(key->gid)
75 )
76 kperm = key->perm >> 8;
77 else
78 kperm = key->perm;
79
80 kperm = kperm & perm & KEY_ALL;
81
82 return kperm != 0;
83}
84
85
86extern struct key *lookup_user_key(key_serial_t id, int create, int part,
87 key_perm_t perm);
88
89extern long join_session_keyring(const char *name);
90
91extern struct key_type *key_type_lookup(const char *type);
92extern void key_type_put(struct key_type *ktype);
93
94#define key_negative_timeout 60 /* default timeout on a negative key's existence */
95
96
97#endif /* _LINUX_KEY_UI_H */