Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-1740

Augeas provider doesn't handle escapes properly



    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Cannot Reproduce
    • Affects Version/s: PUP 3.4.2
    • Fix Version/s: None
    • Component/s: Types and Providers
    • Labels:
    • Environment:

      Debian/Linux wheezy (stable), using puppet packages from apt.puppetlabs.com

    • Template:


      Augeas provider cannot properly pass escapes to libaugeas as some lenses need it. For example:

      # cat test.pp
      node 'puppet' {
         augeas { "/tmp/mytest.txt":
              lens    => 'Shellvars.lns',
              incl    => '/tmp/mytest.txt',
              changes => [ "set VAR1[last() + 1] '\$VAR1 value4'", ],

      Relevant output with puppet apply -d test.pp :

      Debug: Augeas[/tmp/mytest.txt](provider=augeas): sending command 'set' with params ["/files/tmp/mytest.txt/VAR1[last() + 1]", "$VAR1 value4"]

      The single quotes are not present at all.
      Here are more examples and the output :

      changes => [ "set VAR1[last() + 1] \"\$VAR1 value4\"", ],
      Debug: Augeas[/tmp/mytest.txt](provider=augeas): sending command 'set' with params ["/files/tmp/mytest.txt/VAR1[last() + 1]", "$VAR1 value4"]
      ## still no sign of the escaped double quotes
      changes => [ "set VAR1[last() + 1] \\\"\$VAR1 value4\\\"", ],
      Debug: Augeas[/tmp/mytest.txt](provider=augeas): sending command 'set' with params ["/files/tmp/mytest.txt/VAR1[last() + 1]", "\\\"$VAR1"]
      ## shouldn't the last param be "\"$VAR1 value4\"" ?

      Testing it with augtool using a lens that actually require escaped double-quotes as part of the value to be set:

      # cd /tmp;
      # echo 'export VAR1="$VAR1 value1"' >> mytest.txt
      # echo 'export VAR1="$VAR1 value2"' >> mytest.txt
      # augtool --noautoload
      augtool> set /augeas/load/Shellvars/lens "Shellvars.lns"
      augtool> set /augeas/load/Shellvars/incl "/tmp/mytest.txt"
      augtool> load
      augtool> print /files/tmp/mytest.txt
      /files/tmp/mytest.txt/VAR1[1] = "\"$VAR1 value1\""
      /files/tmp/mytest.txt/VAR1[2] = "\"$VAR1 value2\""
      augtool> set /files/tmp/mytest.txt/VAR1[last() + 1] "\"$VAR1 value3\""
      augtool> print //augeas//errors
      augtool> save
      Saved 1 file(s)

      If I do the same, but without the escaping the double quote inside the value:

      augtool> set /files/tmp/mytest.txt/VAR1[last() + 1] "$VAR1 value4"
      augtool> save
      error: Failed to execute command
      saving failed (run 'print /augeas//error' for details)
      augtool> print /augeas//error
      /augeas/files/tmp/mytest.txt/error = "put_failed"
      /augeas/files/tmp/mytest.txt/error/path = "/files/tmp/mytest.txt"
      /augeas/files/tmp/mytest.txt/error/lens = "/usr/share/augeas/lenses/dist/shellvars.aug:138.12-.89:"
      /augeas/files/tmp/mytest.txt/error/message = "Malformed child node 'VAR1'"

      Which means the lens actually require that escaped double quote otherwise it won't accept any value that contains a space (even if it is escaped with backslash). Depending on the point of view, this could be a bug in the lens, but doesn't change the fact that augeas provider in puppet removes too much from the passed string from the manifest.




            kylo Kylo Ginsberg
            tcdiem Theo Cabrerizo Diem
            QA Contact:
            Narmadha Perumal Narmadha Perumal
            0 Vote for this issue
            2 Start watching this issue



                Zendesk Support