[sudo-users] Sudoers EBNF Spec

Jon three18ti at gmail.com
Fri Oct 18 04:37:17 MDT 2013


So I spent some time digging through visudo.c.  Admittedly, I am not a C
programmer (my C skills are quite rusty), but I can't for the life of me
figure out the definition of init_parser().  I see there is a prototype
defined, but there is no subroutine definition.  As far as I understand it,
init_parser doesn't come from another library like yyparse does.

yyparse seems to want some sort of grammar definition[1] but from reading
the sudoers.c source it seems to operate on magic.

Where does visudo pull the grammar definition and where is init_parser


If you're (or really anyone else) interested, I've attached my in progress
grammar spec.  I'm starting on my G0 definitions now.

Best Regards,
Jon A

[1]  http://www.slac.stanford.edu/comp/unix/gnu-info/bison_7.html

On Thu, Oct 17, 2013 at 10:35 AM, Jon <three18ti at gmail.com> wrote:

> Hello Tim,
> What about the visudo source...? Just thinking out loud, but it is the
> tool designed to check the syntax of the sudoers file.
> I basically stripped out the markup from the manual then began describing
> the individual atoms (I think there's a typo where user_name on the LHS is
> written as user name don't quote me on that... still trying to get through
> the grammar).  I wrote an iterator [1] to parse the multiline configuration
> descriptions;  I wrapped the method in a moose class with a filename
> attribute. Happy to share examples when I'm back at a keyboard.
> Thanks for your input.
> Best Regards,
> Jon A
> [1] http://www.perlmonks.org/?node_id=1057121
> On Oct 17, 2013 10:17 AM, "Tim Bradshaw" <tfb at tfeb.org> wrote:
>> On 17 Oct 2013, at 12:20, Jon wrote:
>> >
>> > However, it seems like the grammar is incomplete in the manual.  For
>> > instance, it seems like the specification for all of the special
>> variables
>> > and wildcards.
>> >
>> > Is there a full grammar specification posted somewhere?  (Or is that the
>> > full specification?)
>> I'm trying to do something similar.  I think the description probably is
>> incomplete.  However there are lex and yacc files in the source which (I
>> hope!) do definitively describe the grammar. Unfortunately those files are
>> sufficiently entangled with the sources that I decided I wasn't
>> willing/able to construct a standalone parser.
>> --tim
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sudoers_grammar.spec
Type: application/octet-stream
Size: 3351 bytes
Desc: not available
URL: </pipermail/sudo-users/attachments/20131018/f37202bf/attachment.obj>

More information about the sudo-users mailing list