[augeas-devel] Re: [Augeas] #48: sudoers lens does not handle multiline strings

Augeas trac at fedorahosted.org
Mon Mar 23 07:46:10 UTC 2009


#48: sudoers lens does not handle multiline strings
------------------------+---------------------------------------------------
  Reporter:  fsweetser  |       Owner:  raphink 
      Type:  defect     |      Status:  assigned
  Priority:  minor      |   Milestone:  next    
 Component:  Augeas     |     Version:  0.4.1   
Resolution:             |    Keywords:  sudoers 
------------------------+---------------------------------------------------
Comment (by raphink):

 Replying to [comment:5 lutter]:
 > Replying to [comment:3 raphink]:
 > > Here is at least one thing that doesn't work with this patch :[[BR]]
 >
 > I haven't had time to review your patch in detail, but I think the below
 can actually addressed:
 >
 > > Let's say we have an env_keep with only one value put within double
 quotes (which is optional, but possible) :[[BR]]
 > >
 > >
 > > Defaults env_keep = "TEST"[[BR]]
 > >
 > >
 > > which will get mapped as[[BR]]
 > > /files/etc/sudoers/Defaults/env_keep[[BR]]
 > > /files/etc/sudoers/Defaults/env_keep/var[1] = "\"TEST\""[[BR]]
 > >
 > >
 > > If we add a second variable to this env_keep, we will get :[[BR]]
 > > /files/etc/sudoers/Defaults/env_keep[[BR]]
 > > /files/etc/sudoers/Defaults/env_keep/var[1] = "\"TEST\""[[BR]]
 > > /files/etc/sudoers/Defaults/env_keep/var[2] = "TEST2"[[BR]]
 > >
 > > which fails to save because "\"TEST\"" is only an acceptable value if
 you have only one variable. [[BR]]
 >
 > You can write a lens l = l1 | l2, where l1 covers the single-element
 case, and l2 the more-than-one element case; even though 'get' might use
 l1, 'put' can use l2 when a second 'var' node is added.
 >

 This is already what I'm doing :[[BR]]

 {{{
 let parameter_lists_kw           = "env_check" | "env_delete" | "env_keep"
 let parameter_lists_value        = [ label "var" . sto_to_spc_no_dquote ]
 let parameter_lists_value_dquote = [ label "var" . sto_to_spc ]

 let parameter_lists_values = parameter_lists_value_dquote
                            | ( sep_dquote . parameter_lists_value
                                . ( sep_cont . parameter_lists_value )+
                                . sep_dquote )

 let parameter_lists_sep    = sep_cont_opt
                              . ( [ del "+" "+" . label "append" ]
                                | [ del "-" "-" . label "remove" ] )?
                              . del "=" "=" . sep_cont_opt

 let parameter_lists        = [ ( parameter_negate . key parameter_lists_kw
 )
                              | ( key parameter_lists_kw
                                . parameter_lists_sep
                                . parameter_lists_values ) ]
 }}}

 You can see in parameter_lists_values that it's a union of two lenses: one
 that deals with a single value, and the other which deals with more than
 one. The problem is with the single value one, because I parse the double
 quotes on each side of the value as being part of the value itself, since
 it is not mandatory but has to be symmetric (there can't be a double quote
 only on one side of the value).


 > In pseudo-notation that hopefully gets the point across, it would look
 something like
 > {{{
 >   let var = label "var" . store one_env_var_re
 >   let l1 = [ del /"?/ "" . var . del /"?/ "" ]


 This is my second option in comment #3. The possible issue with it is that
 Augeas won't find it a problem if it finds a double quote only on one side
 of the value, like '\"TEST' or 'TEST\"', which is syntactically wrong.

-- 
Ticket URL: <https://fedorahosted.org/augeas/ticket/48#comment:7>
Augeas <http://augeas.net/>
a configuration API




More information about the augeas-devel mailing list