Re: Bug in ${const.dollar}( ... )

Jean-Noël Rivasseau <[email protected]> Fri, 11 Dec 2009 08:16:08 -0800
Newsgroups gmane.comp.sysutils.cfengine.bugs
Message-ID <[email protected]>
--===============0398725623==
Content-Type: multipart/alternative; boundary=00032555b73ed66fa3047a763dc2

--00032555b73ed66fa3047a763dc2
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Mark,

this is indeed a bug. Read carefully my example and try it. It fails
because of the ${const.dollar}(cat /etc/hosts), eg
only because ${const.dollar} is followed by  ( ... ). In your example
you don't have that, $(const.dollar)y works fine
because it does not reproduce the bug at all. With my example,
cf-engine will **refuse** to run the command and launch the
shell.

Please try with my example and see for yourself.


On Thu, Dec 10, 2009 at 11:01 PM, Mark Burgess <[email protected]>wrot=
e:

>
> This is not a bug in cfengine, it is the shell that is turning the $ into
> nothing.
> Cfengine interprets the string correctly and passes it to the shell as th=
is
> shows.
>
>  "MyClass" expression =3D  "MyClass" expression =3D> returnszero("/bin/ec=
ho x
> $(const.dollar)y", "useshell");
>
> x
>
> > returnszero("/bin/echo x $(const.dollar)y", "noshell");
>
> x $y
>
>
> Jean-No=C3=ABl Rivasseau wrote:
> > Hello, I discussed this issue in the help ML before but it really
> > appears like it is a bug.
> >
> > Basically, cf-engine chokes on ${const.dollar}( ... ) in command string=
s
> > passed to returnszero function. However $() in a shell (Bash) can be
> > very useful as it triggers a subshell. There is a bug in the parser
> > somewhere as this example demonstrates:
> >
> > body common control
> > {
> >     bundlesequence =3D> {"configurePhase"};
> > }
> >
> > bundle agent configurePhase
> > {
> >         classes:
> >                 "MyClass" expression =3D> returnszero("/bin/echo
> > ${const.dollar}(cat /etc/hosts)", "useshell");
> >                 "MyClass2" expression =3D> returnszero("/bin/echo `cat
> > /etc/hosts`", "useshell");
> >         reports:
> >         MyClass::
> >                 "Hi World";
> >         MyClass2::
> >                 "Hello World";
> > }
> >
> >
> > MyClass2 will correctly be defined, but not MyClass as cf-engine will
> > refuse to run the first command - the parser gets confused and attempts
> > to solve 'cat /etc/hosts' as a variable it seems. I checked this on
> > today's SVN and the problem is still present. Please correct it :)
> >
> > Cheers
> > Jean-Noel
> >
> >
> > -----------------------------------------------------------------------=
-
> >
> > _______________________________________________
> > Bug-cfengine mailing list
> > [email protected]
> > https://cfengine.org/mailman/listinfo/bug-cfengine
>

--00032555b73ed66fa3047a763dc2
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<pre>Mark,<br><br>this is indeed a bug. Read carefully my example and try i=
t. It fails because of the ${const.dollar}(cat /etc/hosts), eg<br>only beca=
use ${const.dollar} is followed by  ( ... ). In your example you don&#39;t =
have that, $(const.dollar)y works fine<br>
because it does not reproduce the bug at all. With my example, cf-engine wi=
ll <b class=3D"moz-txt-star"><span class=3D"moz-txt-tag">*</span>refuse<spa=
n class=3D"moz-txt-tag">*</span></b> to run the command and launch the<br>s=
hell.<br>
<br>Please try with my example and see for yourself.<br></pre><br><div clas=
s=3D"gmail_quote">On Thu, Dec 10, 2009 at 11:01 PM, Mark Burgess <span dir=
=3D"ltr">&lt;<a href=3D"mailto:[email protected]">[email protected].=
no</a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, =
204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
This is not a bug in cfengine, it is the shell that is turning the $ into n=
othing.<br>
Cfengine interprets the string correctly and passes it to the shell as this=
 shows.<br>
<br>
 =C2=A0&quot;MyClass&quot; expression =3D =C2=A0&quot;MyClass&quot; express=
ion =3D&gt; returnszero(&quot;/bin/echo x<br>
$(const.dollar)y&quot;, &quot;useshell&quot;);<br>
<br>
x<br>
<br>
&gt; returnszero(&quot;/bin/echo x $(const.dollar)y&quot;, &quot;noshell&qu=
ot;);<br>
<br>
x $y<br>
<div><div></div><div class=3D"h5"><br>
<br>
Jean-No=C3=ABl Rivasseau wrote:<br>
&gt; Hello, I discussed this issue in the help ML before but it really<br>
&gt; appears like it is a bug.<br>
&gt;<br>
&gt; Basically, cf-engine chokes on ${const.dollar}( ... ) in command strin=
gs<br>
&gt; passed to returnszero function. However $() in a shell (Bash) can be<b=
r>
&gt; very useful as it triggers a subshell. There is a bug in the parser<br=
>
&gt; somewhere as this example demonstrates:<br>
&gt;<br>
&gt; body common control<br>
&gt; {<br>
&gt; =C2=A0 =C2=A0 bundlesequence =3D&gt; {&quot;configurePhase&quot;};<br>
&gt; }<br>
&gt;<br>
&gt; bundle agent configurePhase<br>
&gt; {<br>
&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 classes:<br>
&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &quot;MyClass&=
quot; expression =3D&gt; returnszero(&quot;/bin/echo<br>
&gt; ${const.dollar}(cat /etc/hosts)&quot;, &quot;useshell&quot;);<br>
&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &quot;MyClass2=
&quot; expression =3D&gt; returnszero(&quot;/bin/echo `cat<br>
&gt; /etc/hosts`&quot;, &quot;useshell&quot;);<br>
&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 reports:<br>
&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 MyClass::<br>
&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &quot;Hi World=
&quot;;<br>
&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 MyClass2::<br>
&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &quot;Hello Wo=
rld&quot;;<br>
&gt; }<br>
&gt;<br>
&gt;<br>
&gt; MyClass2 will correctly be defined, but not MyClass as cf-engine will<=
br>
&gt; refuse to run the first command - the parser gets confused and attempt=
s<br>
&gt; to solve &#39;cat /etc/hosts&#39; as a variable it seems. I checked th=
is on<br>
&gt; today&#39;s SVN and the problem is still present. Please correct it :)=
<br>
&gt;<br>
&gt; Cheers<br>
&gt; Jean-Noel<br>
&gt;<br>
&gt;<br>
</div></div>&gt; ----------------------------------------------------------=
--------------<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Bug-cfengine mailing list<br>
&gt; <a href=3D"mailto:[email protected]">[email protected]=
</a><br>
&gt; <a href=3D"https://cfengine.org/mailman/listinfo/bug-cfengine" target=
=3D"_blank">https://cfengine.org/mailman/listinfo/bug-cfengine</a><br>
</blockquote></div>

--00032555b73ed66fa3047a763dc2--

--===============0398725623==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Bug-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/bug-cfengine

--===============0398725623==--