]> granicus.if.org Git - mutt/commitdiff
Hardwire some mechanisms for finding secret and public key-rings.
authorThomas Roessler <roessler@does-not-exist.org>
Thu, 3 Jun 1999 20:12:10 +0000 (20:12 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Thu, 3 Jun 1999 20:12:10 +0000 (20:12 +0000)
This way, we need to hard-wire less stuff in the various
configuration files, making the use of PGP with mutt a bit simpler
again.

contrib/pgp2.rc
contrib/pgp5.rc
doc/PGP-Notes.txt
pgppubring.c

index d22cd44ce0808174a8b350f94575732f5aea9ee0..47eb6c7cc6dcc51a4c81d173c716b44763574b78 100644 (file)
@@ -33,9 +33,8 @@ set pgp_export_command="pgp -kxaf +language=mutt %r"
 set pgp_verify_key_command="pgp -kcc +language=mutt %r"
 
 # read in the public key ring
-set pgp_list_pubring_command="pgpring -k $PGPPATH/pubring.pgp %r"
+set pgp_list_pubring_command="pgpring -2 %r"
 
 # read in the secret key ring
-set pgp_list_secring_command="pgpring -k $PGPPATH/secring.pgp %r"
-
+set pgp_list_secring_command="pgpring -s -2 %r"
 
index 0a54f941ff79089c283ed3d35eb22e640debcd7a..11b914b0d4a7b22eef6563fbe92effd87ecc3f16 100644 (file)
@@ -33,9 +33,9 @@ set pgp_export_command="pgpk -xa +language=mutt --OutputInformationFD=1 %r"
 set pgp_verify_key_command="pgpk -c +batchmode +language=mutt --OutputInformationFD=1 %r"
 
 # read in the public key ring
-set pgp_list_pubring_command="pgpring -k $PGPPATH/pubring.pkr %r"
+set pgp_list_pubring_command="pgpring -5 %r" 
 
 # read in the secret key ring
-set pgp_list_secring_command="pgpring -k $PGPPATH/secring.skr %r"
+set pgp_list_secring_command="pgpring -5 -s %r"
 
 
index 85c31639805e13a0cc96557617799f6586ba9ca0..ea2b13bd5cc3ee0cae6041c0eadc02e5a50e1e3f 100644 (file)
@@ -133,6 +133,17 @@ mimics the one used by the GNU Privacy Guard (GPG).
 
 You'll need this program with PGP 2 and PGP 5.
 
+Command line options:
+
+       -k <key ring>   Dump the contents of the key ring specified
+                       as an argument to -k.
+                       
+       -2, -5          Use the default key ring for PGP 2 or 5, 
+                       respectively.
+                       
+       -s              Dump the secret key ring.
+
+
 
 2. pgpewrap
 
index ff3c27f74040957997d66c9f0a4d675f694afca5..318e45c39743e3d582cb1c9a4b3868af73183c8e 100644 (file)
@@ -63,33 +63,73 @@ int main (int argc, char * const argv[])
 {
   int c;
   
+  short version = 2;
+  short secring = 0;
+  
+  const char *_kring = NULL;
+  char *env_pgppath, *env_home;
+
+  char pgppath[_POSIX_PATH_MAX];
   char kring[_POSIX_PATH_MAX];
-  char *pgppath;
 
-  if ((pgppath = getenv ("PGPPATH")))
-    snprintf (kring, sizeof (kring), "%s/%s", pgppath, "pubring.pgp");
+  while ((c = getopt (argc, argv, "25sk:")) != EOF)
+  {
+    switch (c)
+    {
+      case 'k':
+      {
+       _kring = optarg;
+       break;
+      }
+      
+      case '2': case '5':
+      {
+       version = 'c' - '0';
+       break;
+      }
+      
+      case 's':
+      {
+       secring = 1;
+       break;
+      }
+    
+      default:
+      {
+       fprintf (stderr, "usage: %s [-k <key ring> | [-2 | -5] [ -s]] [hints]\n",
+                argv[0]);
+       exit (1);
+      }
+    }
+  }
+
+  if (_kring)
+    strfcpy (kring, _kring, sizeof (kring));
   else
-    *kring = '\0';
-  
-  while ((c = getopt (argc, argv, "k:")) != EOF)
   {
-    if (c == 'k')
-      strfcpy (kring, optarg, sizeof (kring));
+    if ((env_pgppath = getenv ("PGPPATH")))
+      strfcpy (pgppath, env_pgppath, sizeof (pgppath));
+    else if ((env_home = getenv ("HOME")))
+      snprintf (pgppath, sizeof (pgppath), "%s/.pgp", env_home);
     else
     {
-      fprintf (stderr, "usage: %s [-k key ring] [hints]\n",
-              argv[0]);
+      fprintf (stderr, "%s: Can't determine your PGPPATH.\n", argv[0]);
       exit (1);
     }
+    
+    if (secring)
+      snprintf (kring, sizeof (kring), "%s/secring.%s", pgppath, version == 2 ? "pgp" : "skr");
+    else
+      snprintf (kring, sizeof (kring), "%s/pubring.%s", pgppath, version == 2 ? "pgp" : "pkr");
   }
   
   pgpring_find_candidates (kring, argv + optind, argc - optind);
     
   return 0;
 }
-              
 
 
+/* The actual key ring parser */
 
 enum packet_tags
 {