* keyserver.c (keyserver_spawn): Don't mess about with the $PATH.
[gnupg.git] / g10 / mainproc.c
index 5258d57..83bb5d8 100644 (file)
@@ -1,6 +1,6 @@
 /* mainproc.c - handle packets
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003,
- *               2004 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+ *               2005 Free Software Foundation, Inc.
  *
  * This file is part of GnuPG.
  *
@@ -330,6 +330,8 @@ proc_symkey_enc( CTX c, PACKET *pkt )
 
            if(c->dek)
              {
+               c->dek->symmetric=1;
+
                /* FIXME: This doesn't work perfectly if a symmetric
                   key comes before a public key in the message - if
                   the user doesn't know the passphrase, then there is
@@ -457,16 +459,13 @@ print_pkenc_list( struct kidlist_item *list, int failed )
        pk->pubkey_algo = list->pubkey_algo;
        if( !get_pubkey( pk, list->kid ) )
          {
-           size_t n;
            char *p;
            log_info( _("encrypted with %u-bit %s key, ID %s, created %s\n"),
                      nbits_from_pk( pk ), algstr, keystr_from_pk(pk),
                      strtimestamp(pk->timestamp) );
-           fputs("      \"", log_stream() );
-           p = get_user_id( list->kid, &n );
-           print_utf8_string2 ( log_stream(), p, n, '"' );
+           p=get_user_id_native(list->kid);
+           fprintf(log_stream(),_("      \"%s\"\n"),p);
            m_free(p);
-           fputs("\"\n", log_stream() );
          }
        else
          log_info(_("encrypted with %s key, ID %s\n"),
@@ -579,7 +578,7 @@ proc_encrypted( CTX c, PACKET *pkt )
            sprintf ( buf, "%d:", c->dek->algo );
            for(i=0; i < c->dek->keylen; i++ )
              sprintf(buf+strlen(buf), "%02X", c->dek->key[i] );
-           log_info( "session key: \"%s\"\n", buf );
+           log_info( "session key: `%s'\n", buf );
            write_status_text ( STATUS_SESSION_KEY, buf );
          }
     }
@@ -927,9 +926,17 @@ list_node( CTX c, KBNODE node )
          {
            /* of subkey */
            if( pk->is_revoked )
-             printf(" %s",_("[revoked] "));
+             {
+               printf(" [");
+               printf(_("revoked: %s"),revokestr_from_pk(pk));
+               printf("]");
+             }
            else if( pk->expiredate )
-             printf(_(" [expires: %s]"), expirestr_from_pk( pk ) );
+             {
+               printf(" [");
+               printf(_("expires: %s"),expirestr_from_pk(pk));
+               printf("]");
+             }
          }
 
        if( !any )
@@ -1146,7 +1153,7 @@ do_proc_packets( CTX c, IOBUF a )
        if( rc ) {
            free_packet(pkt);
             /* stop processing when an invalid packet has been encountered
-             * but don't do so when we are doing a --list-packet. */
+             * but don't do so when we are doing a --list-packets. */
            if( rc == G10ERR_INVALID_PACKET && opt.list_packets != 2 )
                break;
            continue;
@@ -1368,7 +1375,7 @@ check_sig_and_print( CTX c, KBNODE node )
               page, but "from" if it is located on a keyserver.  I'm
               not going to even try to make two strings here :) */
            log_info(_("Key available at: ") );
