[augeas-devel] Having trouble differentiating quoted vs unquoted string

Raphaël Pinson raphink at gmail.com
Wed Aug 12 08:26:21 UTC 2009


Hi Matthew,

I think I had found a solution for that in sudoers. Have a look in sudoers.aug :


(* Variable: sep_cont *)
let sep_cont = del /([ \t]+|[ \t]*\\\\\n[ \t]*)/ " "

[...]

(* Variable: sep_dquote *)
let sep_dquote   = Util.del_str "\""

[...]

(* Variable: sto_to_spc_no_dquote *)
let sto_to_spc_no_dquote = store /[^", \t\n\\\\]+/ (* " relax emacs *)

[...]

let parameter_lists_value        = [ label "var" . sto_to_spc_no_dquote ]
let parameter_lists_value_dquote = [ label "var"
                                     . del /"?/ "" . sto_to_spc_no_dquote
                                     . del /"?/ "" ]

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



So, parameter_lists_values is either :
   * a string doesn't contain any quotes or spaces, optionally
surrounded by quotes (and by default surrounded by quotes) =>
parameter_lists_value_dquote ;
   * a list of parameters that don't contain any quotes or spaces
(parameter_lists_value), separated by spaces or newlines (sep_cont),
and the whole list is surrounded by mandatory quotes.


It might not correspond to your exact need, but it's close enough that
I believe you can adapt it to your problem.



Raphaël




On Wed, Aug 12, 2009 at 9:46 AM, Matthew Palmer<matt at anchor.net.au> wrote:
> Hi,
>
> I'm writing a lens for SSH authorized_keys files, and I've hit a fairly
> nasty snag in options parsing.  For those not aware, an options line in SSH
> consists of a comma-separated list of key=value pairs (with some exceptions
> that are irrelevant to the current discussion).  Because whitespace is the
> separator between the options and the key type, if you want whitespace or
> commas in your option value you need to quote it.  So you might have the
> following in your authorized_keys file:
>
> command="/usr/bin/foo fromble",something=somethingelse
>
> Note that the quotes are valid in any event (so something="somethingelse" is
> also valid), which makes life trickier...
>
> I've reduced my problem to something quite trivial; writing a lens that will
> successfully parse/write the following should solve my problem:
>
> "quoted line"
> "unecessarily_quoted_line"
> unquotedline
>
> Unfortunately, whatever I try I get an "overlapping lens in tree union.put"
> error, which I understand the meaning of -- when trying to write a value in
> the tree back to the file, augeas can't decide whether to use the quoted or
> unquoted version.
>
> My problem is that I can't work out how to work around it.  Does anyone have
> any suggestions?
>
> - Matt
>
> _______________________________________________
> augeas-devel mailing list
> augeas-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/augeas-devel
>




More information about the augeas-devel mailing list