~ubuntu-branches/ubuntu/oneiric/gnupg2/oneiric-proposed

« back to all changes in this revision

Viewing changes to sm/gpgsm.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Bienia
  • Date: 2010-01-22 21:49:55 UTC
  • mfrom: (1.1.14 upstream) (7.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100122214955-r2ab5it9rts5gqjf
Tags: 2.0.14-1ubuntu1
* Merge with Debian testing (lp: #511356). Remaining changes:
  - debian/gnupg2.dev: udev rules to set ACLs on SCM smartcard readers.
  - debian/rules: Call dh_installudev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
99
99
  oLogFile,
100
100
  oNoLogFile,
101
101
  oAuditLog,
 
102
  oHtmlAuditLog,
102
103
 
103
104
  oEnableSpecialFilenames,
104
105
 
175
176
  oDisablePubkeyAlgo,
176
177
  oIgnoreTimeConflict,
177
178
  oNoRandomSeedFile,
178
 
  oNoCommonCertsImport
 
179
  oNoCommonCertsImport,
 
180
  oIgnoreCertExtension
179
181
 };
180
182
 
181
183
 
286
288
 
287
289
  ARGPARSE_s_s (oAuditLog, "audit-log", 
288
290
                N_("|FILE|write an audit log to FILE")),
 
291
  ARGPARSE_s_s (oHtmlAuditLog, "html-audit-log", ""),
289
292
  ARGPARSE_s_n (oDryRun, "dry-run", N_("do not make any changes")),
290
293
  ARGPARSE_s_n (oBatch, "batch", N_("batch mode: never ask")),
291
294
  ARGPARSE_s_n (oAnswerYes, "yes", N_("assume yes on most questions")),
374
377
  ARGPARSE_s_n (oIgnoreTimeConflict, "ignore-time-conflict", "@"),
375
378
  ARGPARSE_s_n (oNoRandomSeedFile,  "no-random-seed-file", "@"),
376
379
  ARGPARSE_s_n (oNoCommonCertsImport, "no-common-certs-import", "@"),
 
380
  ARGPARSE_s_s (oIgnoreCertExtension, "ignore-cert-extension", "@"),
377
381
 
378
382
  /* Command aliases.  */
379
383
  ARGPARSE_c (aListKeys, "list-key", "@"),  
402
406
/* Option --enable-special-filenames */
403
407
static int allow_special_filenames;
404
408
 
405
 
/* Default value for include-certs. */
406
 
static int default_include_certs = 1; /* Only include the signer's cert. */
 
409
/* Default value for include-certs.  We need an extra macro for
 
410
   gpgconf-list because the variable will be changed by the command
 
411
   line option.  */
 
412
#define DEFAULT_INCLUDE_CERTS -2 /* Include all certs but root. */
 
413
static int default_include_certs = DEFAULT_INCLUDE_CERTS; 
407
414
 
408
415
/* Whether the chain mode shall be used for validation.  */
409
416
static int default_validation_model;
633
640
static void
634
641
set_debug (void)
635
642
{
 
643
  int numok = (debug_level && digitp (debug_level));
 
644
  int numlvl = numok? atoi (debug_level) : 0;
 
645
 
636
646
  if (!debug_level)
637
647
    ;
638
 
  else if (!strcmp (debug_level, "none"))
 
648
  else if (!strcmp (debug_level, "none") || (numok && numlvl < 1))
639
649
    opt.debug = 0;
640
 
  else if (!strcmp (debug_level, "basic"))
 
650
  else if (!strcmp (debug_level, "basic") || (numok && numlvl <= 2))
641
651
    opt.debug = DBG_ASSUAN_VALUE;
642
 
  else if (!strcmp (debug_level, "advanced"))
 
652
  else if (!strcmp (debug_level, "advanced") || (numok && numlvl <= 5))
643
653
    opt.debug = DBG_ASSUAN_VALUE|DBG_X509_VALUE;
644
 
  else if (!strcmp (debug_level, "expert"))
 
654
  else if (!strcmp (debug_level, "expert")  || (numok && numlvl <= 8))
645
655
    opt.debug = (DBG_ASSUAN_VALUE|DBG_X509_VALUE
646
656
                 |DBG_CACHE_VALUE|DBG_CRYPTO_VALUE);
647
 
  else if (!strcmp (debug_level, "guru"))
648
 
    opt.debug = ~0;
 
657
  else if (!strcmp (debug_level, "guru") || numok)
 
658
    {
 
659
      opt.debug = ~0;
 
660
      /* Unless the "guru" string has been used we don't want to allow
 
661
         hashing debugging.  The rationale is that people tend to
 
662
         select the highest debug value and would then clutter their
 
663
         disk with debug files which may reveal confidential data.  */ 
 
664
      if (numok)
 
665
        opt.debug &= ~(DBG_HASHING_VALUE);
 
666
    }
649
667
  else
650
668
    {
651
669
      log_error (_("invalid debug-level `%s' given\n"), debug_level);
652
 
      gpgsm_exit(2);
 
670
      gpgsm_exit (2);
653
671
    }
654
672
 
655
673
  opt.debug |= debug_value;
664
682
  if (opt.debug & DBG_CRYPTO_VALUE )
665
683
    gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1);
666
684
  gcry_control (GCRYCTL_SET_VERBOSITY, (int)opt.verbose);
 
685
 
 
686
  if (opt.debug)
 
687
    log_info ("enabled debug flags:%s%s%s%s%s%s%s%s\n",
 
688
              (opt.debug & DBG_X509_VALUE   )? " x509":"",    
 
689
              (opt.debug & DBG_MPI_VALUE    )? " mpi":"",    
 
690
              (opt.debug & DBG_CRYPTO_VALUE )? " crypto":"", 
 
691
              (opt.debug & DBG_MEMORY_VALUE )? " memory":"", 
 
692
              (opt.debug & DBG_CACHE_VALUE  )? " cache":"", 
 
693
              (opt.debug & DBG_MEMSTAT_VALUE)? " memstat":"", 
 
694
              (opt.debug & DBG_HASHING_VALUE)? " hashing":"", 
 
695
              (opt.debug & DBG_ASSUAN_VALUE )? " assuan":"" );
667
696
}
668
697
 
