Code

Removed debug line
[nagiosplug.git] / plugins / popen.c
index 80a7119b983cc711452a3524f77417e1434c8b58..45d2a3dc937e19345e4da5605465660f683c6673 100644 (file)
@@ -104,7 +104,7 @@ spopen (const char *cmdstring)
        char *env[2];
        char *cmd = NULL;
        char **argv = NULL;
-       char *str;
+       char *str, *tmp;
        int argc;
 
        int i = 0, pfd[2], pfderr[2];
@@ -166,7 +166,15 @@ spopen (const char *cmdstring)
                        cmd = 1 + strstr (str, "'");
                        str[strcspn (str, "'")] = 0;
                }
-               else {
+               else if (strcspn(str,"'") < strcspn (str, " \t\r\n")) {
+                                                                               /* handle --option='foo bar' strings */
+                       tmp = str + strcspn(str, "'") + 1; 
+                       if (!strstr (tmp, "'"))
+                               return NULL;                                            /* balanced? */
+                       tmp += strcspn(tmp,"'") + 1;
+                       *tmp = 0;
+                       cmd = tmp + 1;
+               } else {
                        if (strpbrk (str, " \t\r\n")) {
                                cmd = 1 + strpbrk (str, " \t\r\n");
                                str[strcspn (str, " \t\r\n")] = 0;