mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 13:11:40 +00:00
cf7f601c06
Give the key type the opportunity to preparse the payload prior to the instantiation and update routines being called. This is done with the provision of two new key type operations: int (*preparse)(struct key_preparsed_payload *prep); void (*free_preparse)(struct key_preparsed_payload *prep); If the first operation is present, then it is called before key creation (in the add/update case) or before the key semaphore is taken (in the update and instantiate cases). The second operation is called to clean up if the first was called. preparse() is given the opportunity to fill in the following structure: struct key_preparsed_payload { char *description; void *type_data[2]; void *payload; const void *data; size_t datalen; size_t quotalen; }; Before the preparser is called, the first three fields will have been cleared, the payload pointer and size will be stored in data and datalen and the default quota size from the key_type struct will be stored into quotalen. The preparser may parse the payload in any way it likes and may store data in the type_data[] and payload fields for use by the instantiate() and update() ops. The preparser may also propose a description for the key by attaching it as a string to the description field. This can be used by passing a NULL or "" description to the add_key() system call or the key_create_or_update() function. This cannot work with request_key() as that required the description to tell the upcall about the key to be created. This, for example permits keys that store PGP public keys to generate their own name from the user ID and public key fingerprint in the key. The instantiate() and update() operations are then modified to look like this: int (*instantiate)(struct key *key, struct key_preparsed_payload *prep); int (*update)(struct key *key, struct key_preparsed_payload *prep); and the new payload data is passed in *prep, whether or not it was preparsed. Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
51 lines
1.8 KiB
C
51 lines
1.8 KiB
C
/* user-type.h: User-defined key type
|
|
*
|
|
* Copyright (C) 2005 Red Hat, Inc. All Rights Reserved.
|
|
* Written by David Howells (dhowells@redhat.com)
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version
|
|
* 2 of the License, or (at your option) any later version.
|
|
*/
|
|
|
|
#ifndef _KEYS_USER_TYPE_H
|
|
#define _KEYS_USER_TYPE_H
|
|
|
|
#include <linux/key.h>
|
|
#include <linux/rcupdate.h>
|
|
|
|
/*****************************************************************************/
|
|
/*
|
|
* the payload for a key of type "user" or "logon"
|
|
* - once filled in and attached to a key:
|
|
* - the payload struct is invariant may not be changed, only replaced
|
|
* - the payload must be read with RCU procedures or with the key semaphore
|
|
* held
|
|
* - the payload may only be replaced with the key semaphore write-locked
|
|
* - the key's data length is the size of the actual data, not including the
|
|
* payload wrapper
|
|
*/
|
|
struct user_key_payload {
|
|
struct rcu_head rcu; /* RCU destructor */
|
|
unsigned short datalen; /* length of this data */
|
|
char data[0]; /* actual data */
|
|
};
|
|
|
|
extern struct key_type key_type_user;
|
|
extern struct key_type key_type_logon;
|
|
|
|
struct key_preparsed_payload;
|
|
|
|
extern int user_instantiate(struct key *key, struct key_preparsed_payload *prep);
|
|
extern int user_update(struct key *key, struct key_preparsed_payload *prep);
|
|
extern int user_match(const struct key *key, const void *criterion);
|
|
extern void user_revoke(struct key *key);
|
|
extern void user_destroy(struct key *key);
|
|
extern void user_describe(const struct key *user, struct seq_file *m);
|
|
extern long user_read(const struct key *key,
|
|
char __user *buffer, size_t buflen);
|
|
|
|
|
|
#endif /* _KEYS_USER_TYPE_H */
|