mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
gpgsm: Add a way to save a found state.
* kbx/keybox-defs.h (keybox_found_s): New. (keybox_handle): Factor FOUND out to above. Add saved_found. * kbx/keybox-init.c (keybox_release): Release saved_found. (keybox_push_found_state, keybox_pop_found_state): New. * sm/keydb.c (keydb_handle): Add field saved_found. (keydb_new): Init it. (keydb_push_found_state, keydb_pop_found_state): New.
This commit is contained in:
parent
99972bd6e9
commit
42c043a8ad
5 changed files with 98 additions and 7 deletions
|
@ -85,6 +85,14 @@ struct keybox_name
|
|||
};
|
||||
|
||||
|
||||
struct keybox_found_s
|
||||
{
|
||||
KEYBOXBLOB blob;
|
||||
off_t offset;
|
||||
size_t pk_no;
|
||||
size_t uid_no;
|
||||
unsigned int n_packets; /*used for delete and update*/
|
||||
};
|
||||
|
||||
struct keybox_handle {
|
||||
CONST_KB_NAME kb;
|
||||
|
@ -93,13 +101,8 @@ struct keybox_handle {
|
|||
int eof;
|
||||
int error;
|
||||
int ephemeral;
|
||||
struct {
|
||||
KEYBOXBLOB blob;
|
||||
off_t offset;
|
||||
size_t pk_no;
|
||||
size_t uid_no;
|
||||
unsigned int n_packets; /*used for delete and update*/
|
||||
} found;
|
||||
struct keybox_found_s found;
|
||||
struct keybox_found_s saved_found;
|
||||
struct {
|
||||
char *name;
|
||||
char *pattern;
|
||||
|
|
|
@ -148,6 +148,7 @@ keybox_release (KEYBOX_HANDLE hd)
|
|||
hd->kb->handle_table[idx] = NULL;
|
||||
}
|
||||
_keybox_release_blob (hd->found.blob);
|
||||
_keybox_release_blob (hd->saved_found.blob);
|
||||
if (hd->fp)
|
||||
{
|
||||
fclose (hd->fp);
|
||||
|
@ -159,6 +160,35 @@ keybox_release (KEYBOX_HANDLE hd)
|
|||
}
|
||||
|
||||
|
||||
/* Save the current found state in HD for later retrieval by
|
||||
keybox_restore_found_state. Only one state may be saved. */
|
||||
void
|
||||
keybox_push_found_state (KEYBOX_HANDLE hd)
|
||||
{
|
||||
if (hd->saved_found.blob)
|
||||
{
|
||||
_keybox_release_blob (hd->saved_found.blob);
|
||||
hd->saved_found.blob = NULL;
|
||||
}
|
||||
hd->saved_found = hd->found;
|
||||
hd->found.blob = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* Restore the saved found state in HD. */
|
||||
void
|
||||
keybox_pop_found_state (KEYBOX_HANDLE hd)
|
||||
{
|
||||
if (hd->found.blob)
|
||||
{
|
||||
_keybox_release_blob (hd->found.blob);
|
||||
hd->found.blob = NULL;
|
||||
}
|
||||
hd->found = hd->saved_found;
|
||||
hd->saved_found.blob = NULL;
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
keybox_get_resource_name (KEYBOX_HANDLE hd)
|
||||
{
|
||||
|
|
|
@ -64,6 +64,8 @@ int keybox_is_writable (void *token);
|
|||
|
||||
KEYBOX_HANDLE keybox_new (void *token, int secret);
|
||||
void keybox_release (KEYBOX_HANDLE hd);
|
||||
void keybox_push_found_state (KEYBOX_HANDLE hd);
|
||||
void keybox_pop_found_state (KEYBOX_HANDLE hd);
|
||||
const char *keybox_get_resource_name (KEYBOX_HANDLE hd);
|
||||
int keybox_set_ephemeral (KEYBOX_HANDLE hd, int yes);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue