Hi,

On Fri, Mar 9, 2012 at 4:28 AM, Joe Nall <[email protected]> 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

_______________________________________________
augeas-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/augeas-devel

Reply via email to