Todd C. Miller
e343e07543
Use #include <foo.h> instead of #include "foo.h" in most cases.
...
We rely on the include path to find many of these headers. It
especially doesn't make sense to use #include "foo.h" for headers
in the top-level include directory.
2023-09-25 10:13:28 -06:00
Todd C. Miller
a38b714667
sudoers plugin: silence most -Wconversion warnings.
2023-07-07 15:07:04 -06:00
Todd C. Miller
9d7c30c5a8
Add struct sudoers_parser_config and pass it to init_parser().
...
This struct contains parser configuration such as the sudoers file
uid/gid/mode and parse flags such as verbose, strict and recovery.
2023-05-08 17:03:31 -06:00
Todd C. Miller
e5d98da014
Move hexchar() from the sudoers plugin to lib/util.
2023-01-03 15:50:42 -07: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
3d55bca8ac
Silence a clang analyzer false positive.
2021-02-08 16:06:08 -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
f30670a42f
Plug a few more parser leaks.
2021-02-01 19:56:52 -07:00
Todd C. Miller
9ed14870c6
Add garbage collection to the sudoers parser to clean up on error.
...
This makes it possible to avoid memory leaks when there is a parse error.
2021-02-01 15:06:20 -07:00
Todd C. Miller
4e11bc0e26
Suppress PVS Studio false positives.
2021-01-06 14:27:09 -07:00
Todd C. Miller
446ae3f507
Include string.h unconditionally and only use strings.h for strn?casecmp()
...
In the pre-POSIX days BSD had strings.h, not string.h.
Now strings.h is only used for non-ANSI string functions.
2020-05-18 07:59:24 -06:00
Todd C. Miller
dd88460800
We no longer need to include headers we don't use for sudo*.h files.
...
Previously we needed to include headers required by the various
sudo*h files. Now those files are more self-sufficient and we
should only include headers needed by code in the various .c files.
2020-05-18 06:47:04 -06:00
Todd C. Miller
486ee2b71f
debug_decl and debug_decl_vars now require a semicolon at the end.
2019-12-22 08:48:16 -07:00
Todd C. Miller
635445d471
Transparently handle the "sudo sudoedit" problem.
...
Some admin are confused about how to give users sudoedit permission
and many users try to run sudoedit via sudo instead of directly.
If the user runs "sudo sudoedit" sudo will now treat it as plain
"sudoedit" after issuing a warning. If the admin has specified a
fully-qualified path for sudoedit in sudoers, sudo will treat it
as just "sudoedit" and match accordingly. In visudo (but not sudo),
a fully-qualified path for sudoedit is now treated as an error.
2019-11-05 15:18:34 -07:00
Todd C. Miller
1e1ef61902
Add SPDX-License-Identifier to files.
2019-04-29 07:21:51 -06:00
Todd C. Miller
6c3d20cb41
Convert PVS-Studio comment to ANSI C.
2018-10-26 08:39:09 -06:00
Todd C. Miller
019279a4b8
Fix some mangled text in the license block.
2018-10-26 08:19:41 -06:00
Todd C. Miller
64e5d34c57
Add comments in .c files so PVS-Studio will check them.
2018-10-21 08:46:05 -06:00
Todd C. Miller
8c94175ba1
Avoid some PVS-Studio false positives.
2018-10-19 13:35:20 -06:00
Todd C. Miller
71e98d9493
Include parse.h in sudoers.h since it will soon be required.
2018-05-14 09:05:02 -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
eae8bc9d56
Fix typo introduced in last commit to fix fill_args() overflow check.
2016-07-16 20:59:59 -06:00
Todd C. Miller
73b0ac4bc1
Fix underflow checl in fill_args().
2016-07-16 20:54:07 -06:00
Todd C. Miller
88ba54f478
Make sure we account for the trailing NUL when computing arg_size
...
in fill_args(). Bug #752
2016-07-16 20:12:17 -06:00
Todd C. Miller
0f816c4401
Make arg_size and arg_len unsigned since we do bitwise operations
...
on them.
2016-07-16 16:22:40 -06:00
Todd C. Miller
edd1a1cac5
In fill_args() clean up properly if there is an internal overflow
...
(which should not be possible). Coverity CID 104569.
2016-05-07 04:37:55 -06:00
Todd C. Miller
a09e45d339
In fill_args(), check for "arg_size == 0" instead of
...
"sudoerslval.command.args == NULL" since the latter leads Coverity
to imply that sudoerslval.command.args could be NULL later on.
Coverity CID 104093.
2016-05-05 15:12:37 -06: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
2224cfd000
If realloc of sudoerslval.command.args fails, reset sudoerslval.command.args
...
as well as arg_len and arg_size after freeing sudoerslval.command.args.
2016-01-29 11:10:36 -07: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
108bfb7af3
Add missing warnings for memory allocation failure.
...
Add function name to memory allocation warnings.
2015-07-14 14:50:36 -06:00
Todd C. Miller
0b241088b3
There's no need to conditionalize the #include <unistd.h>, we require
...
a POSIX system.
2015-07-02 09:08:28 -06:00
Todd C. Miller
d7224ea502
It's safe to rely on C89 semantics for realloc(NULL, size).
2015-06-20 19:27:31 -06:00
Todd C. Miller
4a07b472f0
Only include stddef.h where it is needed.
2015-06-20 05:34:35 -06:00
Todd C. Miller
dc883f2454
We require ANSI C so stop using the obsolete STDC_HEADERS.
2015-06-19 14:29:27 -06:00
Todd C. Miller
a50555faa2
Remove support for the obsolete malloc.h header.
2015-06-18 20:30:59 -06:00
Todd C. Miller
4da9e10971
Use non-exiting allocators in the parser (much of it already did).
2015-05-27 10:36:03 -06:00
Todd C. Miller
cbcaaa299a
No need to cast malloc() return value.
2015-05-14 10:47:09 -06:00
Todd C. Miller
59ab26dbcc
Go back to a 2 args debug_decl and just use the "default" instance,
...
now renamed "active".
2015-02-01 08:24:49 -07:00
Todd C. Miller
e9914a91b1
The sudoers plugin now defines its own list of debugging subsystem names
...
and defines.
2014-10-22 13:30:52 -06:00
Todd C. Miller
866cfc4fc3
Add support for multiple Debug lines per program. Callers may
...
register arbitrary debug facilities or use built-in defaults. We
now use separate Debug statements for plugins and programs.
2014-10-22 13:23:05 -06:00
Todd C. Miller
36a5767e3e
efree -> sudo_efree for consistency
2014-07-10 15:35:04 -06:00
Todd C. Miller
aecef4aa1d
Rename warning/fatal -> sudo_warn/sudo_fatal to avoid namespace
...
pollution in libsudo_util.so.
2014-06-27 09:30:52 -06:00
Todd C. Miller
a1240a5417
Use common printf format when warning of buffer overflow prevention.
2014-03-31 15:58:24 -06:00
Todd C. Miller
9ff3b1b570
Make hexchar() return -1 on invalid input instead of calling fatalx().
...
Callers used to check that the string was hex before calling hexchar().
Now callers must check for a -1 return value instead.
2014-03-26 13:50:51 -06:00
Todd C. Miller
96eb2c4f8f
Add warning_gettext() wrapper function that changes to the user locale,
...
then calls gettext().
Add U_ macro that calls warning_gettext() instead of gettext().
Rename warning2()/error2() back to warning_nodebug()/error_nodebug().
2013-11-18 08:59:57 -07:00
Todd C. Miller
07a804caf3
Quiet sign comparision warnings.
2013-10-23 15:03:31 -06:00
Todd C. Miller
d6282d154a
Update copyright years.
2013-04-24 09:35:02 -04:00
Todd C. Miller
35375a2b7e
Initial implementation of checksum support in sudoers.
...
Currently supports SHA-224, SHA-256, SHA-384, SHA-512.
TODO: checksum format validation in parser and base64 support.
checksum support for ldap sudoers
2013-04-14 07:00:21 -04:00