Add more options to gpgtar
authorWerner Koch <wk@gnupg.org>
Tue, 24 Aug 2010 09:20:47 +0000 (09:20 +0000)
committerWerner Koch <wk@gnupg.org>
Tue, 24 Aug 2010 09:20:47 +0000 (09:20 +0000)
ChangeLog
Makefile.am
packages/packages.current
patches/gnupg2-2.0.16/04-gpgtar-2.patch [new file with mode: 0755]

index d55eb3e..6a745df 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,15 @@
-2010-08-17  Emanuel Schuetze <emanuel@intevation.de>
+2010-08-24  Werner Koch  <wk@g10code.com>
 
-       * configure.ac: Added date and version for English compendium.
+       * patches/gnupg2-2.0.16/04-gpgtar-2.patch: New.
+       * Makefile.am (EXTRA_DIST): Add patch
 
+2010-08-24  Werner Koch  <wk@g10code.com>
+
+       * packages/packages.current: Update libassuan.
 
+2010-08-17  Emanuel Schuetze <emanuel@intevation.de>
+
+       * configure.ac: Added date and version for English compendium.
 
 2010-07-27  Werner Koch  <wk@g10code.com>
 
index c1455ca..f3c2458 100644 (file)
@@ -62,6 +62,7 @@ EXTRA_DIST = autogen.sh README.SVN ONEWS \
        patches/gnupg2-2.0.16/01-estream.patch \
        patches/gnupg2-2.0.16/02-gpgtar.patch \
         patches/gnupg2-2.0.16/03-kbx-realloc.patch \
+       patches/gnupg2-2.0.16/04-gpgtar-2.patch \
        patches/dirmngr-1.0.3/01-ldaphttp.patch \
        patches/gpgol-0.9.91/01-gpgme.patch \
         patches/gpa-0.9.0/01-title-prop.patch \
index c881c9a..8e966f7 100644 (file)
@@ -331,8 +331,8 @@ chk  268e424e94e62abb51eeca9c66d886dbee8455ab
 file libgcrypt/libgcrypt-1.4.6.tar.bz2
 chk  445b9e158aaf91e24eae3d1040c6213e9d9f5ba6
 
-#file libassuan/libassuan-2.0.0.tar.bz2
-#chk  b03c586a4eefdfc0bb1ec65ecf958b9890d429f7
+file libassuan/libassuan-2.0.1.tar.bz2
+chk  b7e9dbd41769cc20b1fb7db9f2ecdf276ffc352c
 
 name gnupg2-2.0.16.tar.bz2
 file gnupg/gnupg-2.0.16.tar.bz2
@@ -353,9 +353,6 @@ server ftp://ftp.g10code.com/g10code/scratch
 file gpgme-1.3.1-svn1460.tar.bz2
 chk  a309ae1880c84bf7d76fea7186b3247ee70b1693
 
-file libassuan-2.0.1-svn378.tar.bz2
-chk  2dcfad0f3cf0ef65af382892d6cdfee573ff6c22
-
 
 #
 #  GnuPG utilities