-           print_string( log_stream(), p, n, 0 );
+           print_utf8_string( log_stream(), p, n );
            putc( '\n', log_stream() );
 
            if(opt.keyserver_options.options&KEYSERVER_AUTO_KEY_RETRIEVE
@@ -1434,6 +1441,7 @@ check_sig_and_print( CTX c, KBNODE node )
 
         /* find and print the primary user ID */
        for( un=keyblock; un; un = un->next ) {
+           char *p;
            int valid;
            if(un->pkt->pkttype==PKT_PUBLIC_KEY)
              {
@@ -1467,19 +1475,28 @@ check_sig_and_print( CTX c, KBNODE node )
                                           un->pkt->pkt.user_id->len, 
                                           -1 );
 
-            log_info(rc? _("BAD signature from \"")
-                       : sig->flags.expired ? _("Expired signature from \"")
-                      : _("Good signature from \""));
-           print_utf8_string( log_stream(), un->pkt->pkt.user_id->name,
-                                            un->pkt->pkt.user_id->len );
-           if(opt.verify_options&VERIFY_SHOW_VALIDITY)
-             fprintf(log_stream(),"\" [%s]\n",trust_value_to_string(valid));
+           p=utf8_to_native(un->pkt->pkt.user_id->name,
+                            un->pkt->pkt.user_id->len,0);
+
+           if(rc)
+             log_info(_("BAD signature from \"%s\""),p);
+           else if(sig->flags.expired)
+             log_info(_("Expired signature from \"%s\""),p);
+           else
+             log_info(_("Good signature from \"%s\""),p);
+
+           m_free(p);
+
+           if(opt.verify_options&VERIFY_SHOW_UID_VALIDITY)
+             fprintf(log_stream()," [%s]\n",trust_value_to_string(valid));
            else
-             fputs("\"\n", log_stream() );
+             fputs("\n", log_stream() );
             count++;
        }
        if( !count ) {  /* just in case that we have no valid textual
                            userid */
+           char *p;
+
            /* Try for an invalid textual userid */
             for( un=keyblock; un; un = un->next ) {
                 if( un->pkt->pkttype == PKT_USER_ID &&
@@ -1503,22 +1520,30 @@ check_sig_and_print( CTX c, KBNODE node )
                                           un? un->pkt->pkt.user_id->len:3, 
                                           -1 );
 
-            log_info(rc? _("BAD signature from \"")
-                       : sig->flags.expired ? _("Expired signature from \"")
-                      : _("Good signature from \""));
-            if (opt.trust_model!=TM_ALWAYS && un) {
-                fputs(_("[uncertain]"), log_stream() );
+           if(un)
+             p=utf8_to_native(un->pkt->pkt.user_id->name,
+                               un->pkt->pkt.user_id->len,0);
+           else
+             p=m_strdup("[?]");
+
+           if(rc)
+             log_info(_("BAD signature from \"%s\""),p);
+           else if(sig->flags.expired)
+             log_info(_("Expired signature from \"%s\""),p);
+           else
+             log_info(_("Good signature from \"%s\""),p);
+            if (opt.trust_model!=TM_ALWAYS && un)
+             {
                 putc(' ', log_stream() );
-            }
-            print_utf8_string( log_stream(),
-                               un? un->pkt->pkt.user_id->name:"[?]",
-                               un? un->pkt->pkt.user_id->len:3 );
-           fputs("\"\n", log_stream() );
+                fputs(_("[uncertain]"), log_stream() );
+             }
+           fputs("\n", log_stream() );
        }
 
         /* If we have a good signature and already printed 
          * the primary user ID, print all the other user IDs */
         if ( count && !rc ) {
+           char *p;
             for( un=keyblock; un; un = un->next ) {
                 if( un->pkt->pkttype != PKT_USER_ID )
                     continue;
@@ -1540,11 +1565,12 @@ check_sig_and_print( CTX c, KBNODE node )
                                  un->pkt->pkt.user_id->numattribs,pk,NULL);
                  }
 
-               log_info(    _("                aka \""));
-                print_utf8_string( log_stream(), un->pkt->pkt.user_id->name,
-                                                 un->pkt->pkt.user_id->len );
+               p=utf8_to_native(un->pkt->pkt.user_id->name,
+                                un->pkt->pkt.user_id->len,0);
+               log_info(_("                aka \"%s\""),p);
+               m_free(p);
 
-               if(opt.verify_options&VERIFY_SHOW_VALIDITY)
+               if(opt.verify_options&VERIFY_SHOW_UID_VALIDITY)
                  {
                    const char *valid;
                    if(un->pkt->pkt.user_id->is_revoked)
@@ -1555,10 +1581,10 @@ check_sig_and_print( CTX c, KBNODE node )
                      valid=trust_value_to_string(get_validity(pk,
                                                               un->pkt->
                                                               pkt.user_id));
-                   fprintf(log_stream(),"\" [%s]\n",valid);
+                   fprintf(log_stream()," [%s]\n",valid);
                  }
                else
-                 fputs("\"\n", log_stream() );
+                 fputs("\n", log_stream() );
             }
        }
        release_kbnode( keyblock );