help-cfengine
[Top][All Lists]
Advanced

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

Re: 2.1.17 having issue with ExecResult() using pipelines


From: nathan r. hruby
Subject: Re: 2.1.17 having issue with ExecResult() using pipelines
Date: Fri, 11 Nov 2005 13:06:25 -0500 (EST)

On Fri, 11 Nov 2005, Brendan Strejcek wrote:

nathan r. hruby wrote:

On Fri, 11 Nov 2005, Martin, Jason H wrote:

If yada isn't in the normal path then that might be a problem; I don't
know what PATH will be set to when that happens. Good point.


Err.. right: here's the full real command:
        CurrentLoad = ( ExecResult(/bin/sh -c "/bin/cat /proc/loadavg |
        /bin/awk '{print $1}' | tr -d '\n'") )

What I'm seeing in 2.1.17 is that everything after "/bin/cat" simply
dissapears and thus no pipeline. eg, run a ps -ef while this is
runnning and the awk and tr are not being executed. The above works in
2.1.14.

It might be interesting to trace the cfagent, so see exactly what it is
doing. You don't really know what snapshot you are getting when you just
run ps at a particular point in time.

Linux: strace -f cfagent -q

Solaris: truss -f cfagent -q # truss output goes to stderr

BSD (and OS X): ktrace -di cfagent -q; ktrace -C; kdump | less; rm ktrace.out

Stick an "env -i" before the cfagent if you don't want your current
environment to influence its behavior.


strace stops at a read(), which is expected because cfagent is running
"/bin/cat" with no arguments, so it'll never read anything, and spin.
Since it is sitting at a read(), there's plenty time enough for me to
switch to a different terminal and run ps -ef :)

To my less than trained C coding eye, It appears that cfpopen() changed
the way it cleans things up before sending them to execve() and thus,
quoting is being removed and the pipe is being passed as a series of
arguments, instead of one long argument.  This is a bit of a shot from a
quick glance at the source between meetings.

strace is attached, note that I had to ^C to finish, so the read() is
unfinished and followed by SIGINT (see line 1766, pid 541)

Also, have you tried cfagent with -d set to various levels?


Yes, the -d2 output was appended to my original message, I'll re-paste
here for completeness:
----
HandleFunctionObject(ExecResult(/bin/sh -c "/bin/cat /proc/loadavg | /bin/awk 
'{print $1}' | tr -d '\n' "))
IsBuiltinFunction(ExecResult(/bin/sh -c "/bin/cat /proc/loadavg | /bin/awk '{print 
$1}' | tr -d '\n' "))
IsBuiltinFunction: ExecResult(/bin/sh -c "/bin/cat /proc/loadavg | /bin/awk '{print 
$1}' | tr -d '\n' ")
HandleFunction: ExecResult(/bin/sh -c "/bin/cat /proc/loadavg | /bin/awk '{print 
$1}' | tr -d '\n' ")
FunctionStringToCode(ExecResult)
Appending [/bin/sh -c /bin/cat /proc/loadavg | /bin/awk '{print $1}' | tr -d 
'\n' ]
ExpandVarstring(/bin/sh -c /bin/cat /proc/loadavg | /bin/awk '{print $1}' | tr 
-d '\n' )
ARG[0] /bin/sh -c /bin/cat /proc/loadavg | /bin/awk '{print $1}' | tr -d '\n' cfpopen(/bin/sh -c /bin/cat /proc/loadavg | /bin/awk '{print $1}' | tr -d '\n' )
cfengine:: Time out
----

This looks correct (note the ARG[0]), so that is why I think the bug is in
cfpopen().  Again, it may be that my approach is wrong, and/or 2.1.17 is now
preventing me from taking advantage of a previous bug that I had come to
rely on.

Thanks!

-n

--
-------------------------------------------
nathan hruby <address@hidden>
uga enterprise information technology services
production systems support
-------------------------------------------




reply via email to

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