diff options
Diffstat (limited to 'g10')
-rw-r--r-- | g10/ChangeLog | 18 | ||||
-rw-r--r-- | g10/armor.c | 2 | ||||
-rw-r--r-- | g10/g10.c | 9 | ||||
-rw-r--r-- | g10/mainproc.c | 2 | ||||
-rw-r--r-- | g10/misc.c | 4 | ||||
-rw-r--r-- | g10/options.h | 1 | ||||
-rw-r--r-- | g10/options.skel | 7 | ||||
-rw-r--r-- | g10/pkclist.c | 55 | ||||
-rw-r--r-- | g10/plaintext.c | 1 | ||||
-rw-r--r-- | g10/sign.c | 27 | ||||
-rw-r--r-- | g10/trustdb.c | 133 | ||||
-rw-r--r-- | g10/trustdb.h | 1 |
12 files changed, 210 insertions, 50 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog index 77990ae6d..b2ccffac4 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,21 @@ +Thu Dec 17 18:31:15 CET 1998 Werner Koch <[email protected]> + + * misc.c (trap_unaligned): Only for glibc 1 + + * sign.c (write_dash_escaped): Now escapes "From " lines + * g10.c: New option --escape-from-lines + + * trustdb.c (sort_tsl_list): New + (list_trust_path): Now prints sorted list. + (enum_cert_paths): Likewise. + (enum_cert_paths_print): New. + (print_paths): New printing format. + * pkclist.c (add_ownertrust): New arg quit. + (edit_ownertrust): New quit selection and does not query + the recipients ownertrust anymore. + (add_ownertrust): Print the ceritficate path. + + Mon Dec 14 21:18:49 CET 1998 Werner Koch <[email protected]> * parse-packet.c (parse_signature): Now checks for critical bit diff --git a/g10/armor.c b/g10/armor.c index 78656bae9..ca74fe448 100644 --- a/g10/armor.c +++ b/g10/armor.c @@ -1079,7 +1079,7 @@ armor_filter( void *opaque, int control, } else iobuf_writestr(a, - "Comment: For info finger [email protected]\n"); + "Comment: For info see www.gnupg.org"); if( afx->hdrlines ) iobuf_writestr(a, afx->hdrlines); iobuf_put(a, '\n'); @@ -150,6 +150,7 @@ enum cmd_and_opt_values { aNull = 0, oS2KCipher, oCharset, oNotDashEscaped, + oEscapeFrom, oLockOnce, aTest }; @@ -301,6 +302,7 @@ static ARGPARSE_OPTS opts[] = { { oSetFilename, "set-filename", 2, "@" }, { oComment, "comment", 2, "@" }, { oNotDashEscaped, "not-dash-escaped", 0, "@" }, + { oEscapeFrom, "escape-from-lines", 0, "@" }, { oLockOnce, "lock-once", 0, "@" }, {0} }; @@ -727,7 +729,11 @@ main( int argc, char **argv ) register_cipher_extension(orig_argc? *orig_argv:NULL, pargs.r.ret_str); break; - case oRFC1991: opt.rfc1991 = 1; opt.no_comment = 1; break; + case oRFC1991: + opt.rfc1991 = 1; + opt.no_comment = 1; + opt.escape_from = 1; + break; case oEmuChecksumBug: opt.emulate_bugs |= EMUBUG_GPGCHKSUM; break; case oCompressSigs: opt.compress_sigs = 1; break; case oRunAsShmCP: @@ -777,6 +783,7 @@ main( int argc, char **argv ) pargs.r.ret_str); break; case oNotDashEscaped: opt.not_dash_escaped = 1; break; + case oEscapeFrom: opt.escape_from = 1; break; case oLockOnce: opt.lock_once = 1; break; default : pargs.err = configfp? 1:2; break; diff --git a/g10/mainproc.c b/g10/mainproc.c index 02d42223b..acf5bf5e7 100644 --- a/g10/mainproc.c +++ b/g10/mainproc.c @@ -278,7 +278,7 @@ proc_plaintext( CTX c, PACKET *pkt ) md_enable( c->mfx.md, DIGEST_ALGO_SHA1 ); md_enable( c->mfx.md, DIGEST_ALGO_MD5 ); } - /*md_start_debug( c->mfx.md, "verify" );*/ + md_start_debug( c->mfx.md, "verify" ); rc = handle_plaintext( pt, &c->mfx, c->sigs_only, clearsig ); if( rc == G10ERR_CREATE_FILE && !c->sigs_only) { /* can't write output but we hash it anyway to diff --git a/g10/misc.c b/g10/misc.c index a52114748..e7990475b 100644 --- a/g10/misc.c +++ b/g10/misc.c @@ -23,7 +23,7 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#if defined(__linux__) && defined(__alpha__) +#if defined(__linux__) && defined(__alpha__) && __GLIBC__ < 2 #include <asm/sysinfo.h> #include <asm/unistd.h> #endif @@ -50,7 +50,7 @@ pull_in_libs(void) } -#if defined(__linux__) && defined(__alpha__) && defined(UAC_SIGBUS) +#if defined(__linux__) && defined(__alpha__) && __GLIBC__ < 2 #warning using trap_unaligned static int setsysinfo(unsigned long op, void *buffer, unsigned long size, diff --git a/g10/options.h b/g10/options.h index a8164f89d..b6b1cd2de 100644 --- a/g10/options.h +++ b/g10/options.h @@ -65,6 +65,7 @@ struct { int s2k_digest_algo; int s2k_cipher_algo; int not_dash_escaped; + int escape_from; int lock_once; } opt; diff --git a/g10/options.skel b/g10/options.skel index 0e53339d5..82916826c 100644 --- a/g10/options.skel +++ b/g10/options.skel @@ -28,6 +28,13 @@ $Id$ force-v3-sigs +# Because some mailers change lines starting with "From " to ">From " +# it is good to handle such lines in a special way when creating +# cleartext signatures; all other PGP versions it this way too. +# To enable full OpenPGP compliance you have to remove this option. + +escape_from_lines + # If you do not use the Latin-1 (ISO-8859-1) charset, you should # tell GnuPG which is the native character set. Please check # the man page for supported character sets. diff --git a/g10/pkclist.c b/g10/pkclist.c index 094842df3..fb0a89e7a 100644 --- a/g10/pkclist.c +++ b/g10/pkclist.c @@ -77,6 +77,22 @@ show_paths( ulong lid, int only_first ) level*2, "", nbits_from_pk( pk ), pubkey_letter( pk->pubkey_algo ), (ulong)keyid[1], lid, datestr_from_pk( pk ) ); + #if 0 + c = trust_letter(otrust); + if( c ) + putchar( c ); + else + printf( "%02x", otrust ); + putchar('/'); + c = trust_letter(validity); + if( c ) + putchar( c ); + else + printf( "%02x", validity ); + putchar(' '); + #endif + + p = get_user_id( keyid, &n ); tty_print_string( p, n ), m_free(p); @@ -102,6 +118,7 @@ edit_ownertrust( ulong lid, int mode ) u32 keyid[2]; PKT_public_key *pk ; int changed=0; + int quit=0; rc = keyid_from_lid( lid, keyid ); if( rc ) { @@ -138,13 +155,15 @@ edit_ownertrust( ulong lid, int mode ) " s = please show me more information\n") ); if( mode ) tty_printf(_(" m = back to the main menu\n")); + else + tty_printf(_(" q = quit\n")); tty_printf("\n"); for(;;) { /* a string with valid answers */ - char *ans = _("sSmM"); + char *ans = _("sSmMqQ"); - if( strlen(ans) != 4 ) + if( strlen(ans) != 6 ) BUG(); p = cpr_get("edit_ownertrust.value",_("Your decision? ")); trim_spaces(p); @@ -172,11 +191,15 @@ edit_ownertrust( ulong lid, int mode ) else if( mode && (*p == ans[2] || *p == ans[3] || *p == CONTROL_D ) ) { break ; /* back to the menu */ } + else if( !mode && (*p == ans[4] || *p == ans[5] ) ) { + quit = 1; + break ; /* back to the menu */ + } m_free(p); p = NULL; } m_free(p); m_free(pk); - return changed; + return quit? -1 : changed; } @@ -185,7 +208,7 @@ edit_ownertrust( ulong lid, int mode ) * Returns: -1 if no ownertrust were added. */ static int -add_ownertrust( PKT_public_key *pk ) +add_ownertrust( PKT_public_key *pk, int *quit ) { int rc; void *context = NULL; @@ -193,6 +216,7 @@ add_ownertrust( PKT_public_key *pk ) unsigned otrust, validity; int any=0, changed=0, any_undefined=0; + *quit = 0; tty_printf( _("Could not find a valid trust path to the key. Let's see whether we\n" "can assign some missing owner trust values.\n\n")); @@ -205,12 +229,20 @@ _("Could not find a valid trust path to the key. Let's see whether we\n" lid = pk->local_id; while( enum_cert_paths( &context, &lid, &otrust, &validity ) != -1 ) { + if( lid == pk->local_id ) + continue; any=1; if( otrust == TRUST_UNDEFINED || otrust == TRUST_EXPIRED || otrust == TRUST_UNKNOWN ) { any_undefined=1; - if( edit_ownertrust( lid, 0 ) ) - changed=1; + enum_cert_paths_print( &context, NULL, lid ); + rc = edit_ownertrust( lid, 0 ); + if( rc == -1 ) { + *quit = 1; + break; + } + else if( rc > 0 ) + changed = 1; } } enum_cert_paths( &context, NULL, NULL, NULL ); /* release context */ @@ -272,8 +304,10 @@ do_we_trust( PKT_public_key *pk, int trustlevel ) log_info(_("%08lX: no info to calculate a trust probability\n"), (ulong)keyid_from_pk( pk, NULL) ); else { - rc = add_ownertrust( pk ); - if( !rc ) { + int quit; + + rc = add_ownertrust( pk, &quit ); + if( !rc && !quit ) { rc = check_trust( pk, &trustlevel ); if( rc ) log_fatal("trust check after add_ownertrust failed: %s\n", @@ -407,8 +441,9 @@ check_signatures_trust( PKT_signature *sig ) "signature belongs to the owner.\n" )); } else { - rc = add_ownertrust( pk ); - if( rc ) { + int quit; + rc = add_ownertrust( pk, &quit ); + if( rc || quit ) { dont_try = 1; rc = 0; } diff --git a/g10/plaintext.c b/g10/plaintext.c index 7eda8df9d..d471b9fe3 100644 --- a/g10/plaintext.c +++ b/g10/plaintext.c @@ -44,6 +44,7 @@ special_md_putc( MD_HANDLE md, int c, int *state ) if( *state == 1 ) { md_putc(md, '\r'); } + *state = 0; return; } diff --git a/g10/sign.c b/g10/sign.c index 9b78acf7e..f3373ed4f 100644 --- a/g10/sign.c +++ b/g10/sign.c @@ -475,12 +475,35 @@ write_dash_escaped( IOBUF inp, IOBUF out, MD_HANDLE md ) } while( (c = iobuf_get(inp)) != -1 ) { - /* Note: We don't escape "From " because the MUA should cope with it */ if( lastlf ) { if( c == '-' ) { iobuf_put( out, c ); iobuf_put( out, ' ' ); } + else if( c == 'F' && opt.escape_from ) { + int i; + + if( state >= 1 ) + md_putc(md, '\r'); + if( state >= 2 ) + md_putc(md, '\n'); + state = 0; + + for( i=1; i < 5 && (c = iobuf_get(inp)) != -1; i++ ) { + if( "From "[i] != c ) + break; + } + if( i < 5 ) { + iobuf_write( out, "From", i ); + md_write( md, "From", i ); + if( c == -1 ) + break; + } + else { + iobuf_writestr( out, "- From" ); + md_write( md, "From", 4 ); + } + } } again: @@ -614,7 +637,7 @@ clearsign_file( const char *fname, STRLIST locusr, const char *outfile ) PKT_secret_key *sk = sk_rover->sk; md_enable(textmd, hash_for(sk->pubkey_algo)); } - /*md_start_debug( textmd, "create" );*/ + md_start_debug( textmd, "create" ); if( !opt.not_dash_escaped ) iobuf_push_filter( inp, text_filter, &tfx ); rc = write_dash_escaped( inp, out, textmd ); diff --git a/g10/trustdb.c b/g10/trustdb.c index fbfb807ac..ff05a32ac 100644 --- a/g10/trustdb.c +++ b/g10/trustdb.c @@ -81,6 +81,13 @@ struct trust_seg_list { }; +struct enum_cert_paths_ctx { + int init; + TRUST_SEG_LIST tsl_head; + TRUST_SEG_LIST tsl; + int idx; +}; + struct recno_list_struct { struct recno_list_struct *next; @@ -98,6 +105,7 @@ static int ins_lid_table_item( LOCAL_ID_TABLE tbl, ulong lid, unsigned flag ); static int qry_lid_table_flag( LOCAL_ID_TABLE tbl, ulong lid, unsigned *flag ); static void print_user_id( const char *text, u32 *keyid ); +static void sort_tsl_list( TRUST_SEG_LIST *trust_seg_list ); static int list_sigs( ulong pubkey_id ); static int do_check( TRUSTREC *drec, unsigned *trustlevel ); static int get_dir_record( PKT_public_key *pk, TRUSTREC *rec ); @@ -890,17 +898,23 @@ collect_paths( int depth, int max_depth, int all, TRUSTREC *drec, for(i=0; i < SIGS_PER_RECORD; i++ ) { TRUSTREC tmp; int ot, nt; + int unchecked = 0; if( !rec.r.sig.sig[i].lid ) continue; /* skip deleted sigs */ - if( !(rec.r.sig.sig[i].flag & SIGF_CHECKED) ) - continue; /* skip unchecked signatures */ - if( !(rec.r.sig.sig[i].flag & SIGF_VALID) ) - continue; /* skip invalid signatures */ - if( (rec.r.sig.sig[i].flag & SIGF_EXPIRED) ) - continue; /* skip expired signatures */ - if( (rec.r.sig.sig[i].flag & SIGF_REVOKED) ) - continue; /* skip revoked signatures */ + if( !(rec.r.sig.sig[i].flag & SIGF_CHECKED) ) { + if( !all ) + continue; /* skip unchecked signatures */ + unchecked = 1; + } + else { + if( !(rec.r.sig.sig[i].flag & SIGF_VALID) ) + continue; /* skip invalid signatures */ + if( (rec.r.sig.sig[i].flag & SIGF_EXPIRED) ) + continue; /* skip expired signatures */ + if( (rec.r.sig.sig[i].flag & SIGF_REVOKED) ) + continue; /* skip revoked signatures */ + } /* visit every signer only once (a signer may have * signed more than one user ID) */ @@ -923,7 +937,7 @@ collect_paths( int depth, int max_depth, int all, TRUSTREC *drec, trust_seg_head ); nt &= TRUST_MASK; - if( nt < TRUST_MARGINAL ) { + if( nt < TRUST_MARGINAL || unchecked ) { continue; } @@ -1175,7 +1189,7 @@ import_ownertrust( const char *fname ) continue; n = strlen(line); if( line[n-1] != '\n' ) { - log_error_f(fname, _("line to long\n") ); + log_error_f(fname, _("line too long\n") ); /* ... or last line does not have a LF */ break; /* can't continue */ } @@ -1249,7 +1263,7 @@ import_ownertrust( const char *fname ) static void -print_path( int pathlen, TRUST_INFO *path ) +print_path( int pathlen, TRUST_INFO *path, FILE *fp, ulong highlight ) { int rc, c, i; u32 keyid[2]; @@ -1257,35 +1271,67 @@ print_path( int pathlen, TRUST_INFO *path ) size_t n; for( i = 0; i < pathlen; i++ ) { - printf("%*s", i*2, "" ); + if( highlight ) + fputs(highlight == path[i].lid? "* ":" ", fp ); rc = keyid_from_lid( path[i].lid, keyid ); if( rc ) - printf("????????.%lu:", path[i].lid ); + fprintf(fp, "????????.%lu:", path[i].lid ); else - printf("%08lX.%lu:", (ulong)keyid[1], path[i].lid ); + fprintf(fp,"%08lX.%lu:", (ulong)keyid[1], path[i].lid ); c = trust_letter(path[i].otrust); if( c ) - putchar( c ); + putc( c, fp ); else - printf( "%02x", path[i].otrust ); - putchar('/'); + fprintf( fp, "%02x", path[i].otrust ); + putc('/', fp); c = trust_letter(path[i].trust); if( c ) - putchar( c ); + putc( c, fp ); else - printf( "%02x", path[i].trust ); - putchar(' '); + fprintf( fp, "%02x", path[i].trust ); + putc(' ', fp); p = get_user_id( keyid, &n ); - putchar(' '); - putchar('\"'); - print_string( stdout, p, n > 40? 40:n, 0 ); - putchar('\"'); + putc(' ', fp); + putc('\"', fp); + print_string( fp, p, n > 40? 40:n, 0 ); + putc('\"', fp); m_free(p); - putchar('\n'); + putc('\n', fp ); } } +static int +cmp_tsl_array( const void *xa, const void *xb ) +{ + TRUST_SEG_LIST a = *(TRUST_SEG_LIST*)xa; + TRUST_SEG_LIST b = *(TRUST_SEG_LIST*)xb; + return a->pathlen - b->pathlen; +} + + +static void +sort_tsl_list( TRUST_SEG_LIST *trust_seg_list ) +{ + TRUST_SEG_LIST *array, *tail, tsl; + size_t n; + + for(n=0, tsl = *trust_seg_list; tsl; tsl = tsl->next ) + n++; + array = m_alloc( (n+1) * sizeof *array ); + for(n=0, tsl = *trust_seg_list; tsl; tsl = tsl->next ) + array[n++] = tsl; + array[n] = NULL; + qsort( array, n, sizeof *array, cmp_tsl_array ); + *trust_seg_list = NULL; + tail = trust_seg_list; + for(n=0; (tsl=array[n]); n++ ) { + *tail = tsl; + tail = &tsl->next; + } + m_free( array ); +} + void list_trust_path( const char *username ) @@ -1318,9 +1364,12 @@ list_trust_path( const char *username ) trust_seg_list = NULL; collect_paths( 0, opt.max_cert_depth, 1, &rec, tmppath, &trust_seg_list ); m_free( tmppath ); + sort_tsl_list( &trust_seg_list ); /* and now print them */ for(tsl = trust_seg_list; tsl; tsl = tsl->next ) { - print_path( tsl->pathlen, tsl->path ); + print_path( tsl->pathlen, tsl->path, stdout, 0 ); + if( tsl->next ) + putchar('\n'); } /* release the list */ @@ -1638,12 +1687,7 @@ int enum_cert_paths( void **context, ulong *lid, unsigned *ownertrust, unsigned *validity ) { - struct { - int init; - TRUST_SEG_LIST tsl_head; - TRUST_SEG_LIST tsl; - int idx; - } *ctx; + struct enum_cert_paths_ctx *ctx; TRUST_SEG_LIST tsl; if( !lid ) { /* release the context */ @@ -1675,7 +1719,8 @@ enum_cert_paths( void **context, ulong *lid, tsl = NULL; collect_paths( 0, opt.max_cert_depth, 1, &rec, tmppath, &tsl ); m_free( tmppath ); - /* and now print them */ + sort_tsl_list( &tsl ); + /* setup the context */ ctx->tsl_head = tsl; ctx->tsl = ctx->tsl_head; ctx->idx = 0; @@ -1702,6 +1747,28 @@ enum_cert_paths( void **context, ulong *lid, /**************** + * Print the current path + */ +int +enum_cert_paths_print( void **context, FILE *fp, ulong selected_lid ) +{ + struct enum_cert_paths_ctx *ctx; + TRUST_SEG_LIST tsl; + + if( !*context ) + return; + ctx = *context; + if( !ctx->tsl ) + return; + + if( !fp ) + fp = stderr; + + print_path( ctx->tsl->pathlen, ctx->tsl->path, fp, selected_lid ); +} + + +/**************** * Return the assigned ownertrust value for the given LID */ unsigned diff --git a/g10/trustdb.h b/g10/trustdb.h index 933d7a58d..fd92826ba 100644 --- a/g10/trustdb.h +++ b/g10/trustdb.h @@ -53,6 +53,7 @@ int check_trust( PKT_public_key *pk, unsigned *r_trustlevel ); int query_trust_info( PKT_public_key *pk ); int enum_cert_paths( void **context, ulong *lid, unsigned *ownertrust, unsigned *validity ); +int enum_cert_paths_print( void **context, FILE *fp, ulong selected_lid ); unsigned get_ownertrust( ulong lid ); int get_ownertrust_info( ulong lid ); byte *get_pref_data( ulong lid, const byte *namehash, size_t *ret_n ); |