diff options
author | David Howells <dhowells@redhat.com> | 2008-11-13 18:39:17 -0500 |
---|---|---|
committer | James Morris <jmorris@namei.org> | 2008-11-13 18:39:17 -0500 |
commit | f1752eec6145c97163dbce62d17cf5d928e28a27 (patch) | |
tree | 16bc51166d38815092de36a461b845b0b4b522f9 /include/linux/cred.h | |
parent | b6dff3ec5e116e3af6f537d4caedcad6b9e5082a (diff) |
CRED: Detach the credentials from task_struct
Detach the credentials from task_struct, duplicating them in copy_process()
and releasing them in __put_task_struct().
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: James Morris <jmorris@namei.org>
Acked-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'include/linux/cred.h')
-rw-r--r-- | include/linux/cred.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/include/linux/cred.h b/include/linux/cred.h index 3e65587a72e5..a7a686074cb0 100644 --- a/include/linux/cred.h +++ b/include/linux/cred.h | |||
@@ -158,4 +158,33 @@ do { \ | |||
158 | *(_gid) = current->cred->fsgid; \ | 158 | *(_gid) = current->cred->fsgid; \ |
159 | } while(0) | 159 | } while(0) |
160 | 160 | ||
161 | extern void __put_cred(struct cred *); | ||
162 | extern int copy_creds(struct task_struct *, unsigned long); | ||
163 | |||
164 | /** | ||
165 | * get_cred - Get a reference on a set of credentials | ||
166 | * @cred: The credentials to reference | ||
167 | * | ||
168 | * Get a reference on the specified set of credentials. The caller must | ||
169 | * release the reference. | ||
170 | */ | ||
171 | static inline struct cred *get_cred(struct cred *cred) | ||
172 | { | ||
173 | atomic_inc(&cred->usage); | ||
174 | return cred; | ||
175 | } | ||
176 | |||
177 | /** | ||
178 | * put_cred - Release a reference to a set of credentials | ||
179 | * @cred: The credentials to release | ||
180 | * | ||
181 | * Release a reference to a set of credentials, deleting them when the last ref | ||
182 | * is released. | ||
183 | */ | ||
184 | static inline void put_cred(struct cred *cred) | ||
185 | { | ||
186 | if (atomic_dec_and_test(&(cred)->usage)) | ||
187 | __put_cred(cred); | ||
188 | } | ||
189 | |||
161 | #endif /* _LINUX_CRED_H */ | 190 | #endif /* _LINUX_CRED_H */ |