gpg: No need to create a trustdb when encrypting with --always-trust.
authorWerner Koch <wk@gnupg.org>
Fri, 2 Aug 2013 07:10:17 +0000 (09:10 +0200)
committerWerner Koch <wk@gnupg.org>
Fri, 2 Aug 2013 07:10:17 +0000 (09:10 +0200)
* g10/gpg.c (main): Special case setup_trustdb for --encrypt.

Signed-off-by: Werner Koch <wk@gnupg.org>
g10/gpg.c

index a141164..599948f 100644 (file)
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -3440,7 +3440,8 @@ main (int argc, char **argv)
     ctrl = xcalloc (1, sizeof *ctrl);
     gpg_init_default_ctrl (ctrl);
 
-    switch( cmd ) {
+    switch (cmd)
+      {
       case aPrimegen:
       case aPrintMD:
       case aPrintMDs:
@@ -3449,12 +3450,24 @@ main (int argc, char **argv)
       case aEnArmor:
        break;
       case aFixTrustDB:
-      case aExportOwnerTrust: rc = setup_trustdb( 0, trustdb_name ); break;
-      case aListTrustDB: rc = setup_trustdb( argc? 1:0, trustdb_name ); break;
-      default: rc = setup_trustdb(1, trustdb_name ); break;
-    }
-    if( rc )
-       log_error(_("failed to initialize the TrustDB: %s\n"), g10_errstr(rc));
+      case aExportOwnerTrust:
+        rc = setup_trustdb (0, trustdb_name);
+        break;
+      case aListTrustDB:
+        rc = setup_trustdb (argc? 1:0, trustdb_name);
+        break;
+      case aEncr:
+      case aEncrFiles:
+        /* If we are using TM_ALWAYS, we do not need to create the
+           trustdb.  */
+        rc = setup_trustdb (opt.trust_model != TM_ALWAYS, trustdb_name);
+        break;
+      default:
+        rc = setup_trustdb (1, trustdb_name );
+        break;
+      }
+    if (rc)
+      log_error (_("failed to initialize the TrustDB: %s\n"), g10_errstr(rc));
 
 
     switch (cmd)