diff --git a/patches/gnupg2-2.0.16/04-gpgtar-2.patch b/patches/gnupg2-2.0.16/04-gpgtar-2.patch
new file mode 100755 (executable)
index 0000000..0a1f4aa
--- /dev/null
@@ -0,0 +1,259 @@
+#! /bin/sh
+patch -p1 -f $* < $0
+exit $?
+
+[tools/]
+2010-08-24  Werner Koch  <wk@g10code.com>
+
+       * gpgtar-create.c (gpgtar_create): Allow "-" for stdout in
+       opt.outfile.  Switch es_stdout to binary mode.
+
+       * gpgtar.c (main): Add options -T and --null.
+       * gpgtar-create.c (gpgtar_create): Implement option --null.
+
+
+diff -urpN orig/gnupg2-2.0.16/tools/gpgtar-create.c gnupg2-2.0.16/tools/gpgtar-create.c
+--- orig/gnupg2-2.0.16/tools/gpgtar-create.c   2010-08-24 09:19:53.000000000 +0200
++++ gnupg2-2.0.16/tools/gpgtar-create.c        2010-08-24 09:31:54.000000000 +0200
+@@ -28,6 +28,7 @@
+ #ifdef HAVE_W32_SYSTEM
+ # define WIN32_LEAN_AND_MEAN
+ # include <windows.h>
++# include <fcntl.h> /* for setmode() */
+ #else /*!HAVE_W32_SYSTEM*/
+ # include <unistd.h>
+ # include <pwd.h>
+@@ -736,27 +737,88 @@ write_eof_mark (estream_t stream)
\f
++/* Create a new tarball using the names in the array INPATTERN.  If
++   INPATTERN is NULL take the pattern as null terminated strings from
++   stdin.  */
+ void
+ gpgtar_create (char **inpattern)
+ {
+   gpg_error_t err = 0;
+-  const char *pattern;
+   struct scanctrl_s scanctrl_buffer;
+   scanctrl_t scanctrl = &scanctrl_buffer;
+   tar_header_t hdr, *start_tail;
+   estream_t outstream = NULL;
++  int eof_seen = 0;
++
++  if (!inpattern)
++    setmode (es_fileno (es_stdin), O_BINARY);
+   memset (scanctrl, 0, sizeof *scanctrl);
+   scanctrl->flist_tail = &scanctrl->flist;
+-  for (; (pattern = *inpattern); inpattern++)
++  while (!eof_seen)
+     {
+       char *pat, *p;
++      int skip_this = 0;
++
++      if (inpattern)
++        {
++          const char *pattern = *inpattern;
++
++          if (!pattern)
++            break; /* End of array.  */
++          inpattern++;
++          
++          if (!*pattern)
++            continue;
++
++          pat = xtrystrdup (pattern);
++        }
++      else /* Read null delimited pattern from stdin.  */
++        {
++          int c;
++          char namebuf[4096];
++          size_t n = 0;
++          
++          for (;;)
++            {
++              if ((c = es_getc (es_stdin)) == EOF)
++                {
++                  if (es_ferror (es_stdin))
++                    {
++                      err = gpg_error_from_syserror ();
++                      log_error ("error reading `%s': %s\n",
++                                 "[stdin]", strerror (errno));
++                      goto leave;
++                    }
++                  /* Note: The Nul is a delimiter and not a terminator.  */
++                  c = 0;
++                  eof_seen = 1;
++                }
++              if (n >= sizeof namebuf - 1)
++                {
++                  if (!skip_this)
++                    {
++                      skip_this = 1;
++                      log_error ("error reading `%s': %s\n",
++                                 "[stdin]", "filename too long");
++                    }
++                }
++              else
++                namebuf[n++] = c;
++              if (!c)
++                {
++                  namebuf[n] = 0;
++                  break;
++                }
++            }
++          
++          if (skip_this || n < 2)
++            continue;
+-      if (!*pattern)
+-        continue;
++          pat = xtrystrdup (namebuf);
++        }
+-      pat = xtrystrdup (pattern);
+       if (!pat)
+         {
+           err = gpg_error_from_syserror ();
+@@ -771,7 +833,7 @@ gpgtar_create (char **inpattern)
+         log_info ("scanning `%s'\n", pat);
+       start_tail = scanctrl->flist_tail;
+-      if (!pattern_valid_p (pat))
++      if (skip_this || !pattern_valid_p (pat))
+         log_error ("skipping invalid name `%s'\n", pat);
+       else if (!add_entry (pat, NULL, scanctrl)
+                && *start_tail && ((*start_tail)->typeflag & TF_DIRECTORY))
+@@ -782,7 +844,10 @@ gpgtar_create (char **inpattern)
+   if (opt.outfile)
+     {
+-      outstream = es_fopen (opt.outfile, "wb");
++      if (!strcmp (opt.outfile, "-"))
++        outstream = es_stdout;
++      else
++        outstream = es_fopen (opt.outfile, "wb");
+       if (!outstream)
+         {
+           err = gpg_error_from_syserror ();
+@@ -796,6 +861,9 @@ gpgtar_create (char **inpattern)
+       outstream = es_stdout;
+     }
++  if (outstream == es_stdout)
++    setmode (es_fileno (es_stdout), O_BINARY);
++
+   for (hdr = scanctrl->flist; hdr; hdr = hdr->next)
+     {
+       err = write_file (outstream, hdr);
+diff -urpN orig/gnupg2-2.0.16/tools/gpgtar.c gnupg2-2.0.16/tools/gpgtar.c
+--- orig/gnupg2-2.0.16/tools/gpgtar.c  2010-08-24 09:19:53.000000000 +0200
++++ gnupg2-2.0.16/tools/gpgtar.c       2010-08-24 09:38:15.000000000 +0200
+@@ -55,12 +55,16 @@ enum cmd_and_opt_values
+     oOutput   = 'o',
+     oQuiet      = 'q',
+     oVerbose  = 'v',
++    oFilesFrom  = 'T',
+     oNoVerbose        = 500,
+     aSignEncrypt,
+     oSkipCrypto,
++    oOpenPGP,
++    oCMS,
+     oSetFilename,
+-    aList
++    aList,
++    oNull
+   };
+@@ -84,6 +88,11 @@ static ARGPARSE_OPTS opts[] = {
+   ARGPARSE_s_n (oQuiet,       "quiet",  N_("be somewhat more quiet")),
+   ARGPARSE_s_n (oSkipCrypto, "skip-crypto", N_("skip the crypto processing")),
+   ARGPARSE_s_s (oSetFilename, "set-filename", "@"),
++  ARGPARSE_s_s (oFilesFrom, "files-from",
++                N_("|FILE|get names to create from FILE")),
++  ARGPARSE_s_n (oNull, "null", N_("-T reads null-terminated names")),
++  ARGPARSE_s_n (oOpenPGP, "openpgp", "@"),
++  ARGPARSE_s_n (oCMS, "cms", "@"),
+   ARGPARSE_end ()
+ };
+@@ -157,6 +166,8 @@ main (int argc, char **argv)
+   int no_more_options = 0;
+   enum cmd_and_opt_values cmd = 0;
+   int skip_crypto = 0;
++  const char *files_from = NULL;
++  int null_names = 0;
+   assert (sizeof (struct ustar_raw_header) == 512);
+@@ -181,6 +192,8 @@ main (int argc, char **argv)
+       case oQuiet:     opt.quiet = 1; break;
+         case oVerbose:   opt.verbose++; break;
+         case oNoVerbose: opt.verbose = 0; break;
++        case oFilesFrom: files_from = pargs.r.ret_str; break;
++        case oNull: null_names = 1; break;
+           
+       case aList:
+         case aDecrypt:
+@@ -198,10 +211,18 @@ main (int argc, char **argv)
+           skip_crypto = 1;
+           break;
++        case oOpenPGP: /* Dummy option for now.  */ break;
++        case oCMS:     /* Dummy option for now.  */ break;
++
+         default: pargs.err = 2; break;
+       }
+     }
+   
++  if ((files_from && !null_names) || (!files_from && null_names))
++    log_error ("--files-from and --null may only be used in conjunction\n");
++  if (files_from && strcmp (files_from, "-"))
++    log_error ("--files-from only supports argument \"-\"\n");
++
+   if (log_get_errorcount (0))
+     exit (2);
+@@ -213,6 +234,8 @@ main (int argc, char **argv)
+       fname = argc ? *argv : NULL;
+       if (opt.filename)
+         log_info ("note: ignoring option --set-filename\n");
++      if (files_from)
++        log_info ("note: ignoring option --files-from\n");
+       if (skip_crypto)
+         gpgtar_list (fname);
+       else
+@@ -220,14 +243,15 @@ main (int argc, char **argv)
+       break;
+     case aEncrypt:
+-      if (!argc)
++      if ((!argc && !null_names)
++          || (argc && null_names))
+         usage (1);
+       if (opt.filename)
+         log_info ("note: ignoring option --set-filename\n");
+       if (skip_crypto)
+-        gpgtar_create (argv);
++        gpgtar_create (null_names? NULL :argv);
+       else
+-        tar_and_encrypt (argv);
++        tar_and_encrypt (null_names? NULL : argv);
+       break;
+     case aDecrypt:
+@@ -235,6 +259,8 @@ main (int argc, char **argv)
+         usage (1);
+       if (opt.outfile)
+         log_info ("note: ignoring option --output\n");
++      if (files_from)
++        log_info ("note: ignoring option --files-from\n");
+       fname = argc ? *argv : NULL;
+       if (skip_crypto)
+         gpgtar_extract (fname);
+
+