! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
commands with quotes do not run in genmon
Status:
RESOLVED: FIXED
Product:
Xfce4-genmon-plugin
Component:
General

Comments

Description Steve 2008-04-19 21:46:24 CEST
Commands with quotes do not run. Instead, the genmon plugin displays "XXX".
Reproduce by configuring genmon to invoke this command once per second:
sh -c 'echo -n "foo "; echo bar'
In a terminal window, this command produces "foo bar".

The problem is that the command line is over-parsed. From strace:
$ ps -e | fgrep genmon
13783 ?        00:00:01 xfce4-genmon-pl
$ strace -p 13783 -f -e write=2 2>x.log

[pid 14338] execve("/bin/sh", ["sh"..., "-c"..., "\'echo"..., "-n"..., "\"foo"..., "\";"..., "echo"..., "bar\'"...], [/* 39 vars */]) = 0

Which produces these errors:
[pid 14338] write(2, "-n: -c: line 0: unexpected EOF w"..., 62) = 62
 | 00000  2d 6e 3a 20 2d 63 3a 20  6c 69 6e 65 20 30 3a 20  -n: -c:  line 0:  |
 | 00010  75 6e 65 78 70 65 63 74  65 64 20 45 4f 46 20 77  unexpect ed EOF w |
 | 00020  68 69 6c 65 20 6c 6f 6f  6b 69 6e 67 20 66 6f 72  hile loo king for |
 | 00030  20 6d 61 74 63 68 69 6e  67 20 60 27 27 0a         matchin g `''.   |
[pid 14338] write(2, "-n: -c: line 1: syntax error: un"..., 53) = 53
 | 00000  2d 6e 3a 20 2d 63 3a 20  6c 69 6e 65 20 31 3a 20  -n: -c:  line 1:  |
 | 00010  73 79 6e 74 61 78 20 65  72 72 6f 72 3a 20 75 6e  syntax e rror: un |
 | 00020  65 78 70 65 63 74 65 64  20 65 6e 64 20 6f 66 20  expected  end of  |
 | 00030  66 69 6c 65 0a                                    file.             |

The same command run from the launcher plugin does not produce any errors (as shown by strace). The launcher plugin calls g_shell_parse_argv() in xfce4-panel-4.4.2/plugins/launcher/launcher.c.

A suggested solution is to replace the call to ParseCmdline() in cmdspawn.c with a call to g_shell_parse_argv() and remove ParseCmdline() from cmdspawn.c.

g_shell_parse_argv() is documented here:
http://library.gnome.org/devel/glib/stable/glib-Shell-related-Utilities.html#g-shell-parse-argv

xfce4-genmon-plugin 3.2 - Generic Monitor
Comment 1 Steve 2008-04-20 17:29:36 CEST
Created attachment 1599 
call g_shell_parse_argv() instead of ParseCmdline() in cmdspawn.c

This patch fixes this bug.

Test with this command and the update period set to 10 seconds:
sh -c 'date | tr -d "\n"; echo -n " foo "; echo bar'

Remove the last quote to test error handling.
Setting the update period to 10 seconds simplifies the error handling test.
With an update period of one second, error dialogs pop up so fast that it is difficult to correct the error.
Comment 2 Florian Rivoal editbugs 2011-02-24 15:19:06 CET
Patch applied. Thanks for your contribution.

Bug #4028

Reported by:
Steve
Reported on: 2008-04-19
Last modified on: 2011-02-24

People

Assignee:
Florian Rivoal
CC List:
0 users

Version

Version:
3.2 or older

Attachments

Additional information