[augeas-devel] Modifying a comma separated list in the postfix main.cf file - possible?

Dominic Cleal dcleal at redhat.com
Mon Nov 26 09:37:46 UTC 2012


Hi Graham,

On 24/11/12 15:06, Graham Leggett wrote:
> Hi all,
> 
> I have a file /etc/postfix/main.cf that contains the following:
> 
> virtual_alias_maps = A, B, C
> 
> I want to perform the following three steps:
> 
> - Add a value D to the end, producing the following:
> 
> virtual_alias_maps = A, B, C, D
> 
> - Add a value E to the end, producing the following:
> 
> virtual_alias_maps = A, B, C, D, E
> 
> - Remove a value D from the comma separated list, producing the following. Notice how we don't know what position D is in the list:
> 
> virtual_alias_maps = A, B, C, E
> 
> Can this be done with the existing augeas postfix lens today? Does augeas have functionality to manipulate comma separated values, or is the only solution to this problem physically modifying the lens?

It's a problem with the lens - it's too simplistic.  There's another
report of it here:
https://fedorahosted.org/augeas/ticket/265

The only way to get round it is to take the value of the node from the
Augeas API, parse it yourself and set the value you want.  Unless the
lens breaks apart a string into nodes, that's all you can do.  There are
no helpers in the Augeas API for this, since it should be done in the lens.

As per the bug, there's a good argument for splitting lists up in the
lens, despite it being a backwards-incompatible change.  I expect we'd
welcome a patch to the lens to fix this.

Regards,

-- 
Dominic Cleal
Red Hat Engineering




More information about the augeas-devel mailing list