mirror of
git://git.gnupg.org/gnupg.git
synced 2025-03-02 21:11:05 +01:00
* getkey.c (get_user_id_native): Renamed to ..
(get_user_id_printable): this. Filter out all dangerous characters. Checked all usages. (get_user_id_string_native): Renamed to.. (get_user_id_string_printable): this. Filter out all dangerous characters. Checked all usages. * keyedit.c (show_basic_key_info): New. * keylist.c (print_fingerprint): New mode 3. * import.c (import_one): Use new function to display the user ID.
This commit is contained in:
parent
5201d1ec9d
commit
89f8e7ef36
@ -1,6 +1,18 @@
|
||||
2002-08-19 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* getkey.c (get_user_id_native): Renamed to ..
|
||||
(get_user_id_printable): this. Filter out all dangerous
|
||||
characters. Checked all usages.
|
||||
(get_user_id_string_native): Renamed to..
|
||||
(get_user_id_string_printable): this. Filter out all dangerous
|
||||
characters. Checked all usages.
|
||||
* keyedit.c (show_basic_key_info): New.
|
||||
* keylist.c (print_fingerprint): New mode 3.
|
||||
* import.c (import_one): Use new function to display the user ID.
|
||||
|
||||
2002-08-16 Timo Schulz <ts@winpt.org>
|
||||
|
||||
* g10.c (main): enable opt.interactive.
|
||||
* g10.c (main): Enable opt.interactive.
|
||||
|
||||
* import.c (import_one): Ask the user if the key shall be
|
||||
imported when the interactive mode is used. Useful to extract
|
||||
|
@ -719,8 +719,8 @@ write_pubkey_enc_from_list( PK_LIST pk_list, DEK *dek, IOBUF out )
|
||||
log_error("pubkey_encrypt failed: %s\n", g10_errstr(rc) );
|
||||
else {
|
||||
if( opt.verbose ) {
|
||||
char *ustr = get_user_id_string_native( enc->keyid );
|
||||
log_info(_("%s/%s encrypted for: %s\n"),
|
||||
char *ustr = get_user_id_string_printable (enc->keyid);
|
||||
log_info(_("%s/%s encrypted for: \"%s\"\n"),
|
||||
pubkey_algo_to_string(enc->pubkey_algo),
|
||||
cipher_algo_to_string(dek->algo), ustr );
|
||||
m_free(ustr);
|
||||
|
17
g10/getkey.c
17
g10/getkey.c
@ -2323,13 +2323,14 @@ get_user_id_string( u32 *keyid )
|
||||
|
||||
|
||||
char*
|
||||
get_user_id_string_native( u32 *keyid )
|
||||
get_user_id_string_printable ( u32 *keyid )
|
||||
{
|
||||
char *p = get_user_id_string( keyid );
|
||||
char *p2 = utf8_to_native( p, strlen(p), 0 );
|
||||
|
||||
m_free(p);
|
||||
return p2;
|
||||
p = make_printable_string (p2, strlen (p2), 0);
|
||||
m_free (p2);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
@ -2386,17 +2387,19 @@ get_user_id( u32 *keyid, size_t *rn )
|
||||
}
|
||||
|
||||
char*
|
||||
get_user_id_native( u32 *keyid )
|
||||
get_user_id_printable( u32 *keyid )
|
||||
{
|
||||
size_t rn;
|
||||
|
||||
char *p = get_user_id( keyid, &rn );
|
||||
char *p2 = utf8_to_native( p, rn, 0 );
|
||||
|
||||
m_free(p);
|
||||
return p2;
|
||||
p = make_printable_string (p2, strlen (p2), 0);
|
||||
m_free (p2);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
|
||||
KEYDB_HANDLE
|
||||
get_ctx_handle(GETKEY_CTX ctx)
|
||||
{
|
||||
|
29
g10/import.c
29
g10/import.c
@ -34,6 +34,7 @@
|
||||
#include "trustdb.h"
|
||||
#include "main.h"
|
||||
#include "i18n.h"
|
||||
#include "ttyio.h"
|
||||
#include "status.h"
|
||||
#include "keyserver-internal.h"
|
||||
|
||||
@ -643,21 +644,13 @@ import_one( const char *fname, KBNODE keyblock, int fast,
|
||||
}
|
||||
|
||||
if (opt.interactive) {
|
||||
char *prompt, *p;
|
||||
size_t n = 0;
|
||||
|
||||
p = get_user_id( pk->keyid, &n );
|
||||
prompt = m_alloc( n + 16 + 128 + 1 );
|
||||
snprintf( prompt, n + 16 + 128,
|
||||
"Do you want to import %08lX \"%s\" ? (y/n) ",
|
||||
(ulong)keyid[1], p );
|
||||
m_free( p );
|
||||
if( !cpr_get_answer_is_yes( "import.okay", prompt ) ) {
|
||||
m_free( prompt );
|
||||
tty_printf ("\n");
|
||||
show_basic_key_info (keyblock);
|
||||
tty_printf ("\n");
|
||||
if (!cpr_get_answer_is_yes ("import.okay",
|
||||
"Do you want to import this key? (y/N) "))
|
||||
return 0;
|
||||
}
|
||||
m_free( prompt );
|
||||
}
|
||||
|
||||
clear_kbnode_flags( keyblock );
|
||||
|
||||
@ -728,7 +721,7 @@ import_one( const char *fname, KBNODE keyblock, int fast,
|
||||
|
||||
/* we are ready */
|
||||
if( !opt.quiet ) {
|
||||
char *p=get_user_id_native(keyid);
|
||||
char *p=get_user_id_printable (keyid);
|
||||
log_info( _("key %08lX: public key \"%s\" imported\n"),
|
||||
(ulong)keyid[1],p);
|
||||
m_free(p);
|
||||
@ -804,7 +797,7 @@ import_one( const char *fname, KBNODE keyblock, int fast,
|
||||
|
||||
/* we are ready */
|
||||
if( !opt.quiet ) {
|
||||
char *p=get_user_id_native(keyid);
|
||||
char *p=get_user_id_printable(keyid);
|
||||
if( n_uids == 1 )
|
||||
log_info( _("key %08lX: \"%s\" 1 new user ID\n"),
|
||||
(ulong)keyid[1], p);
|
||||
@ -832,7 +825,7 @@ import_one( const char *fname, KBNODE keyblock, int fast,
|
||||
}
|
||||
else {
|
||||
if( !opt.quiet ) {
|
||||
char *p=get_user_id_native(keyid);
|
||||
char *p=get_user_id_printable(keyid);
|
||||
log_info( _("key %08lX: \"%s\" not changed\n"),
|
||||
(ulong)keyid[1],p);
|
||||
m_free(p);
|
||||
@ -1023,7 +1016,7 @@ import_revoke_cert( const char *fname, KBNODE node, struct stats_s *stats )
|
||||
keydb_release (hd); hd = NULL;
|
||||
/* we are ready */
|
||||
if( !opt.quiet ) {
|
||||
char *p=get_user_id_native(keyid);
|
||||
char *p=get_user_id_printable (keyid);
|
||||
log_info( _("key %08lX: \"%s\" revocation certificate imported\n"),
|
||||
(ulong)keyid[1],p);
|
||||
m_free(p);
|
||||
@ -1445,7 +1438,7 @@ merge_blocks( const char *fname, KBNODE keyblock_orig, KBNODE keyblock,
|
||||
}
|
||||
}
|
||||
if( !found ) {
|
||||
char *p=get_user_id_native(keyid);
|
||||
char *p=get_user_id_printable (keyid);
|
||||
KBNODE n2 = clone_kbnode(node);
|
||||
insert_kbnode( keyblock_orig, n2, 0 );
|
||||
n2->flag |= 1;
|
||||
|
@ -215,10 +215,10 @@ void get_seckey_end( GETKEY_CTX ctx );
|
||||
int enum_secret_keys( void **context, PKT_secret_key *sk, int with_subkeys );
|
||||
void merge_keys_and_selfsig( KBNODE keyblock );
|
||||
char*get_user_id_string( u32 *keyid );
|
||||
char*get_user_id_string_native( u32 *keyid );
|
||||
char*get_user_id_string_printable( u32 *keyid );
|
||||
char*get_long_user_id_string( u32 *keyid );
|
||||
char*get_user_id( u32 *keyid, size_t *rn );
|
||||
char*get_user_id_native( u32 *keyid );
|
||||
char*get_user_id_printable( u32 *keyid );
|
||||
KEYDB_HANDLE get_ctx_handle(GETKEY_CTX ctx);
|
||||
|
||||
/*-- keyid.c --*/
|
||||
|
@ -1845,6 +1845,74 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, int with_revoker,
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Display basic key information. This fucntion is suitable to show
|
||||
information on the key without any dependencies on the trustdb or
|
||||
any other internal GnuPG stuff. KEYBLOCK may either be a public or
|
||||
a secret key.*/
|
||||
void
|
||||
show_basic_key_info ( KBNODE keyblock )
|
||||
{
|
||||
KBNODE node;
|
||||
int i;
|
||||
|
||||
/* The primary key */
|
||||
for (node = keyblock; node; node = node->next)
|
||||
{
|
||||
if (node->pkt->pkttype == PKT_PUBLIC_KEY)
|
||||
{
|
||||
PKT_public_key *pk = node->pkt->pkt.public_key;
|
||||
|
||||
/* Note, we use the same format string as in other show
|
||||
functions to make the translation job easier. */
|
||||
tty_printf (_("%s%c %4u%c/%08lX created: %s expires: %s"),
|
||||
node->pkt->pkttype == PKT_PUBLIC_KEY? "pub":"sub",
|
||||
' ',
|
||||
nbits_from_pk( pk ),
|
||||
pubkey_letter( pk->pubkey_algo ),
|
||||
(ulong)keyid_from_pk(pk,NULL),
|
||||
datestr_from_pk(pk),
|
||||
expirestr_from_pk(pk) );
|
||||
tty_printf("\n");
|
||||
print_fingerprint ( pk, NULL, 3 );
|
||||
tty_printf("\n");
|
||||
}
|
||||
else if (node->pkt->pkttype == PKT_SECRET_KEY)
|
||||
{
|
||||
PKT_secret_key *sk = node->pkt->pkt.secret_key;
|
||||
tty_printf(_("%s%c %4u%c/%08lX created: %s expires: %s"),
|
||||
node->pkt->pkttype == PKT_SECRET_KEY? "sec":"ssb",
|
||||
' ',
|
||||
nbits_from_sk( sk ),
|
||||
pubkey_letter( sk->pubkey_algo ),
|
||||
(ulong)keyid_from_sk(sk,NULL),
|
||||
datestr_from_sk(sk),
|
||||
expirestr_from_sk(sk) );
|
||||
tty_printf("\n");
|
||||
print_fingerprint (NULL, sk, 3 );
|
||||
tty_printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* The user IDs. */
|
||||
for (i=0, node = keyblock; node; node = node->next)
|
||||
{
|
||||
if (node->pkt->pkttype == PKT_USER_ID)
|
||||
{
|
||||
PKT_user_id *uid = node->pkt->pkt.user_id;
|
||||
++i;
|
||||
|
||||
tty_printf (" ");
|
||||
if (uid->is_revoked)
|
||||
tty_printf ("[revoked] ");
|
||||
if ( uid->is_expired )
|
||||
tty_printf ("[expired] ");
|
||||
tty_print_utf8_string (uid->name, uid->len);
|
||||
tty_printf ("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
show_key_and_fingerprint( KBNODE keyblock )
|
||||
{
|
||||
|
@ -940,6 +940,7 @@ list_keyblock( KBNODE keyblock, int secret, int fpr, void *opaque )
|
||||
* mode 0: as used in key listings, opt.with_colons is honored
|
||||
* 1: print using log_info ()
|
||||
* 2: direct use of tty
|
||||
* 3: direct use of tty but only primary key.
|
||||
* modes 1 and 2 will try and print both subkey and primary key fingerprints
|
||||
*/
|
||||
void
|
||||
@ -1005,6 +1006,10 @@ print_fingerprint (PKT_public_key *pk, PKT_secret_key *sk, int mode )
|
||||
else
|
||||
text = _(" Subkey fingerprint:");
|
||||
}
|
||||
else if (mode == 3) {
|
||||
fp = NULL; /* use tty */
|
||||
text = _(" Key fingerprint =");
|
||||
}
|
||||
else {
|
||||
fp = stdout;
|
||||
text = _(" Key fingerprint =");
|
||||
|
@ -117,6 +117,7 @@ int delete_keys( STRLIST names, int secret, int allow_both );
|
||||
/*-- keyedit.c --*/
|
||||
void keyedit_menu( const char *username, STRLIST locusr, STRLIST cmds,
|
||||
int sign_mode );
|
||||
void show_basic_key_info (KBNODE keyblock);
|
||||
|
||||
/*-- keygen.c --*/
|
||||
u32 ask_expire_interval(int object);
|
||||
|
@ -308,8 +308,8 @@ do_sign( PKT_secret_key *sk, PKT_signature *sig,
|
||||
log_error(_("signing failed: %s\n"), g10_errstr(rc) );
|
||||
else {
|
||||
if( opt.verbose ) {
|
||||
char *ustr = get_user_id_string( sig->keyid );
|
||||
log_info(_("%s signature from: %s\n"),
|
||||
char *ustr = get_user_id_string_printable (sig->keyid);
|
||||
log_info(_("%s signature from: \"%s\"\n"),
|
||||
pubkey_algo_to_string(sk->pubkey_algo), ustr );
|
||||
m_free(ustr);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user