bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-tar] rmt tar hangs


From: Sergey Poznyakoff
Subject: Re: [Bug-tar] rmt tar hangs
Date: Tue, 14 Sep 2010 13:00:57 +0300

Roland JARRY <address@hidden> ha escrit:

> local : /usr/local/bin/tar x --directory / --rmt-command=/etc/rmt -f
> rmt is launched on the remote machine but doing nothing and tar doesn't
> finish.
> I've installed the same version on local and remote servers.

Thanks for reporting.  Please try the attached patch.  Let me know
if it works for you.

Regards,
Sergey

diff --git a/rmt/rmt.c b/rmt/rmt.c
index 098ff57..c963fb5 100644
--- 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;
-       }
+      numeric_mode = strtol (mstr, (char**) &p, 10);
+      mstr = skip_ws (p);
+    }
 
-      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
+  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;
 }

reply via email to

[Prev in Thread] Current Thread [Next in Thread]