"set *[self::directive='F..." />

augeas set value with whitespace failed

1.6k views Asked by At


I've problem with augeas when I set value (augeas-0.10.0 is used with puppet-2.7.11) with whitespace, ex.


...
changes => "set *[self::directive='FastCgiExternalServer']/arg '/usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization'", ...

After saving I've got this error msg:


/augeas/files/etc/apache2/mods-available/fastcgi.conf/error = "put_failed"
/augeas/files/etc/apache2/mods-available/fastcgi.conf/error/path = "/files/etc/apache2/mods-available/fastcgi.conf/IfModule/directive"
/augeas/files/etc/apache2/mods-available/fastcgi.conf/error/lens = "/usr/share/augeas/lenses/dist/httpd.aug:76.18-77.49:"
/augeas/files/etc/apache2/mods-available/fastcgi.conf/error/message = "Failed to match \n    ({ /arg/ = /([^\001-\004\t\n \"']|\\\\\"|\\\\')+|\"([^\001-\004\n\"\\]|\\\\[^\001-\004\n])\"|'([^\001-\004\n'\\]|\\\\[^\001-\004\n])'/ }({ /arg/ = /([^\001-\004\t\n \"']|\\\\\"|\\\\')+|\"([^\001-\004\n\"\\]|\\\\[^\001-\004\n])\"|'([^\001-\004\n'\\]|\\\\[^\001-\004\n])'/ })*)?\n  with tree\n    { \"arg\" = \"/usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization\" }"
I tried diffrent ways to escape this value, but every attempt failed with the same error. What I'm doing wrong ? Thanks for any helpfull answers !

2

There are 2 answers

4
raphink On

You have two issues:

  • your changes potentially create an arg node without a parent directive node, which is not valid with the Httpd.lns lens;
  • you need to force quotes around the value because it contains spaces.

So (using augtool):

# Make sure the directive exists
set directive[. = 'FastCgiExternalServer'] FastCgiExternalServer
# Set the argument
set directive[. = 'FastCgiExternalServer']/arg '"/usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization"'

should work better.

0
fgiraldeau On

The "arg" is actually a list. Each argument should be enumerated:

defvar conf /files/etc/apache2/sites-available/foo
clear $conf/VirtualHost
set $conf/VirtualHost/arg "172.16.0.1:80"
set $conf/VirtualHost/directive "FastCgiExternalServer"
set $conf/VirtualHost/*[self::directive='FastCgiExternalServer']/arg[0] "/usr/lib/cgi-bin/php5-fcgi"
set $conf/VirtualHost/*[self::directive='FastCgiExternalServer']/arg[1] "-socket"
set $conf/VirtualHost/*[self::directive='FastCgiExternalServer']/arg[2] "/var/run/php5-fpm.sock"
set $conf/VirtualHost/*[self::directive='FastCgiExternalServer']/arg[3] "-pass-header"
set $conf/VirtualHost/*[self::directive='FastCgiExternalServer']/arg[4] "Authorization"

It produces the following file:

<VirtualHost 172.16.0.1:80>
FastCgiExternalServer -socket /var/run/php5-fpm.sock -pass-header Authorization
</VirtualHost>