Why are the #include and #includedir directives in sudo prefixed with the pound (#) character

#include was added in 2004. It had to be compatible with what was already there. I don't think include /path/to/file would have been ambiguous, though, but it might have been a little harder to parse, because the parser would have to distinguish include /path/to/file (include directive) from include = foo (allow the user include to run the command foo).

But I think mostly the reason was to look like the C preprocessor, which the manual explicitly cites as inspiration.


As a side note: I often use something like egrep -v '^#|^$' configfile to get the non-default/active configured settings, and this obviously does not work for the sudoers file.

This will work from sudo version 1.9.1 as support for @include and @includedir has been added to make it "less confusing".

Add support for @include and @includedir

These are less confusing than #include and #includedir when the hash character is also the comment character.

This commit also adds real parsing of include directives as opposed to the pure lexer approach used previously. As a result, it is now possible to include files with spaces by either using a double-quoted string or escaping the space characters with a backslash.

Use of #include and #includedir is retained for compatibility with versions prior to 1.9.1.

Tags:

Sudo