Commit Graph

28 Commits

Author SHA1 Message Date
Todd C. Miller
f352ef5d67 Move parser prototypes / externs from sudoers.h to parse.h or toke.h. 2023-05-09 14:01:41 -06:00
Todd C. Miller
28ecbe4d51 Warn about ignored files in sudoers.d in visudo. 2023-03-20 18:29:33 -06:00
Todd C. Miller
738387aa4d Split push_include() into push_include() and push_includedir().
This moves the "isdir" function argument to the internal version.
2023-03-20 13:01:02 -06:00
Todd C. Miller
304726a215 Move gcc-style __attribute__ macros to config.h.in
Renamed __malloc -> sudo_malloclike, __printflike -> sudo_printflike,
__printf0like -> sudo_printf0like.
Add sudo_noreturn instead of __attribute__((__noreturn__)).
We do not use stdnoreturn.h since it has been deprecated in C23
in favor of the [[noreturn]] attribute.
2022-09-07 07:48:31 -06:00
Todd C. Miller
7c17f84a35 Add helper function to compile a regex that supports (?i). 2022-02-11 12:01:31 -07:00
Todd C. Miller
86d2173937 Add support for matching command and args using regular expressions.
Either the command, its arguments or both may be (separate)
regular expressions.
2022-02-10 18:26:24 -07:00
Todd C. Miller
04de04f544 The lexer now sets an error string before returning ERROR.
The parser will use that when reporting on an ERROR state.  This
prevents the lexer from reporting errors about tokens that are not
actually consumed by the parser and we don't have to worry about
both the lexer and the parser reporting errors.  It also means we
only get one error per sudoers line.
2021-02-08 13:43:49 -07:00
Todd C. Miller
63a63680b6 Push lexer leak tracking down into check_fill.c.
This lets us track things correctly when buffers are realloc()d.
Rewrote fill() and append() to be more readable.
2021-02-03 12:57:04 -07:00
Todd C. Miller
95fb8eb727 Add sudoerserrorf(), a printf-style yyerror() function.
Use this to display a better error message when using a reserved
work in an alias definition.
2020-11-14 06:17:41 -07:00
Todd C. Miller
91cc68d7fd Keep track of the position of the current token for error messages. 2020-08-07 14:13:25 -06:00
Todd C. Miller
99f43f8a00 Store the current line in our own buffer for better error messages. 2020-08-06 21:16:35 -06:00
Todd C. Miller
741c6f274e 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.
2020-05-20 13:10:53 -06:00
Todd C. Miller
1e1ef61902 Add SPDX-License-Identifier to files. 2019-04-29 07:21:51 -06:00
Todd C. Miller
48fba3c2cc update my email to Todd.Miller@sudo.ws 2017-12-03 17:53:40 -07:00
Todd C. Miller
5725acd1c4 In fill_args(), replace loop that increments arg_size() with
a simple add and mask.  Should prevent a false positive from
Coverity CID 104094.
2016-05-04 16:59:04 -06:00
Todd C. Miller
604d350344 Use size_t for length parameters in the fill functions used by the
lexer.
2015-11-22 09:22:38 -07:00
Todd C. Miller
05a01d4c5d Avoid using a leading underbar in defines as they are reserved in
ISO C.
2015-05-21 11:13:20 -06:00
Todd C. Miller
d6282d154a Update copyright years. 2013-04-24 09:35:02 -04:00
Todd C. Miller
a803b4d2ec Change multiple inclusion guards to be _SUDOERS_FOO_H 2013-03-25 11:17:46 -04:00
Todd C. Miller
5276ab3a5f Set yacc prefix to "sudoers" to avoid conflicts other yacc parsers. 2012-09-14 16:19:25 -04:00
Todd C. Miller
0c8c3c0cd8 Avoid printing the >>> parse error <<< message for testsudoers
when the -t flag is specified.
2012-08-23 11:28:44 -04:00
Todd C. Miller
2c84bd4d08 Log warning() at SUDO_DEBUG_WARN not SUDO_DEBUG_ERROR.
Log the function, file and line number in the debug log for warning()
and error().
2012-04-05 12:37:15 -04:00
Todd C. Miller
21a2f95821 Use stdbool.h instead of rolling our own TRUE/FALSE macros. 2011-12-02 11:27:33 -05:00
Todd C. Miller
839919566e Add debug_decl/debug_return (almost) everywhere.
Remove old sudo_debug() and convert users to sudo_debug_printf().
2011-10-22 14:40:21 -04:00
Todd C. Miller
edfb5cd7a2 Move LEXTRACE macro to toke.h so we can use it in yyerror(). 2011-03-21 12:39:06 -04:00
Todd C. Miller
e63849afb0 constify 2011-01-08 19:54:30 -05:00
Todd C. Miller
4cc6322b48 Move fill macro to toke.h 2011-01-08 19:34:31 -05:00
Todd C. Miller
400b6ffe20 Split tokenizer utility functions out into toke_util.c 2011-01-08 15:42:39 -05:00