Convert ERR_PTR(PTR_ERR(p)) instances to ERR_CAST(p)
[safe/jmp/linux-2.6] / security / keys / internal.h
index 67b2b93..d36d693 100644 (file)
@@ -1,6 +1,6 @@
 /* internal.h: authentication token and access key management internal defs
  *
- * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
+ * Copyright (C) 2003-5, 2007 Red Hat, Inc. All Rights Reserved.
  * Written by David Howells (dhowells@redhat.com)
  *
  * This program is free software; you can redistribute it and/or
 #ifndef _INTERNAL_H
 #define _INTERNAL_H
 
-#include <linux/key.h>
+#include <linux/key-type.h>
 #include <linux/key-ui.h>
 
-extern struct key_type key_type_dead;
+static inline __attribute__((format(printf, 1, 2)))
+void no_printk(const char *fmt, ...)
+{
+}
+
+#ifdef __KDEBUG
+#define kenter(FMT, ...) \
+       printk(KERN_DEBUG "==> %s("FMT")\n", __FUNCTION__, ##__VA_ARGS__)
+#define kleave(FMT, ...) \
+       printk(KERN_DEBUG "<== %s()"FMT"\n", __FUNCTION__, ##__VA_ARGS__)
+#define kdebug(FMT, ...) \
+       printk(KERN_DEBUG "xxx" FMT"yyy\n", ##__VA_ARGS__)
+#else
+#define kenter(FMT, ...) \
+       no_printk(KERN_DEBUG "==> %s("FMT")\n", __FUNCTION__, ##__VA_ARGS__)
+#define kleave(FMT, ...) \
+       no_printk(KERN_DEBUG "<== %s()"FMT"\n", __FUNCTION__, ##__VA_ARGS__)
+#define kdebug(FMT, ...) \
+       no_printk(KERN_DEBUG FMT"\n", ##__VA_ARGS__)
+#endif
+
 extern struct key_type key_type_user;
 
 /*****************************************************************************/
@@ -27,7 +47,7 @@ extern struct key_type key_type_user;
  */
 struct key_user {
        struct rb_node          node;
-       struct list_head        consq;          /* construction queue */
+       struct mutex            cons_lock;      /* construction initiation lock */
        spinlock_t              lock;
        atomic_t                usage;          /* for accessing qnkeys & qnbytes */
        atomic_t                nkeys;          /* number of keys */
@@ -53,7 +73,7 @@ extern void key_user_put(struct key_user *user);
 extern struct rb_root key_serial_tree;
 extern spinlock_t key_serial_lock;
 extern struct semaphore key_alloc_sem;
-extern struct rw_semaphore key_construction_sem;
+extern struct mutex key_construction_mutex;
 extern wait_queue_head_t request_key_conswq;
 
 
@@ -61,25 +81,54 @@ extern void keyring_publish_name(struct key *keyring);
 
 extern int __key_link(struct key *keyring, struct key *key);
 
-extern struct key *__keyring_search_one(struct key *keyring,
-                                       const struct key_type *type,
-                                       const char *description,
-                                       key_perm_t perm);
+extern key_ref_t __keyring_search_one(key_ref_t keyring_ref,
+                                     const struct key_type *type,
+                                     const char *description,
+                                     key_perm_t perm);
+
+extern struct key *keyring_search_instkey(struct key *keyring,
+                                         key_serial_t target_id);
 
 typedef int (*key_match_func_t)(const struct key *, const void *);
 
-extern struct key *keyring_search_aux(struct key *keyring,
-                                     struct key_type *type,
-                                     const void *description,
-                                     key_match_func_t match);
+extern key_ref_t keyring_search_aux(key_ref_t keyring_ref,
+                                   struct task_struct *tsk,
+                                   struct key_type *type,
+                                   const void *description,
+                                   key_match_func_t match);
 
-extern struct key *search_process_keyrings_aux(struct key_type *type,
-                                              const void *description,
-                                              key_match_func_t match);
+extern key_ref_t search_process_keyrings(struct key_type *type,
+                                        const void *description,
+                                        key_match_func_t match,
+                                        struct task_struct *tsk);
 
 extern struct key *find_keyring_by_name(const char *name, key_serial_t bound);
 
 extern int install_thread_keyring(struct task_struct *tsk);
+extern int install_process_keyring(struct task_struct *tsk);
+
+extern struct key *request_key_and_link(struct key_type *type,
+                                       const char *description,
+                                       const char *callout_info,
+                                       void *aux,
+                                       struct key *dest_keyring,
+                                       unsigned long flags);
+
+/*
+ * request_key authorisation
+ */
+struct request_key_auth {
+       struct key              *target_key;
+       struct task_struct      *context;
+       char                    *callout_info;
+       pid_t                   pid;
+};
+
+extern struct key_type key_type_request_key_auth;
+extern struct key *request_key_auth_new(struct key *target,
+                                       const char *callout_info);
+
+extern struct key *key_get_instantiation_authkey(key_serial_t target_id);
 
 /*
  * keyctl functions
@@ -100,6 +149,9 @@ extern long keyctl_setperm_key(key_serial_t, key_perm_t);
 extern long keyctl_instantiate_key(key_serial_t, const void __user *,
                                   size_t, key_serial_t);
 extern long keyctl_negate_key(key_serial_t, unsigned, key_serial_t);
+extern long keyctl_set_reqkey_keyring(int);
+extern long keyctl_set_timeout(key_serial_t, unsigned);
+extern long keyctl_assume_authority(key_serial_t);
 
 
 /*