[augeas-devel] Allow sudoers to handle escaped characters in commands

David Lutterkort lutter at redhat.com
Thu Sep 17 19:13:24 UTC 2009


On Thu, 2009-09-17 at 15:28 +1000, Matthew Palmer wrote:
> I just came across a sudoers file in the wild that had an escaped equals in
> it (well, it didn't originally, but sudoers(5) says it should, so now it
> does) and sudoers.aug didn't handle that case.  After applying the attached
> patch (with test case mods, what's more) it now does.  Application
> appreciated.

Cool. Thanks for sending hte patch. Committed.

> On a related note, I'd *love* to know why I need to use \\\\ (four whole
> backslashes) to get the effect of a single backslash in my regexes. 
> Shouldn't \\ be enough?

My keyboard has three backslash keys, so I just had to find a way to use
all of them ;)

The reason is that I wanted to make it easy to embed control characters
in regexps, so that /[\n\t]/ would match a newline or a tab. Since the
regexp syntax follows POSIX very closely, and regex(7) explains that '\'
+ any character matches exactly that character, I need to make a pass
over the regex to replace \n with a newline and \t with a tab before
feeding the regex to the regex matcher.

That means there are two passes made over each regex that strip '\': one
by the Augeas lexer to resolve control characters, and one by the regex
matcher. To wind up with a single backslash in the internal
representation of the matcher, the regex compiler needs to get a '\\',
and the Augeas lexer needs to get a '\\\\', since both replace '\\' ->
'\'

David





More information about the augeas-devel mailing list