mirror of
git://git.gnupg.org/gnupg.git
synced 2024-11-11 21:48:50 +01:00
gpg: Pass CTRL parameter to all key listing functions.
* g10/keylist.c (public_key_list): Add arg CTRL. (secret_key_list): Ditto. (list_all, list_one): Ditto. (locate_one): Ditto. (list_keyblock_pka): Ditto. (list_keyblock): Ditto. (list_keyblock_direct): Ditto. * g10/keygen.c (proc_parameter_file): Add arg CTRL. (read_parameter_file): Ditto. (quick_generate_keypair): Ditto. (do_generate_keypair): Ditto. (generate_keypair): Pass arg CTRL. * g10/gpg.c (main): Pass arg CTRL to quick_generate_keypair. -- This will help use to implement the --server mode. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
a400958323
commit
b6d621583f
@ -3949,7 +3949,7 @@ main (int argc, char **argv)
|
|||||||
if (argc != 1 )
|
if (argc != 1 )
|
||||||
wrong_args("--gen-key user-id");
|
wrong_args("--gen-key user-id");
|
||||||
username = make_username (fname);
|
username = make_username (fname);
|
||||||
quick_generate_keypair (username);
|
quick_generate_keypair (ctrl, username);
|
||||||
xfree (username);
|
xfree (username);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
26
g10/keygen.c
26
g10/keygen.c
@ -135,7 +135,7 @@ static byte zip_prefs[MAX_PREFS];
|
|||||||
static int nzip_prefs;
|
static int nzip_prefs;
|
||||||
static int mdc_available,ks_modify;
|
static int mdc_available,ks_modify;
|
||||||
|
|
||||||
static void do_generate_keypair( struct para_data_s *para,
|
static void do_generate_keypair (ctrl_t ctrl, struct para_data_s *para,
|
||||||
struct output_control_s *outctrl, int card );
|
struct output_control_s *outctrl, int card );
|
||||||
static int write_keyblock (iobuf_t out, kbnode_t node);
|
static int write_keyblock (iobuf_t out, kbnode_t node);
|
||||||
static gpg_error_t gen_card_key (int algo, int keyno, int is_primary,
|
static gpg_error_t gen_card_key (int algo, int keyno, int is_primary,
|
||||||
@ -3036,7 +3036,7 @@ get_parameter_revkey( struct para_data_s *para, enum para_name key )
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
proc_parameter_file( struct para_data_s *para, const char *fname,
|
proc_parameter_file (ctrl_t ctrl, struct para_data_s *para, const char *fname,
|
||||||
struct output_control_s *outctrl, int card )
|
struct output_control_s *outctrl, int card )
|
||||||
{
|
{
|
||||||
struct para_data_s *r;
|
struct para_data_s *r;
|
||||||
@ -3222,7 +3222,7 @@ proc_parameter_file( struct para_data_s *para, const char *fname,
|
|||||||
append_to_parameter (para, r);
|
append_to_parameter (para, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
do_generate_keypair( para, outctrl, card );
|
do_generate_keypair (ctrl, para, outctrl, card );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3233,7 +3233,7 @@ proc_parameter_file( struct para_data_s *para, const char *fname,
|
|||||||
* Note, that string parameters are expected to be in UTF-8
|
* Note, that string parameters are expected to be in UTF-8
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
read_parameter_file( const char *fname )
|
read_parameter_file (ctrl_t ctrl, const char *fname )
|
||||||
{
|
{
|
||||||
static struct { const char *name;
|
static struct { const char *name;
|
||||||
enum para_name key;
|
enum para_name key;
|
||||||
@ -3328,7 +3328,7 @@ read_parameter_file( const char *fname )
|
|||||||
outctrl.keygen_flags |= KEYGEN_FLAG_TRANSIENT_KEY;
|
outctrl.keygen_flags |= KEYGEN_FLAG_TRANSIENT_KEY;
|
||||||
else if( !ascii_strcasecmp( keyword, "%commit" ) ) {
|
else if( !ascii_strcasecmp( keyword, "%commit" ) ) {
|
||||||
outctrl.lnr = lnr;
|
outctrl.lnr = lnr;
|
||||||
if (proc_parameter_file( para, fname, &outctrl, 0 ))
|
if (proc_parameter_file (ctrl, para, fname, &outctrl, 0 ))
|
||||||
print_status_key_not_created
|
print_status_key_not_created
|
||||||
(get_parameter_value (para, pHANDLE));
|
(get_parameter_value (para, pHANDLE));
|
||||||
release_parameter_list( para );
|
release_parameter_list( para );
|
||||||
@ -3384,7 +3384,7 @@ read_parameter_file( const char *fname )
|
|||||||
|
|
||||||
if( keywords[i].key == pKEYTYPE && para ) {
|
if( keywords[i].key == pKEYTYPE && para ) {
|
||||||
outctrl.lnr = lnr;
|
outctrl.lnr = lnr;
|
||||||
if (proc_parameter_file( para, fname, &outctrl, 0 ))
|
if (proc_parameter_file (ctrl, para, fname, &outctrl, 0 ))
|
||||||
print_status_key_not_created
|
print_status_key_not_created
|
||||||
(get_parameter_value (para, pHANDLE));
|
(get_parameter_value (para, pHANDLE));
|
||||||
release_parameter_list( para );
|
release_parameter_list( para );
|
||||||
@ -3414,7 +3414,7 @@ read_parameter_file( const char *fname )
|
|||||||
}
|
}
|
||||||
else if( para ) {
|
else if( para ) {
|
||||||
outctrl.lnr = lnr;
|
outctrl.lnr = lnr;
|
||||||
if (proc_parameter_file( para, fname, &outctrl, 0 ))
|
if (proc_parameter_file (ctrl, para, fname, &outctrl, 0 ))
|
||||||
print_status_key_not_created (get_parameter_value (para, pHANDLE));
|
print_status_key_not_created (get_parameter_value (para, pHANDLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3479,7 +3479,7 @@ quickgen_set_para (struct para_data_s *para, int for_subkey,
|
|||||||
* Unattended generation of a standard key.
|
* Unattended generation of a standard key.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
quick_generate_keypair (const char *uid)
|
quick_generate_keypair (ctrl_t ctrl, const char *uid)
|
||||||
{
|
{
|
||||||
gpg_error_t err;
|
gpg_error_t err;
|
||||||
struct para_data_s *para = NULL;
|
struct para_data_s *para = NULL;
|
||||||
@ -3569,7 +3569,7 @@ quick_generate_keypair (const char *uid)
|
|||||||
para = r;
|
para = r;
|
||||||
}
|
}
|
||||||
|
|
||||||
proc_parameter_file (para, "[internal]", &outctrl, 0);
|
proc_parameter_file (ctrl, para, "[internal]", &outctrl, 0);
|
||||||
leave:
|
leave:
|
||||||
release_parameter_list (para);
|
release_parameter_list (para);
|
||||||
}
|
}
|
||||||
@ -3613,7 +3613,7 @@ generate_keypair (ctrl_t ctrl, int full, const char *fname,
|
|||||||
|
|
||||||
if (opt.batch)
|
if (opt.batch)
|
||||||
{
|
{
|
||||||
read_parameter_file( fname );
|
read_parameter_file (ctrl, fname);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3841,7 +3841,7 @@ generate_keypair (ctrl_t ctrl, int full, const char *fname,
|
|||||||
r->next = para;
|
r->next = para;
|
||||||
para = r;
|
para = r;
|
||||||
|
|
||||||
proc_parameter_file (para, "[internal]", &outctrl, !!card_serialno);
|
proc_parameter_file (ctrl, para, "[internal]", &outctrl, !!card_serialno);
|
||||||
release_parameter_list (para);
|
release_parameter_list (para);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3958,7 +3958,7 @@ start_tree(KBNODE *tree)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_generate_keypair (struct para_data_s *para,
|
do_generate_keypair (ctrl_t ctrl, struct para_data_s *para,
|
||||||
struct output_control_s *outctrl, int card)
|
struct output_control_s *outctrl, int card)
|
||||||
{
|
{
|
||||||
gpg_error_t err;
|
gpg_error_t err;
|
||||||
@ -4192,7 +4192,7 @@ do_generate_keypair (struct para_data_s *para,
|
|||||||
{
|
{
|
||||||
tty_printf (_("public and secret key created and signed.\n") );
|
tty_printf (_("public and secret key created and signed.\n") );
|
||||||
tty_printf ("\n");
|
tty_printf ("\n");
|
||||||
list_keyblock_direct (pub_root, 0, 1, 1);
|
list_keyblock_direct (ctrl, pub_root, 0, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,8 +45,9 @@
|
|||||||
#include "mbox-util.h"
|
#include "mbox-util.h"
|
||||||
|
|
||||||
|
|
||||||
static void list_all (int, int);
|
static void list_all (ctrl_t, int, int);
|
||||||
static void list_one (strlist_t names, int secret, int mark_secret);
|
static void list_one (ctrl_t ctrl,
|
||||||
|
strlist_t names, int secret, int mark_secret);
|
||||||
static void locate_one (ctrl_t ctrl, strlist_t names);
|
static void locate_one (ctrl_t ctrl, strlist_t names);
|
||||||
static void print_card_serialno (const char *serialno);
|
static void print_card_serialno (const char *serialno);
|
||||||
|
|
||||||
@ -60,7 +61,8 @@ struct keylist_context
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static void list_keyblock (kbnode_t keyblock, int secret, int has_secret,
|
static void list_keyblock (ctrl_t ctrl,
|
||||||
|
kbnode_t keyblock, int secret, int has_secret,
|
||||||
int fpr, struct keylist_context *listctx);
|
int fpr, struct keylist_context *listctx);
|
||||||
|
|
||||||
|
|
||||||
@ -131,9 +133,9 @@ public_key_list (ctrl_t ctrl, strlist_t list, int locate_mode)
|
|||||||
if (locate_mode)
|
if (locate_mode)
|
||||||
locate_one (ctrl, list);
|
locate_one (ctrl, list);
|
||||||
else if (!list)
|
else if (!list)
|
||||||
list_all (0, opt.with_secret);
|
list_all (ctrl, 0, opt.with_secret);
|
||||||
else
|
else
|
||||||
list_one (list, 0, opt.with_secret);
|
list_one (ctrl, list, 0, opt.with_secret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -145,9 +147,9 @@ secret_key_list (ctrl_t ctrl, strlist_t list)
|
|||||||
check_trustdb_stale ();
|
check_trustdb_stale ();
|
||||||
|
|
||||||
if (!list)
|
if (!list)
|
||||||
list_all (1, 0);
|
list_all (ctrl, 1, 0);
|
||||||
else /* List by user id */
|
else /* List by user id */
|
||||||
list_one (list, 1, 0);
|
list_one (ctrl, list, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -466,7 +468,7 @@ print_signature_stats (struct keylist_context *s)
|
|||||||
MARK_SECRET is true secret keys are indicated in a public key
|
MARK_SECRET is true secret keys are indicated in a public key
|
||||||
listing. */
|
listing. */
|
||||||
static void
|
static void
|
||||||
list_all (int secret, int mark_secret)
|
list_all (ctrl_t ctrl, int secret, int mark_secret)
|
||||||
{
|
{
|
||||||
KEYDB_HANDLE hd;
|
KEYDB_HANDLE hd;
|
||||||
KBNODE keyblock = NULL;
|
KBNODE keyblock = NULL;
|
||||||
@ -527,7 +529,7 @@ list_all (int secret, int mark_secret)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
merge_keys_and_selfsig (keyblock);
|
merge_keys_and_selfsig (keyblock);
|
||||||
list_keyblock (keyblock, secret, any_secret, opt.fingerprint,
|
list_keyblock (ctrl, keyblock, secret, any_secret, opt.fingerprint,
|
||||||
&listctx);
|
&listctx);
|
||||||
}
|
}
|
||||||
release_kbnode (keyblock);
|
release_kbnode (keyblock);
|
||||||
@ -552,7 +554,7 @@ list_all (int secret, int mark_secret)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
list_one (strlist_t names, int secret, int mark_secret)
|
list_one (ctrl_t ctrl, strlist_t names, int secret, int mark_secret)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
KBNODE keyblock = NULL;
|
KBNODE keyblock = NULL;
|
||||||
@ -593,7 +595,8 @@ list_one (strlist_t names, int secret, int mark_secret)
|
|||||||
es_putc ('-', es_stdout);
|
es_putc ('-', es_stdout);
|
||||||
es_putc ('\n', es_stdout);
|
es_putc ('\n', es_stdout);
|
||||||
}
|
}
|
||||||
list_keyblock (keyblock, secret, mark_secret, opt.fingerprint, &listctx);
|
list_keyblock (ctrl,
|
||||||
|
keyblock, secret, mark_secret, opt.fingerprint, &listctx);
|
||||||
release_kbnode (keyblock);
|
release_kbnode (keyblock);
|
||||||
}
|
}
|
||||||
while (!getkey_next (ctx, NULL, &keyblock));
|
while (!getkey_next (ctx, NULL, &keyblock));
|
||||||
@ -634,7 +637,7 @@ locate_one (ctrl_t ctrl, strlist_t names)
|
|||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
list_keyblock (keyblock, 0, 0, opt.fingerprint, &listctx);
|
list_keyblock (ctrl, keyblock, 0, 0, opt.fingerprint, &listctx);
|
||||||
release_kbnode (keyblock);
|
release_kbnode (keyblock);
|
||||||
}
|
}
|
||||||
while (ctx && !getkey_next (ctx, NULL, &keyblock));
|
while (ctx && !getkey_next (ctx, NULL, &keyblock));
|
||||||
@ -837,7 +840,7 @@ dump_attribs (const PKT_user_id *uid, PKT_public_key *pk)
|
|||||||
|
|
||||||
/* Print IPGP cert records instead of a standard key listing. */
|
/* Print IPGP cert records instead of a standard key listing. */
|
||||||
static void
|
static void
|
||||||
list_keyblock_pka (kbnode_t keyblock)
|
list_keyblock_pka (ctrl_t ctrl, kbnode_t keyblock)
|
||||||
{
|
{
|
||||||
kbnode_t kbctx;
|
kbnode_t kbctx;
|
||||||
kbnode_t node;
|
kbnode_t node;
|
||||||
@ -1671,12 +1674,13 @@ reorder_keyblock (KBNODE keyblock)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
list_keyblock (KBNODE keyblock, int secret, int has_secret, int fpr,
|
list_keyblock (ctrl_t ctrl,
|
||||||
|
KBNODE keyblock, int secret, int has_secret, int fpr,
|
||||||
struct keylist_context *listctx)
|
struct keylist_context *listctx)
|
||||||
{
|
{
|
||||||
reorder_keyblock (keyblock);
|
reorder_keyblock (keyblock);
|
||||||
if (opt.print_pka_records)
|
if (opt.print_pka_records)
|
||||||
list_keyblock_pka (keyblock);
|
list_keyblock_pka (ctrl, keyblock);
|
||||||
else if (opt.with_colons)
|
else if (opt.with_colons)
|
||||||
list_keyblock_colon (keyblock, secret, has_secret, fpr);
|
list_keyblock_colon (keyblock, secret, has_secret, fpr);
|
||||||
else
|
else
|
||||||
@ -1688,12 +1692,13 @@ list_keyblock (KBNODE keyblock, int secret, int has_secret, int fpr,
|
|||||||
|
|
||||||
/* Public function used by keygen to list a keyblock. */
|
/* Public function used by keygen to list a keyblock. */
|
||||||
void
|
void
|
||||||
list_keyblock_direct (kbnode_t keyblock, int secret, int has_secret, int fpr)
|
list_keyblock_direct (ctrl_t ctrl,
|
||||||
|
kbnode_t keyblock, int secret, int has_secret, int fpr)
|
||||||
{
|
{
|
||||||
struct keylist_context listctx;
|
struct keylist_context listctx;
|
||||||
|
|
||||||
memset (&listctx, 0, sizeof (listctx));
|
memset (&listctx, 0, sizeof (listctx));
|
||||||
list_keyblock (keyblock, secret, has_secret, fpr, &listctx);
|
list_keyblock (ctrl, keyblock, secret, has_secret, fpr, &listctx);
|
||||||
keylist_context_release (&listctx);
|
keylist_context_release (&listctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@ void show_basic_key_info (KBNODE keyblock);
|
|||||||
u32 parse_expire_string(const char *string);
|
u32 parse_expire_string(const char *string);
|
||||||
u32 ask_expire_interval(int object,const char *def_expire);
|
u32 ask_expire_interval(int object,const char *def_expire);
|
||||||
u32 ask_expiredate(void);
|
u32 ask_expiredate(void);
|
||||||
void quick_generate_keypair (const char *uid);
|
void quick_generate_keypair (ctrl_t ctrl, const char *uid);
|
||||||
void generate_keypair (ctrl_t ctrl, int full, const char *fname,
|
void generate_keypair (ctrl_t ctrl, int full, const char *fname,
|
||||||
const char *card_serialno, int card_backup_key);
|
const char *card_serialno, int card_backup_key);
|
||||||
int keygen_set_std_prefs (const char *string,int personal);
|
int keygen_set_std_prefs (const char *string,int personal);
|
||||||
@ -347,8 +347,8 @@ void public_key_list (ctrl_t ctrl, strlist_t list, int locate_mode );
|
|||||||
void secret_key_list (ctrl_t ctrl, strlist_t list );
|
void secret_key_list (ctrl_t ctrl, strlist_t list );
|
||||||
void print_subpackets_colon(PKT_signature *sig);
|
void print_subpackets_colon(PKT_signature *sig);
|
||||||
void reorder_keyblock (KBNODE keyblock);
|
void reorder_keyblock (KBNODE keyblock);
|
||||||
void list_keyblock_direct (kbnode_t keyblock, int secret, int has_secret,
|
void list_keyblock_direct (ctrl_t ctrl, kbnode_t keyblock, int secret,
|
||||||
int fpr);
|
int has_secret, int fpr);
|
||||||
void print_fingerprint (estream_t fp, PKT_public_key *pk, int mode);
|
void print_fingerprint (estream_t fp, PKT_public_key *pk, int mode);
|
||||||
void print_revokers (estream_t fp, PKT_public_key *pk);
|
void print_revokers (estream_t fp, PKT_public_key *pk);
|
||||||
void show_policy_url(PKT_signature *sig,int indent,int mode);
|
void show_policy_url(PKT_signature *sig,int indent,int mode);
|
||||||
|
Loading…
Reference in New Issue
Block a user