Hi David,

 

this is how I reproduce the error:

 

[root ~]# augtool --version

augtool 1.4.0 <http://augeas.net/>

Copyright (C) 2007-2011 David Lutterkort

License LGPLv2+: GNU LGPL version 2.1 or later

                 <http://www.gnu.org/licenses/lgpl-2.1.html>

This is free software: you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law.

 

Written by David Lutterkort

 

[root ~]# touch /etc/dcache/layouts/empty.conf

[root ~]# augtool -A -t 'DCacheLayout_old incl "/etc/dcache/layouts/*.conf"'

augtool> print /files/etc/dcache/layouts/empty.conf

/files/etc/dcache/layouts/empty.conf

augtool> set /files/etc/dcache/layouts/empty.conf/properties/word spam

augtool> save

error: Failed to execute command

saving failed (run 'errors' for details)

augtool> errors

Error in /etc/dcache/layouts/empty.conf (put_failed)

  Failed to match

        { /properties/ }?

(    { /#comment/ = /[^\001-\004\t\n\r ][^\001-\004\n]*[^\001-\004\t\n\r 
]|[^\001-\004\t\n\r ]/ }

      | { }

      | { /domain/ = /[$.0-9A-Z_a-{}-]+/ })*

  with tree

    {  } { "properties" }

  Lens: /usr/share/augeas/lenses/dcachelayout_old.aug:30.12-.46:

 

 

Creating the file through augtool works fine:

 

augtool> rm /files/etc/dcache/layouts/empty.conf

rm : /files/etc/dcache/layouts/empty.conf 4

augtool> save

Saved 1 file(s)

augtool> set /files/etc/dcache/layouts/empty.conf/properties/word spam

augtool> save

Saved 1 file(s)

 

 

 

Ciao,

Xavier.

 

From: David Lutterkort [mailto:lut...@watzmann.net] 
Sent: Wednesday, February 24, 2016 12:57 AM
To: Mol, Xavier (SCC)
Cc: Raphaël Pinson; augeas-devel@redhat.com
Subject: Re: [augeas-devel] Why does Augeas fail to handle empty files?

 

On Tue, Feb 23, 2016 at 12:49 AM, Mol, Xavier (SCC) <xavier....@kit.edu> wrote:

Hello David,

 

attached you can find my custom lens that I was talking about.

 

I don't know how to simulate my test cases with this lens through Augeas unit 
tests, I'm sorry. I'm afraid, that this problem will not be reproducable with 
them.

 

This module contains two different definitions for the final lens 'lns':

 

- let lns = properties? . ( filler | domain )*

Using this definition, the lens fails to update empty files. It can be used to 
create new files and update existing non-empty files just fine. To reproduce 
the error (after you have imported the lens), create an empty file before 
running augtool (e.g. with 'touch /etc/dcache/layouts/empty.conf', which will 
be autoloaded, or any other location – you know how to do that ;-) ).

 

This seemed to work for me .. creating the empty file and running augtool, I 
did not get any errors. Even when I do 'clear /etc/dcache/layouts/empty.conf' 
and then save, things seem to work without errors.

Could you also send me the commands I need to perform on augtool to get an 
error (or the undesired behaviuor) ?

 

 

- let lns = ( properties? . ( filler | domain )* )?

This definition can handle existing empty files, but augparse generates a huge 
error that I won't paste here ("illegal optional expression: /…/ matches the 
empty word").

 

The complaint here is that when you have a construct 'lns ?' and lns matches 
the empty string, Augeas doesn't know whether it should treat that as "the 
whole construct 'lns ?' did not match" or "we did match an instance of lns, it 
just happened to be the empty string". The reason that is important is that in 
the first case we completely ignore lns, while in the second we do whatever lns 
says. For example, think of something like '[ label "foo"]?' ... if the input 
is an empty string, should we create that node or not ?

David

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
augeas-devel mailing list
augeas-devel@redhat.com
https://www.redhat.com/mailman/listinfo/augeas-devel

Reply via email to