On Sat, 18 Aug 2007, Thomas Lange wrote:

On Sat, 18 Aug 2007 18:52:20 +0200 (CEST), Per Foreby <[EMAIL PROTECTED]> said:

   > Is it possible to use $ROOTCMD in cfengine scripts?
   > I update a configuration file for tex-common, and want to run
   > update-texmf after that. It must work both for install and softupdate.

   >    shellcommands:
   >      any::
   >        ${ROOTCMD} /usr/sbin/update-texmf

   > The error from cfengine says that the command must be an absolute path,
IMO this error is because chroot is not used as /sbin/chroot but
only as chroot in $ROOTCMD. You may define $ROOTCMD in a class/*.var file.

But i got the error message when doing a softupdate, and then $ROOTCMD is set to nothing, so it is not the missing path for chroot that is the problem.

I did some testing, and the problem seems to be ROOTCMD= (empty) in /usr/sbin/fai. I tried to come up with some commands that just executed its arguments without the need for quoting (like /bin/sh -c). Writing such a "shell" is of cource easy. I would know since I have written a number of them for restricted environments, but now I tried to find something out-of-the-box. This worked:

  ROOTCMD="/usr/bin/nice -n 0"

But then I found an even simpler soulution:

  ROOTCMD=" "

This works togeter with "noabspath=true"

This is what my test script looked like:

  control:
    actionsequence = ( shellcommands )

  shellcommands:
    any::
      "${ROOTCMD} /usr/bin/touch /root/tt" noabspath=true


Setting ROOTCMD to " " doesn't affect shell scripts, so I would suggest a change in /usr/sbin/fai:


    ROOTCMD="/usr/sbin/chroot $FAI_ROOT"
    # no chroot needed
    [ "$FAI_ROOT" = '/' ] && ROOTCMD=" "

Or, to be safe if chroot would move to another directory:

    ROOTCMD="`which chroot` $FAI_ROOT"
    # no chroot needed
    [ "$FAI_ROOT" = '/' ] && ROOTCMD=" "

For the time beeing I will put this in a *.var script.

/Per


Antwort per Email an