Change capitalization of TOR to Tor.
[gnupg.git] / g10 / trustdb.c
index 1be98b5..32061e4 100644 (file)
@@ -459,20 +459,23 @@ init_trustdb ()
       opt.trust_model=tdbio_read_model();
 
       /* Sanity check this ;) */
-      if(opt.trust_model!=TM_CLASSIC
-        && opt.trust_model!=TM_PGP
-        && opt.trust_model!=TM_EXTERNAL)
+      if(opt.trust_model != TM_CLASSIC
+        && opt.trust_model != TM_PGP
+        && opt.trust_model != TM_TOFU_PGP
+        && opt.trust_model != TM_TOFU
+        && opt.trust_model != TM_EXTERNAL)
        {
          log_info(_("unable to use unknown trust model (%d) - "
-                    "assuming %s trust model\n"),opt.trust_model,"PGP");
-         opt.trust_model=TM_PGP;
+                    "assuming %s trust model\n"),opt.trust_model,"tofu+pgp");
+         opt.trust_model = TM_TOFU_PGP;
        }
 
       if(opt.verbose)
        log_info(_("using %s trust model\n"),trust_model_string());
     }
 
-  if(opt.trust_model==TM_PGP || opt.trust_model==TM_CLASSIC)
+  if (opt.trust_model==TM_PGP || opt.trust_model==TM_CLASSIC
+      || opt.trust_model == TM_TOFU || opt.trust_model == TM_TOFU_PGP)
     {
       /* Verify the list of ultimately trusted keys and move the
         --trusted-keys list there as well. */
@@ -494,7 +497,8 @@ void
 check_trustdb ()
 {
   init_trustdb();
-  if(opt.trust_model==TM_PGP || opt.trust_model==TM_CLASSIC)
+  if (opt.trust_model == TM_PGP || opt.trust_model == TM_CLASSIC
+      || opt.trust_model == TM_TOFU_PGP || opt.trust_model == TM_TOFU)
     {
       if (opt.batch && !opt.answer_yes)
        {
@@ -530,7 +534,8 @@ void
 update_trustdb()
 {
   init_trustdb();
-  if(opt.trust_model==TM_PGP || opt.trust_model==TM_CLASSIC)
+  if (opt.trust_model == TM_PGP || opt.trust_model == TM_CLASSIC
+      || opt.trust_model == TM_TOFU_PGP || opt.trust_model == TM_TOFU)
     validate_keys (1);
   else
     log_info (_("no need for a trustdb update with '%s' trust model\n"),
@@ -946,7 +951,8 @@ tdb_check_trustdb_stale (void)
     return;  /* No trustdb => can't be stale.  */
 
   if (!did_nextcheck
-      && (opt.trust_model==TM_PGP || opt.trust_model==TM_CLASSIC))
+      && (opt.trust_model == TM_PGP || opt.trust_model == TM_CLASSIC
+          || opt.trust_model == TM_TOFU_PGP || opt.trust_model == TM_TOFU))
     {
       ulong scheduled;
 
@@ -1573,7 +1579,8 @@ validate_one_keyblock (KBNODE kb, struct key_item *klist,
              since we don't accept a regexp on the sig unless it's a
              trust sig. */
           if (kr && (!kr->trust_regexp
-                     || opt.trust_model != TM_PGP
+                     || !(opt.trust_model == TM_PGP
+                          || opt.trust_model == TM_TOFU_PGP)
                      || (uidnode
                          && check_regexp(kr->trust_regexp,
                                          uidnode->pkt->pkt.user_id->name))))
@@ -1583,7 +1590,8 @@ validate_one_keyblock (KBNODE kb, struct key_item *klist,
                  lesser trust sig or value.  I could make a decent
                  argument for any of these cases, but this seems to be
                  what PGP does, and I'd like to be compatible. -dms */
-              if (opt.trust_model == TM_PGP
+              if ((opt.trust_model == TM_PGP
+                   || opt.trust_model == TM_TOFU_PGP)
                   && sig->trust_depth
                   && pk->trust_timestamp <= sig->timestamp)
                {
@@ -1938,6 +1946,11 @@ validate_keys (int interactive)
       do_sync ();
     }
 
+  if (opt.trust_model == TM_TOFU)
+    /* In the TOFU trust model, we only need to save the ultimately
+       trusted keys.  */
+    goto leave;
+
   klist = utk_list;
 
   log_info(_("%d marginal(s) needed, %d complete(s) needed, %s trust model\n"),
@@ -2084,7 +2097,8 @@ validate_keys (int interactive)
  leave:
   keydb_release (kdb);
   release_key_array (keys);
-  release_key_items (klist);
+  if (klist != utk_list)
+    release_key_items (klist);
   release_key_hash_table (full_trust);
   release_key_hash_table (used);
   release_key_hash_table (stored);