]> git.cworth.org Git - tar/commitdiff
patch from upstream to fix mixed file mode representation problem in rmt
authorBdale Garbee <bdale@gag.com>
Wed, 22 Sep 2010 06:33:49 +0000 (00:33 -0600)
committerBdale Garbee <bdale@gag.com>
Wed, 22 Sep 2010 06:33:49 +0000 (00:33 -0600)
debian/changelog
rmt/rmt.c

index 65b8bee0462b6c81a71c7ddf5da99bdd5d24ec52..9c9e6f78f6035be5b8aba5f891691bd72a79e24f 100644 (file)
@@ -1,10 +1,12 @@
-tar (1.23-3) UNRELEASED; urgency=low
+tar (1.23-3) UNRELEASED; urgency=medium
 
   * add xz-utils back to the Suggests list since it may not be 'required'
     forever
   * current debhelper includes trigger support, closes: #561598
+  * patch from upstream to fix ability of rmt to accept mixed file mode
+    representations, closes: #587702, #597672
 
- -- Bdale Garbee <bdale@gag.com>  Tue, 15 Jun 2010 09:32:39 -0600
+ -- Bdale Garbee <bdale@gag.com>  Wed, 22 Sep 2010 00:33:16 -0600
 
 tar (1.23-2.1) unstable; urgency=low
 
index a3897eb56f0fc06d91417d8d92ff373d4c44a60f..4932ae8c73498e543cb437a63f793503dd25b04a 100644 (file)
--- a/rmt/rmt.c
+++ b/rmt/rmt.c
@@ -100,6 +100,7 @@ rmt_write (const char *fmt, ...)
   va_list ap;
   va_start (ap, fmt);
   vfprintf (stdout, fmt, ap);
+  fflush (stdout);
   VDEBUG (10, "S: ", fmt, ap);
 }
 
@@ -117,6 +118,7 @@ rmt_error_message (int code, const char *msg)
   DEBUG1 (10, "S: %s\n", msg);
   DEBUG1 (1, "error: %s\n", msg);
   fprintf (stdout, "E%d\n%s\n", code, msg);
+  fflush (stdout);
 }
 
 void
@@ -225,44 +227,57 @@ static struct rmt_kw const open_flag_kw[] =
 int
 decode_open_flag (const char *mstr, int *pmode)
 {
+  int numeric_mode = 0;
   int mode = 0;
+  const char *p;
 
-  while (mstr)
+  mstr = skip_ws (mstr);
+  if (c_isdigit (*mstr))
     {
-      int v;
-      const char *p;
-
-      mstr = skip_ws (mstr);
-      if (*mstr == 0)
-       break;
-      else if (c_isdigit (*mstr))
-       v = strtol (mstr, (char**) &p, 10);
-      else if (xlat_kw (mstr, "O_", open_flag_kw, &v, &p))
-       {
-         rmt_error_message (EINVAL, "invalid open mode");
-         return 1;
-       }
-
-      mode |= v;
+      numeric_mode = strtol (mstr, (char**) &p, 10);
+      mstr = skip_ws (p);
+    }
       
-      if (*p && c_isblank (*p))
-       p = skip_ws (p);
-      if (*p == 0)
-       break;
-      else if (*p == '|')
-       {
-         /* FIXMEL
-            if (p[1] == 0)
-              rmt_error_message (EINVAL, "invalid open mode");
-         */
-         mstr = p + 1;
-       }
-      else
+  if (*mstr)
+    {
+       while (mstr)
        {
-         rmt_error_message (EINVAL, "invalid open mode");
-         return 1;
+          int v;
+        
+          mstr = skip_ws (mstr);
+          if (*mstr == 0)
+            break;
+          else if (c_isdigit (*mstr))
+            v = strtol (mstr, (char**) &p, 10);
+          else if (xlat_kw (mstr, "O_", open_flag_kw, &v, &p))
+            {
+              rmt_error_message (EINVAL, "invalid open mode");
+              return 1;
+            }
+  
+          mode |= v;
+        
+          if (*p && c_isblank (*p))
+            p = skip_ws (p);
+          if (*p == 0)
+            break;
+          else if (*p == '|')
+            {
+              /* FIXMEL
+                 if (p[1] == 0)
+                 rmt_error_message (EINVAL, "invalid open mode");
+              */
+              mstr = p + 1;
+            }
+          else
+            {
+              rmt_error_message (EINVAL, "invalid open mode");
+              return 1;
+            }
        }
     }
+  else
+    mode = numeric_mode;
   *pmode = mode;
   return 0;
 }
@@ -288,6 +303,10 @@ decode_open_flag (const char *mstr, int *pmode)
       64|512
       CREAT|TRUNC
 
+   In addition, a compined form is also allowed, i.e. a decimal mode followed
+   by its symbolic representation.  In this case the symbolic representation
+   is given preference.
+
    Reply
    -----
    A0\n on success, E<errno>\n<msg>\n on error.