hercules-team / augeas

A configuration editing tool and API
http://augeas.net/
GNU Lesser General Public License v2.1
486 stars 199 forks source link

String stored as reference in /augeas/context #302

Open raphink opened 9 years ago

raphink commented 9 years ago

Setting /augeas/context creates new entries:

$ augtool -Ast "IniFile.lns_loose incl /etc/puppetlabs/puppetdb/conf.d/database.ini"
augtool> match /files//database.ini/section[.="database"]
/files/etc/puppetlabs/puppetdb/conf.d/database.ini/section = database
augtool> set /augeas/context /files//database.ini/section[.="database"]
augtool> match .
/files/etc/puppetlabs/puppetdb/conf.d/database.ini/section[4] = (none)
augtool> match .
/files/etc/puppetlabs/puppetdb/conf.d/database.ini/section[6] = (none)
augtool> match .
/files/etc/puppetlabs/puppetdb/conf.d/database.ini/section[8] = (none)
augtool> get /augeas/context
/augeas/context = /files//database.ini/section[.=database]

The quotes are missing in the expression, which causes the bug.

This bug doesn't exist with defvar for example:

augtool> defvar section /files//database.ini/section[.="database"]
augtool> get /augeas/variables/section
/augeas/variables/section = /files//database.ini/section[.="database"]
raphink commented 9 years ago

This is not a problem with Augeas per-se, but with the way Augtool expands strings. defvar works, because it deals with nodesets, but /augeas/context must store a string verbatim. Therefore, quoting the string works:

augtool> set /augeas/context /files/etc/passwd/*[uid="0"]
augtool> get /augeas/context
error: Invalid path expression
error: type error
/files/etc/passwd/*[uid=0]|=|
augtool> set /augeas/context '/files/etc/passwd/*[uid="0"]'
augtool> get /augeas/context
/augeas/context = /files/etc/passwd/*[uid="0"]
augtool> match .
/files/etc/passwd/root = (none)

Should this be fixed somehow?