diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2005-10-18 20:50:52 (GMT) |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2005-10-18 20:50:52 (GMT) |
commit | cff6bf970965c98c62007fc8a36527fd147fe233 (patch) | |
tree | 2791f2208b54ade86625af416ff5342f11282f0c /include/linux/key-ui.h | |
parent | 6cd7525a00f3b926e8bd2e402954ed3e09a8e924 (diff) | |
parent | 39ca371c45b04cd50d0974030ae051906fc516b6 (diff) | |
download | linux-fsl-qoriq-cff6bf970965c98c62007fc8a36527fd147fe233.tar.xz |
Merge /home/trondmy/scm/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'include/linux/key-ui.h')
-rw-r--r-- | include/linux/key-ui.h | 87 |
1 files changed, 8 insertions, 79 deletions
diff --git a/include/linux/key-ui.h b/include/linux/key-ui.h index cc32617..7a2e332 100644 --- a/include/linux/key-ui.h +++ b/include/linux/key-ui.h @@ -38,92 +38,21 @@ struct keyring_list { struct key *keys[0]; }; - /* * check to see whether permission is granted to use a key in the desired way */ -static inline int key_permission(const struct key *key, key_perm_t perm) -{ - key_perm_t kperm; - - if (key->uid == current->fsuid) - kperm = key->perm >> 16; - else if (key->gid != -1 && - key->perm & KEY_GRP_ALL && - in_group_p(key->gid) - ) - kperm = key->perm >> 8; - else - kperm = key->perm; - - kperm = kperm & perm & KEY_ALL; - - return kperm == perm; -} - -/* - * check to see whether permission is granted to use a key in at least one of - * the desired ways - */ -static inline int key_any_permission(const struct key *key, key_perm_t perm) -{ - key_perm_t kperm; - - if (key->uid == current->fsuid) - kperm = key->perm >> 16; - else if (key->gid != -1 && - key->perm & KEY_GRP_ALL && - in_group_p(key->gid) - ) - kperm = key->perm >> 8; - else - kperm = key->perm; +extern int key_task_permission(const key_ref_t key_ref, + struct task_struct *context, + key_perm_t perm); - kperm = kperm & perm & KEY_ALL; - - return kperm != 0; -} - -static inline int key_task_groups_search(struct task_struct *tsk, gid_t gid) +static inline int key_permission(const key_ref_t key_ref, key_perm_t perm) { - int ret; - - task_lock(tsk); - ret = groups_search(tsk->group_info, gid); - task_unlock(tsk); - return ret; -} - -static inline int key_task_permission(const struct key *key, - struct task_struct *context, - key_perm_t perm) -{ - key_perm_t kperm; - - if (key->uid == context->fsuid) { - kperm = key->perm >> 16; - } - else if (key->gid != -1 && - key->perm & KEY_GRP_ALL && ( - key->gid == context->fsgid || - key_task_groups_search(context, key->gid) - ) - ) { - kperm = key->perm >> 8; - } - else { - kperm = key->perm; - } - - kperm = kperm & perm & KEY_ALL; - - return kperm == perm; - + return key_task_permission(key_ref, current, perm); } -extern struct key *lookup_user_key(struct task_struct *context, - key_serial_t id, int create, int partial, - key_perm_t perm); +extern key_ref_t lookup_user_key(struct task_struct *context, + key_serial_t id, int create, int partial, + key_perm_t perm); extern long join_session_keyring(const char *name); |