[augeas-devel] Extra spaces in lens output

Joe Nall joe at nall.com
Fri Mar 9 14:41:31 UTC 2012


On Mar 9, 2012, at 7:46 AM, Raphaël Pinson wrote:

> Actually, I don't think it's really useful to have a specific lens for
> this file.
> 
> Unless you really want a strict syntax check for it. We could very
> well add /etc/selinux/config to the Simplevars lens, which is made for
> this kind of files.
> 
> Let me know if this would be good for you.

That would be fine, the extra validation doesn't really merit a lens.
I'm still curious about controlling spaces emitted around the value.
Where are things like Sep.space_equals found in the filesystem?

joe

> 
> 
> Raphaël
> 
> 
> 
> On Fri, Mar 9, 2012 at 7:16 AM, Raphaël Pinson <raphink at gmail.com> wrote:
>> Hi,
>> 
>> On Fri, Mar 9, 2012 at 4:28 AM, Joe Nall <joe at nall.com> wrote:
>>> I've written a short lens for /etc/selinux/config:
>>> 
>>> module SelinuxConfig =
>>>  autoload xfm
>>> 
>>> let equals = del /[ \t]*=[ \t]*/ "="
>>> 
>>> let state = Build.key_value_line "SELINUX" equals (store /(enforcing|permissive|disabled)/)
>>> let type  = Build.key_value_line "SELINUXTYPE" equals (store Rx.word)
>>> 
>>> let lns = (Util.empty|Util.comment|state|type)*
>>> let filter = incl "/etc/selinux/config"
>>> let xfm = transform lns filter
>> 
>> 
>> A few comments first:
>>  * It is strongly recommended to write a unit test file (see the
>> tests/ directory under /usr/share/augeas/lenses/dist) to avoid
>> regressions in your lens ;
>>  * You coud now use Sep.space_equal to declare equals.
>> 
>> 
>>> 
>>> When I set SELINUX to enforcing in augtool
>>> augtool> set /files/etc/selinux/config/SELINUX enforcing
>>> 
>>> I get this
>>> SELINUX = enforcing
>>>       ^ ^         ^ extra spaces
>>> when I would prefer
>>> SELINUX=enforcing
>>> 
>>> Is there a way to control when spaces are emitted?
>> 
>> 
>> My best bet here is that there is already a SELINUX entry in your
>> file, and you're merely modifying it, not creating it. When Augeas
>> modifies existing entries, it keeps the existing syntax (spaces,
>> indentations, etc.) the way it was. If you were to create a new
>> SELINUX entry, then Augeas would use the default value for equals,
>> which doesn't include spaces.
>> 
>> 
>> Raphaël





More information about the augeas-devel mailing list