669
698
 
838
867
  int default_keyring = 1;
839
868
  char *logfile = NULL;
840
869
  char *auditlog = NULL;
 
870
  char *htmlauditlog = NULL;
841
871
  int greeting = 0;
842
872
  int nogreeting = 0;
843
873
  int debug_wait = 0;
853
883
  int do_not_setup_keys = 0;
854
884
  int recp_required = 0;
855
885
  estream_t auditfp = NULL;
 
886
  estream_t htmlauditfp = NULL;
856
887
 
857
888
  /*mtrace();*/
858
889
 
1169
1200
        case oNoLogFile: logfile = NULL; break;          
1170
1201
 
1171
1202
        case oAuditLog: auditlog = pargs.r.ret_str; break;
 
1203
        case oHtmlAuditLog: htmlauditlog = pargs.r.ret_str; break;
1172
1204
 
1173
1205
        case oBatch: 
1174
1206
          opt.batch = 1;
1351
1383
          }
1352
1384
          break;
1353
1385
 
 
1386
        case oIgnoreCertExtension:
 
1387
          add_to_strlist (&opt.ignored_cert_extensions, pargs.r.ret_str);
 
1388
          break;
 
1389
 
1354
1390
        default: 
1355
1391
          pargs.err = configfp? ARGPARSE_PRINT_WARNING:ARGPARSE_PRINT_ERROR; 
1356
1392
          break;
1397
1433
    }
1398
1434
#  endif
1399
1435
 
1400
 
  if (auditlog)
1401
 
    log_info ("NOTE: The audit log feature (--audit-log) is "
1402
 
              "WORK IN PRORESS and not ready for use!\n");
1403
 
 
1404
 
 
1405
1436
  if (may_coredump && !opt.quiet)
1406
1437
    log_info (_("WARNING: program may create a core file!\n"));
1407
1438
 
1533
1564
 
1534
1565
 
1535
1566
  /* Prepare the audit log feature for certain commands.  */
1536
 
  if (auditlog)
 
1567
  if (auditlog || htmlauditlog)
1537
1568
    {
1538
1569
      switch (cmd)
1539
1570
        {
1543
1574
        case aVerify:
1544
1575
          audit_release (ctrl.audit);
1545
1576
          ctrl.audit = audit_new ();
1546
 
          auditfp = open_es_fwrite (auditlog);
 
1577
          if (auditlog)
 
1578
            auditfp = open_es_fwrite (auditlog);
 
1579
          if (htmlauditlog)
 
1580
            htmlauditfp = open_es_fwrite (htmlauditlog);
1547
1581
          break;
1548
1582
        default:
1549
1583
          break;
1606
1640
        printf ("disable-crl-checks:%lu:\n", GC_OPT_FLAG_NONE);
1607
1641
        printf ("disable-trusted-cert-crl-check:%lu:\n", GC_OPT_FLAG_NONE);
1608
1642
        printf ("enable-ocsp:%lu:\n", GC_OPT_FLAG_NONE);
1609
 
        printf ("include-certs:%lu:1:\n", GC_OPT_FLAG_DEFAULT);
 
1643
        printf ("include-certs:%lu:%d:\n", GC_OPT_FLAG_DEFAULT,
 
1644
                DEFAULT_INCLUDE_CERTS);
1610
1645
        printf ("disable-policy-checks:%lu:\n", GC_OPT_FLAG_NONE);
1611
1646
        printf ("auto-issuer-key-retrieve:%lu:\n", GC_OPT_FLAG_NONE);
1612
1647
        printf ("disable-dirmngr:%lu:\n", GC_OPT_FLAG_NONE);
1619
1654
        printf ("encrypt-to:%lu:\n", GC_OPT_FLAG_DEFAULT);
1620
1655
        printf ("keyserver:%lu:\n", GC_OPT_FLAG_NONE);
1621
1656
 
 
1657
        /* The next one is an info only item and should match what
 
1658
           proc_parameters actually implements.  */
 
1659
        printf ("default_pubkey_algo:%lu:\"%s:\n", GC_OPT_FLAG_DEFAULT,
 
1660
                "RSA-2048");
1622
1661
      }
1623
1662
      break;
1624
1663
    case aGPGConfTest:
1894
1933
    }
1895
1934
 
1896
1935
  /* Print the audit result if needed.  */
1897
 
  if (auditlog && auditfp)
 
1936
  if ((auditlog && auditfp) || (htmlauditlog && htmlauditfp))
1898
1937
    {
1899
 
      audit_print_result (ctrl.audit, auditfp, 0);
 
1938
      if (auditlog && auditfp)
 
1939
        audit_print_result (ctrl.audit, auditfp, 0);
 
1940
      if (htmlauditlog && htmlauditfp)
 
1941
        audit_print_result (ctrl.audit, htmlauditfp, 1);
1900
1942
      audit_release (ctrl.audit);
1901
1943
      ctrl.audit = NULL;
1902
1944
      es_fclose (auditfp);
 
1945
      es_fclose (htmlauditfp);
1903
1946
    }
1904
1947
  
1905
1948
  /* cleanup */