[Patch] Make cygcheck handle Window paths with spaces

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Patch] Make cygcheck handle Window paths with spaces

Pierre A. Humblet-2
Formatting is more likely to be preserved in the attached files.

Pierre

2008-12-30  Pierre Humblet  <[hidden email]>

        * cygcheck.cc (pretty_id): Quote the path for popen.
        (dump_sysinfo_services): Ditto.


Index: cygcheck.cc
===================================================================
RCS file: /cvs/src/src/winsup/utils/cygcheck.cc,v
retrieving revision 1.105
diff -u -p -r1.105 cygcheck.cc
--- cygcheck.cc 12 Sep 2008 22:43:10 -0000 1.105
+++ cygcheck.cc 30 Dec 2008 19:20:32 -0000
@@ -1032,9 +1032,10 @@ pretty_id (const char *s, char *cygwin,
       return;
     }
 
-  FILE *f = popen (id, "rt");
-
   char buf[16384];
+  snprintf (buf, sizeof (buf), "\"%s\"", id);
+  FILE *f = popen (buf, "rt");
+
   buf[0] = '\0';
   fgets (buf, sizeof (buf), f);
   pclose (f);
@@ -1118,7 +1119,7 @@ dump_sysinfo_services ()
     }
 
   /* check for a recent cygrunsrv */
