tools/gpgtar: Handle '--gpg' argument.
authorJustus Winter <justus@g10code.com>
Wed, 25 Nov 2015 13:57:14 +0000 (14:57 +0100)
committerJustus Winter <justus@g10code.com>
Wed, 25 Nov 2015 13:57:14 +0000 (14:57 +0100)
* tools/gpgtar-create.c (gpgtar_create): Use given gpg program.
* tools/gpgtar-extract.c (gpgtar_extract): Likewise.
* tools/gpgtar-list.c (gpgtar_list): Likewise.
* tools/gpgtar.c (enum cmd_and_opt_values): New constant.
(opts): Add argument.
(main): Handle argument.
* tools/gpgtar.h (opt): Add field 'gpg_program'.

Signed-off-by: Justus Winter <justus@g10code.com>
tools/gpgtar-create.c
tools/gpgtar-extract.c
tools/gpgtar-list.c
tools/gpgtar.c
tools/gpgtar.h

index 69ba440..92c1fb8 100644 (file)
@@ -892,7 +892,8 @@ gpgtar_create (char **inpattern, int encrypt)
       if (err)
         goto leave;
 
-      err = gpg_encrypt_stream (NULL, NULL,
+      err = gpg_encrypt_stream (NULL,
+                                opt.gpg_program,
                                 outstream,
                                 opt.recipients,
                                 cipher_stream);
index 594f257..92346b0 100644 (file)
@@ -303,7 +303,7 @@ gpgtar_extract (const char *filename, int decrypt)
           err = gpg_error_from_syserror ();
           goto leave;
         }
-      err = gpg_decrypt_stream (NULL, NULL, cipher_stream, stream);
+      err = gpg_decrypt_stream (NULL, opt.gpg_program, cipher_stream, stream);
       if (err)
         goto leave;
 
index 1f917ad..cdc7fc4 100644 (file)
@@ -306,7 +306,7 @@ gpgtar_list (const char *filename, int decrypt)
           err = gpg_error_from_syserror ();
           goto leave;
         }
-      err = gpg_decrypt_stream (NULL, NULL, cipher_stream, stream);
+      err = gpg_decrypt_stream (NULL, opt.gpg_program, cipher_stream, stream);
       if (err)
         goto leave;
 
index 714b216..c4bf855 100644 (file)
@@ -64,6 +64,7 @@ enum cmd_and_opt_values
     oNoVerbose = 500,
 
     aSignEncrypt,
+    oGpgProgram,
     oSkipCrypto,
     oOpenPGP,
     oCMS,
@@ -90,6 +91,7 @@ static ARGPARSE_OPTS opts[] = {
   ARGPARSE_s_s (oOutput, "output", N_("|FILE|write output to FILE")),
   ARGPARSE_s_n (oVerbose, "verbose", N_("verbose")),
   ARGPARSE_s_n (oQuiet,        "quiet",  N_("be somewhat more quiet")),
+  ARGPARSE_s_s (oGpgProgram, "gpg", "@"),
   ARGPARSE_s_n (oSkipCrypto, "skip-crypto", N_("skip the crypto processing")),
   ARGPARSE_s_s (oSetFilename, "set-filename", "@"),
   ARGPARSE_s_s (oFilesFrom, "files-from",
@@ -221,6 +223,10 @@ main (int argc, char **argv)
           opt.symmetric = 1;
           break;
 
+        case oGpgProgram:
+          opt.gpg_program = pargs.r.ret_str;
+          break;
+
         case oSkipCrypto:
           skip_crypto = 1;
           break;
index ab2ccec..98fd51c 100644 (file)
@@ -29,6 +29,7 @@ struct
   int verbose;
   unsigned int debug_level;
   int quiet;
+  const char *gpg_program;
   const char *outfile;
   strlist_t recipients;
   const char *user;