* Makefile.am (DISTCHECK_CONFIGURE_FLAGS): New.
[gnupg.git] / sm / gpgsm.c
index 1583787..c392886 100644 (file)
@@ -1,5 +1,5 @@
 /* gpgsm.c - GnuPG for S/MIME 
- *     Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+ *     Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
  *
  * This file is part of GnuPG.
  *
 #include <unistd.h>
 #include <fcntl.h>
 
-#include <gcrypt.h>
 #include "gpgsm.h"
-#include "../assuan/assuan.h" /* malloc hooks */
+#include <gcrypt.h>
+#include <assuan.h> /* malloc hooks */
+
 #include "../kbx/keybox.h" /* malloc hooks */
 #include "i18n.h"
 #include "keydb.h"
@@ -1070,10 +1071,7 @@ main ( int argc, char **argv)
   /* set the random seed file */
   if (use_random_seed) {
     char *p = make_filename (opt.homedir, "random_seed", NULL);
-#if 0
-#warning set_random_seed_file not yet available in Libgcrypt
-    set_random_seed_file(p);
-#endif
+    gcry_control (GCRYCTL_SET_RANDOM_SEED_FILE, p);
     xfree(p);
   }
 
@@ -1094,18 +1092,18 @@ main ( int argc, char **argv)
       if (rc)
         {
           log_error (_("can't sign using `%s': %s\n"),
-                     sl->d, gnupg_strerror (rc));
+                     sl->d, gpg_strerror (rc));
           gpgsm_status2 (&ctrl, STATUS_INV_RECP,
-                         rc == -1? "1":
-                         rc == GNUPG_No_Public_Key?       "1":
-                         rc == GNUPG_Ambiguous_Name?      "2":
-                         rc == GNUPG_Wrong_Key_Usage?     "3":
-                         rc == GNUPG_Certificate_Revoked? "4":
-                         rc == GNUPG_Certificate_Expired? "5":
-                         rc == GNUPG_No_CRL_Known?        "6":
-                         rc == GNUPG_CRL_Too_Old?         "7":
-                         rc == GNUPG_No_Policy_Match?     "8":
-                         rc == GNUPG_No_Secret_Key?       "9":
+                         gpg_err_code (rc) == -1?                      "1":
+                         gpg_err_code (rc) == GPG_ERR_NO_PUBKEY?       "1":
+                         gpg_err_code (rc) == GPG_ERR_AMBIGUOUS_NAME?  "2":
+                         gpg_err_code (rc) == GPG_ERR_WRONG_KEY_USAGE? "3":
+                         gpg_err_code (rc) == GPG_ERR_CERT_REVOKED?    "4":
+                         gpg_err_code (rc) == GPG_ERR_CERT_EXPIRED?    "5":
+                         gpg_err_code (rc) == GPG_ERR_NO_CRL_KNOWN?    "6":
+                         gpg_err_code (rc) == GPG_ERR_CRL_TOO_OLD?     "7":
+                         gpg_err_code (rc) == GPG_ERR_NO_POLICY_MATCH? "8":
+                         gpg_err_code (rc) == GPG_ERR_NO_SECKEY?       "9":
                          "0",
                          sl->d, NULL);
         }
@@ -1116,17 +1114,17 @@ main ( int argc, char **argv)
       if (rc)
         {
           log_error (_("can't encrypt to `%s': %s\n"),
-                     sl->d, gnupg_strerror (rc));
+                     sl->d, gpg_strerror (rc));
           gpgsm_status2 (&ctrl, STATUS_INV_RECP,
-                         rc == -1? "1":
-                         rc == GNUPG_No_Public_Key?       "1":
-                         rc == GNUPG_Ambiguous_Name?      "2":
-                         rc == GNUPG_Wrong_Key_Usage?     "3":
-                         rc == GNUPG_Certificate_Revoked? "4":
-                         rc == GNUPG_Certificate_Expired? "5":
-                         rc == GNUPG_No_CRL_Known?        "6":
-                         rc == GNUPG_CRL_Too_Old?         "7":
-                         rc == GNUPG_No_Policy_Match?     "8":
+                         gpg_err_code (rc) == -1?                         "1":
+                         gpg_err_code (rc) == GPG_ERR_NO_PUBKEY?          "1":
+                         gpg_err_code (rc) == GPG_ERR_AMBIGUOUS_NAME?     "2":
+                         gpg_err_code (rc) == GPG_ERR_WRONG_KEY_USAGE?    "3":
+                         gpg_err_code (rc) == GPG_ERR_CERT_REVOKED?       "4":
+                         gpg_err_code (rc) == GPG_ERR_CERT_EXPIRED?       "5":
+                         gpg_err_code (rc) == GPG_ERR_NO_CRL_KNOWN?       "6":
+                         gpg_err_code (rc) == GPG_ERR_CRL_TOO_OLD?        "7":
+                         gpg_err_code (rc) == GPG_ERR_NO_POLICY_MATCH?    "8":
                          "0",
                          sl->d, NULL);
         }
@@ -1289,7 +1287,7 @@ main ( int argc, char **argv)
         {
           int rc = gpgsm_agent_learn ();
           if (rc)
-            log_error ("error learning card: %s\n", gnupg_strerror (rc));
+            log_error ("error learning card: %s\n", gpg_strerror (rc));
         }
       break;
 
@@ -1306,11 +1304,11 @@ main ( int argc, char **argv)
           if (rc)
             ;
           else if (!(grip = gpgsm_get_keygrip_hexstring (cert)))
-            rc = GNUPG_Bug;
+            rc = gpg_error (GPG_ERR_BUG);
           else 
             rc = gpgsm_agent_passwd (grip);
           if (rc)
-            log_error ("error changing passphrase: %s\n", gnupg_strerror (rc));
+            log_error ("error changing passphrase: %s\n", gpg_strerror (rc));
           xfree (grip);
           ksba_cert_release (cert);
         }
@@ -1341,12 +1339,7 @@ emergency_cleanup (void)
 void
 gpgsm_exit (int rc)
 {
-  #if 0
-#warning no update_random_seed_file
-  update_random_seed_file();
-  #endif
-#if 0
-  /* at this time a bit annoying */
+  gcry_control (GCRYCTL_UPDATE_RANDOM_SEED_FILE);
   if (opt.debug & DBG_MEMSTAT_VALUE)
     {
       gcry_control( GCRYCTL_DUMP_MEMORY_STATS );
@@ -1354,7 +1347,6 @@ gpgsm_exit (int rc)
     }
   if (opt.debug)
     gcry_control (GCRYCTL_DUMP_SECMEM_STATS );
-#endif
   emergency_cleanup ();
   rc = rc? rc : log_get_errorcount(0)? 2 : gpgsm_errors_seen? 1 : 0;
   exit (rc);