-  snprintf (buf, sizeof (buf), "%s --version", cygrunsrv);
+  snprintf (buf, sizeof (buf), "\"%s\" --version", cygrunsrv);
   if ((f = popen (buf, "rt")) == NULL)
     {
       printf ("Failed to execute '%s', skipping services check.\n", buf);
@@ -1136,7 +1137,7 @@ dump_sysinfo_services ()
   /* For verbose mode, just run cygrunsrv --list --verbose and copy output
      verbatim; otherwise run cygrunsrv --list and then cygrunsrv --query for
      each service.  */
-  snprintf (buf, sizeof (buf), (verbose ? "%s --list --verbose" : "%s --list"),
+  snprintf (buf, sizeof (buf), (verbose ? "\"%s\" --list --verbose" : "%s --list"),
      cygrunsrv);
   if ((f = popen (buf, "rt")) == NULL)
     {
@@ -1167,7 +1168,7 @@ dump_sysinfo_services ()
       if (nchars > 0)
  for (char *srv = strtok (buf, "\n"); srv; srv = strtok (NULL, "\n"))
    {
-     snprintf (buf2, sizeof (buf2), "%s --query %s", cygrunsrv, srv);
+     snprintf (buf2, sizeof (buf2), "\"%s\" --query %s", cygrunsrv, srv);
      if ((f = popen (buf2, "rt")) == NULL)
        {
   printf ("Failed to execute '%s', skipping services check.\n", buf2);

cygcheck.cc.diff (1K) Download Attachment
ChangeLog.cygcheck (157 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Patch] Make cygcheck handle Window paths with spaces

Christopher Faylor-8
On Tue, Dec 30, 2008 at 03:14:30PM -0500, Pierre A. Humblet wrote:
>Formatting is more likely to be preserved in the attached files.
>
>Pierre
>
>2008-12-30  Pierre Humblet  <[hidden email]>
>
>        * cygcheck.cc (pretty_id): Quote the path for popen.
>        (dump_sysinfo_services): Ditto.

Looks good.  Please check in.

Thanks.

cgf
Reply | Threaded
Open this post in threaded view
|

Re: [Patch] Make cygcheck handle Windows paths with spaces

Pierre A. Humblet-2
In reply to this post by Pierre A. Humblet-2
Oops, I didn't notice that one line required a double fix.

Pierre

2009-01-05  Pierre Humblet  <[hidden email]>
 
        * cygcheck.cc (dump_sysinfo_services): Quote the path for popen.

Index: cygcheck.cc
===================================================================
RCS file: /cvs/src/src/winsup/utils/cygcheck.cc,v
retrieving revision 1.106
diff -u -p -r1.106 cygcheck.cc
--- cygcheck.cc 31 Dec 2008 01:44:36 -0000      1.106
+++ cygcheck.cc 5 Jan 2009 15:05:56 -0000
@@ -1137,7 +1137,7 @@ dump_sysinfo_services ()
   /* For verbose mode, just run cygrunsrv --list --verbose and copy output
      verbatim; otherwise run cygrunsrv --list and then cygrunsrv --query for
      each service.  */
-  snprintf (buf, sizeof (buf), (verbose ? "\"%s\" --list --verbose" : "%s --list"),
+  snprintf (buf, sizeof (buf), (verbose ? "\"%s\" --list --verbose" : "\"%s\" --list"),
            cygrunsrv);
   if ((f = popen (buf, "rt")) == NULL)
     {

----- Original Message -----
From: "Pierre A. Humblet" <[hidden email]>
To: <[hidden email]>
Sent: Tuesday, December 30, 2008 3:14 PM
Subject: [Patch] Make cygcheck handle Window paths with spaces


| Formatting is more likely to be preserved in the attached files.
|
| Pierre
|
| 2008-12-30  Pierre Humblet  <[hidden email]>
|
|        * cygcheck.cc (pretty_id): Quote the path for popen.
|        (dump_sysinfo_services): Ditto.
|
|
| Index: cygcheck.cc
| ===================================================================
| RCS file: /cvs/src/src/winsup/utils/cygcheck.cc,v
| retrieving revision 1.105
| diff -u -p -r1.105 cygcheck.cc
| --- cygcheck.cc 12 Sep 2008 22:43:10 -0000 1.105
| +++ cygcheck.cc 30 Dec 2008 19:20:32 -0000
| @@ -1032,9 +1032,10 @@ pretty_id (const char *s, char *cygwin,
|       return;
|     }
|
| -  FILE *f = popen (id, "rt");
| -
|   char buf[16384];
| +  snprintf (buf, sizeof (buf), "\"%s\"", id);
| +  FILE *f = popen (buf, "rt");
| +
|   buf[0] = '\0';
|   fgets (buf, sizeof (buf), f);
|   pclose (f);
| @@ -1118,7 +1119,7 @@ dump_sysinfo_services ()
|     }
|
|   /* check for a recent cygrunsrv */
| -  snprintf (buf, sizeof (buf), "%s --version", cygrunsrv);
| +  snprintf (buf, sizeof (buf), "\"%s\" --version", cygrunsrv);
|   if ((f = popen (buf, "rt")) == NULL)
|     {
|       printf ("Failed to execute '%s', skipping services check.\n", buf);
| @@ -1136,7 +1137,7 @@ dump_sysinfo_services ()
|   /* For verbose mode, just run cygrunsrv --list --verbose and copy output
|      verbatim; otherwise run cygrunsrv --list and then cygrunsrv --query for
|      each service.  */
| -  snprintf (buf, sizeof (buf), (verbose ? "%s --list --verbose" : "%s --list"),
| +  snprintf (buf, sizeof (buf), (verbose ? "\"%s\" --list --verbose" : "%s --list"),
|      cygrunsrv);
|   if ((f = popen (buf, "rt")) == NULL)
|     {
| @@ -1167,7 +1168,7 @@ dump_sysinfo_services ()
|       if (nchars > 0)
|  for (char *srv = strtok (buf, "\n"); srv; srv = strtok (NULL, "\n"))
|    {
| -     snprintf (buf2, sizeof (buf2), "%s --query %s", cygrunsrv, srv);
| +     snprintf (buf2, sizeof (buf2), "\"%s\" --query %s", cygrunsrv, srv);
|      if ((f = popen (buf2, "rt")) == NULL)
|        {
|   printf ("Failed to execute '%s', skipping services check.\n", buf2);
|
Reply | Threaded
Open this post in threaded view
|

Re: [Patch] Make cygcheck handle Windows paths with spaces

Christopher Faylor-8
On Mon, Jan 05, 2009 at 10:19:59AM -0500, Pierre A. Humblet wrote:
>Oops, I didn't notice that one line required a double fix.
>
>Pierre
>
>2009-01-05  Pierre Humblet  <[hidden email]>
>
>        * cygcheck.cc (dump_sysinfo_services): Quote the path for popen.

Looks good.  Please check in.

Thanks.

cgf