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>
|
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
|
* import.c (import_one): Ask the user if the key shall be
|
||||||
imported when the interactive mode is used. Useful to extract
|
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) );
|
log_error("pubkey_encrypt failed: %s\n", g10_errstr(rc) );
|
||||||
else {
|
else {
|
||||||
if( opt.verbose ) {
|
if( opt.verbose ) {
|
||||||
char *ustr = get_user_id_string_native( enc->keyid );
|
char *ustr = get_user_id_string_printable (enc->keyid);
|
||||||
log_info(_("%s/%s encrypted for: %s\n"),
|
log_info(_("%s/%s encrypted for: \"%s\"\n"),
|
||||||
pubkey_algo_to_string(enc->pubkey_algo),
|
pubkey_algo_to_string(enc->pubkey_algo),
|
||||||
cipher_algo_to_string(dek->algo), ustr );
|
cipher_algo_to_string(dek->algo), ustr );
|
||||||
m_free(ustr);
|
m_free(ustr);
|
||||||
|
17
g10/getkey.c
17
g10/getkey.c
@ -2323,13 +2323,14 @@ get_user_id_string( u32 *keyid )
|
|||||||
|
|
||||||
|
|
||||||
char*
|
char*
|
||||||
get_user_id_string_native( u32 *keyid )
|
get_user_id_string_printable ( u32 *keyid )
|
||||||
{
|
{
|
||||||
char *p = get_user_id_string( keyid );
|
char *p = get_user_id_string( keyid );
|
||||||
char *p2 = utf8_to_native( p, strlen(p), 0 );
|
char *p2 = utf8_to_native( p, strlen(p), 0 );
|
||||||
|
|
||||||
m_free(p);
|
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*
|
char*
|
||||||
get_user_id_native( u32 *keyid )
|
get_user_id_printable( u32 *keyid )
|
||||||
{
|
{
|
||||||
size_t rn;
|
size_t rn;
|
||||||
|
|
||||||
char *p = get_user_id( keyid, &rn );
|
char *p = get_user_id( keyid, &rn );
|
||||||
char *p2 = utf8_to_native( p, rn, 0 );
|
char *p2 = utf8_to_native( p, rn, 0 );
|
||||||
|
|
||||||
m_free(p);
|
m_free(p);
|
||||||
return p2;
|
p = make_printable_string (p2, strlen (p2), 0);
|
||||||
|
m_free (p2);
|
||||||
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
KEYDB_HANDLE
|
KEYDB_HANDLE
|
||||||
get_ctx_handle(GETKEY_CTX ctx)
|
get_ctx_handle(GETKEY_CTX ctx)
|
||||||
{
|
{
|
||||||
|
31
g10/import.c
31
g10/import.c
@ -34,6 +34,7 @@
|
|||||||
#include "trustdb.h"
|
#include "trustdb.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
|
#include "ttyio.h"
|
||||||
#include "status.h"
|
#include "status.h"
|
||||||
#include "keyserver-internal.h"
|
#include "keyserver-internal.h"
|
||||||
|
|
||||||
@ -642,21 +643,13 @@ import_one( const char *fname, KBNODE keyblock, int fast,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( opt.interactive ) {
|
if (opt.interactive) {
|
||||||
char *prompt, *p;
|
tty_printf ("\n");
|
||||||
size_t n = 0;
|
show_basic_key_info (keyblock);
|
||||||
|
tty_printf ("\n");
|
||||||
p = get_user_id( pk->keyid, &n );
|
if (!cpr_get_answer_is_yes ("import.okay",
|
||||||
prompt = m_alloc( n + 16 + 128 + 1 );
|
"Do you want to import this key? (y/N) "))
|
||||||
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 );
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
m_free( prompt );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
clear_kbnode_flags( keyblock );
|
clear_kbnode_flags( keyblock );
|
||||||
@ -728,7 +721,7 @@ import_one( const char *fname, KBNODE keyblock, int fast,
|
|||||||
|
|
||||||
/* we are ready */
|
/* we are ready */
|
||||||
if( !opt.quiet ) {
|
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"),
|
log_info( _("key %08lX: public key \"%s\" imported\n"),
|
||||||
(ulong)keyid[1],p);
|
(ulong)keyid[1],p);
|
||||||
m_free(p);
|
m_free(p);
|
||||||
@ -804,7 +797,7 @@ import_one( const char *fname, KBNODE keyblock, int fast,
|
|||||||
|
|
||||||
/* we are ready */
|
/* we are ready */
|
||||||
if( !opt.quiet ) {
|
if( !opt.quiet ) {
|
||||||
char *p=get_user_id_native(keyid);
|
char *p=get_user_id_printable(keyid);
|
||||||
if( n_uids == 1 )
|
if( n_uids == 1 )
|
||||||
log_info( _("key %08lX: \"%s\" 1 new user ID\n"),
|
log_info( _("key %08lX: \"%s\" 1 new user ID\n"),
|
||||||
(ulong)keyid[1], p);
|
(ulong)keyid[1], p);
|
||||||
@ -832,7 +825,7 @@ import_one( const char *fname, KBNODE keyblock, int fast,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if( !opt.quiet ) {
|
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"),
|
log_info( _("key %08lX: \"%s\" not changed\n"),
|
||||||
(ulong)keyid[1],p);
|
(ulong)keyid[1],p);
|
||||||
m_free(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;
|
keydb_release (hd); hd = NULL;
|
||||||
/* we are ready */
|
/* we are ready */
|
||||||
if( !opt.quiet ) {
|
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"),
|
log_info( _("key %08lX: \"%s\" revocation certificate imported\n"),
|
||||||
(ulong)keyid[1],p);
|
(ulong)keyid[1],p);
|
||||||
m_free(p);
|
m_free(p);
|
||||||
@ -1445,7 +1438,7 @@ merge_blocks( const char *fname, KBNODE keyblock_orig, KBNODE keyblock,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( !found ) {
|
if( !found ) {
|
||||||
char *p=get_user_id_native(keyid);
|
char *p=get_user_id_printable (keyid);
|
||||||
KBNODE n2 = clone_kbnode(node);
|
KBNODE n2 = clone_kbnode(node);
|
||||||
insert_kbnode( keyblock_orig, n2, 0 );
|
insert_kbnode( keyblock_orig, n2, 0 );
|
||||||
n2->flag |= 1;
|
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 );
|
int enum_secret_keys( void **context, PKT_secret_key *sk, int with_subkeys );
|
||||||
void merge_keys_and_selfsig( KBNODE keyblock );
|
void merge_keys_and_selfsig( KBNODE keyblock );
|
||||||
char*get_user_id_string( u32 *keyid );
|
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_long_user_id_string( u32 *keyid );
|
||||||
char*get_user_id( u32 *keyid, size_t *rn );
|
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);
|
KEYDB_HANDLE get_ctx_handle(GETKEY_CTX ctx);
|
||||||
|
|
||||||
/*-- keyid.c --*/
|
/*-- 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
|
static void
|
||||||
show_key_and_fingerprint( KBNODE keyblock )
|
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
|
* mode 0: as used in key listings, opt.with_colons is honored
|
||||||
* 1: print using log_info ()
|
* 1: print using log_info ()
|
||||||
* 2: direct use of tty
|
* 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
|
* modes 1 and 2 will try and print both subkey and primary key fingerprints
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
@ -1005,6 +1006,10 @@ print_fingerprint (PKT_public_key *pk, PKT_secret_key *sk, int mode )
|
|||||||
else
|
else
|
||||||
text = _(" Subkey fingerprint:");
|
text = _(" Subkey fingerprint:");
|
||||||
}
|
}
|
||||||
|
else if (mode == 3) {
|
||||||
|
fp = NULL; /* use tty */
|
||||||
|
text = _(" Key fingerprint =");
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
fp = stdout;
|
fp = stdout;
|
||||||
text = _(" Key fingerprint =");
|
text = _(" Key fingerprint =");
|
||||||
|
@ -117,6 +117,7 @@ int delete_keys( STRLIST names, int secret, int allow_both );
|
|||||||
/*-- keyedit.c --*/
|
/*-- keyedit.c --*/
|
||||||
void keyedit_menu( const char *username, STRLIST locusr, STRLIST cmds,
|
void keyedit_menu( const char *username, STRLIST locusr, STRLIST cmds,
|
||||||
int sign_mode );
|
int sign_mode );
|
||||||
|
void show_basic_key_info (KBNODE keyblock);
|
||||||
|
|
||||||
/*-- keygen.c --*/
|
/*-- keygen.c --*/
|
||||||
u32 ask_expire_interval(int object);
|
u32 ask_expire_interval(int object);
|
||||||
|
@ -636,7 +636,7 @@ agent_get_passphrase ( u32 *keyid, int mode, const char *tryagain_text )
|
|||||||
else
|
else
|
||||||
*maink = 0;
|
*maink = 0;
|
||||||
|
|
||||||
uid = get_user_id( keyid, &uidlen );
|
uid = get_user_id ( keyid, &uidlen );
|
||||||
timestr = strtimestamp (pk->timestamp);
|
timestr = strtimestamp (pk->timestamp);
|
||||||
fmtstr = _("You need a passphrase to unlock the"
|
fmtstr = _("You need a passphrase to unlock the"
|
||||||
" secret key for user:\n"
|
" secret key for user:\n"
|
||||||
|
@ -308,8 +308,8 @@ do_sign( PKT_secret_key *sk, PKT_signature *sig,
|
|||||||
log_error(_("signing failed: %s\n"), g10_errstr(rc) );
|
log_error(_("signing failed: %s\n"), g10_errstr(rc) );
|
||||||
else {
|
else {
|
||||||
if( opt.verbose ) {
|
if( opt.verbose ) {
|
||||||
char *ustr = get_user_id_string( sig->keyid );
|
char *ustr = get_user_id_string_printable (sig->keyid);
|
||||||
log_info(_("%s signature from: %s\n"),
|
log_info(_("%s signature from: \"%s\"\n"),
|
||||||
pubkey_algo_to_string(sk->pubkey_algo), ustr );
|
pubkey_algo_to_string(sk->pubkey_algo), ustr );
|
||||||
m_free(ustr);
|
m_free(ustr);
|
||||||
}
|
}
|
||||||
|
@ -642,10 +642,10 @@ cpr_get_answer_is_yes( const char *keyword, const char *prompt )
|
|||||||
|
|
||||||
if( opt.command_fd != -1 )
|
if( opt.command_fd != -1 )
|
||||||
return !!do_get_from_fd ( keyword, 0, 1 );
|
return !!do_get_from_fd ( keyword, 0, 1 );
|
||||||
#ifdef USE_SHM_COPROCESSING
|
#ifdef USE_SHM_COPROCESSING
|
||||||
if( opt.shm_coprocess )
|
if( opt.shm_coprocess )
|
||||||
return !!do_shm_get( keyword, 0, 1 );
|
return !!do_shm_get( keyword, 0, 1 );
|
||||||
#endif
|
#endif
|
||||||
for(;;) {
|
for(;;) {
|
||||||
p = tty_get( prompt );
|
p = tty_get( prompt );
|
||||||
trim_spaces(p); /* it is okay to do this here */
|
trim_spaces(p); /* it is okay to do this here */
|
||||||
@ -670,10 +670,10 @@ cpr_get_answer_yes_no_quit( const char *keyword, const char *prompt )
|
|||||||
|
|
||||||
if( opt.command_fd != -1 )
|
if( opt.command_fd != -1 )
|
||||||
return !!do_get_from_fd ( keyword, 0, 1 );
|
return !!do_get_from_fd ( keyword, 0, 1 );
|
||||||
#ifdef USE_SHM_COPROCESSING
|
#ifdef USE_SHM_COPROCESSING
|
||||||
if( opt.shm_coprocess )
|
if( opt.shm_coprocess )
|
||||||
return !!do_shm_get( keyword, 0, 1 );
|
return !!do_shm_get( keyword, 0, 1 );
|
||||||
#endif
|
#endif
|
||||||
for(;;) {
|
for(;;) {
|
||||||
p = tty_get( prompt );
|
p = tty_get( prompt );
|
||||||
trim_spaces(p); /* it is okay to do this here */
|
trim_spaces(p); /* it is okay to do this here */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user