Todd C. Miller
6286ce1d16
Store column number for aliases, defaults and userspecs too.
...
This is used to provided the column number along with the line
number in error messages. For aliases we store the column of the
alias name, not the value since that is what visudo generally needs.
2020-11-02 05:39:06 -07:00
Todd C. Miller
982012dbb1
Display column number in parse error messages too.
...
Bug #841
2020-11-01 15:34:11 -07:00
Todd C. Miller
e8747a33f8
Add a newline at end of line if one is missing.
...
This is simpler than having to support entries that end at EOF too.
2020-09-27 20:21:05 -06:00
Todd C. Miller
7d20900616
Use sudoerschar (yychar) instead of last_token.
...
The parser already provides a way to examing the last token processed,
we don't need to add our own.
2020-09-26 06:39:57 -06:00
Todd C. Miller
70ada21c5b
Detect when a reserved word is used when declaring an alias.
...
Now instead of "syntax error, unexpected CHROOT, expecting ALIAS"
the message is "syntax error, reserved word used as an alias name"
Bug #941
2020-09-25 12:24:45 -06:00
Todd C. Miller
8a8a24560e
Fix copy and paste error; Coverity CID 214191
2020-09-03 13:23:27 -06:00
Todd C. Miller
578789c56f
Fix error recovery in a privilege after a ':' separator.
2020-09-02 11:01:09 -06:00
Todd C. Miller
fc563286ff
Initialize runchroot and runcwd in init_options()
2020-09-02 09:34:43 -06:00
Todd C. Miller
e3b85171f8
Regenerate the parser with "bison -y" for verbose syntax error messages.
2020-09-01 21:34:30 -06:00
Todd C. Miller
1676f0ceeb
Support "*" for CWD/CHROOT to allow user to specify cwd or chroot.
...
Adds two new command line options, -D (--chdir) and -R (--chroot)
that can only be used when sudoers sets runcwd or runchroot to "*".
2020-09-01 14:10:02 -06:00
Todd C. Miller
6bdfd010d2
Add CHROOT and CWD sudoers options.
...
Also matching runchroot and runcwd Defaults settings.
2020-09-01 06:26:00 -06:00
Todd C. Miller
c7bc24d40b
Recover from a syntax error after the ':' in a privilege spec.
...
For compound privilege specs, don't throw away the entire thing if
we have a syntax error, only the part after the error is encountered.
2020-08-16 15:19:53 -06:00
Todd C. Miller
11803027c6
Add explicit end-of-line matching in the parser for better error messages.
...
A valid line in sudoers must end in a newline or EOF.
Previously, it was possible (though not documented) to have multiple
user specs on a single line. Now, each must be on its own line.
2020-08-16 14:59:45 -06:00
Todd C. Miller
d72a48dc78
Add NOMATCH token and use it in the lexer for an unmatched pattern.
...
The ERROR token is now only used for errors detected by the lexer
and for which we've already printed an error. This lets us remove
the hack in sudoerserror() and just check last_token to determine
whether or not to display the error.
2020-08-16 06:42:15 -06:00
Todd C. Miller
de9c77ba7e
Enable error recovery for syntax erorrs that don't end with a newline.
...
A syntax error on the last line of a sudoers file with no trailing
newline is now recoverable.
2020-08-15 11:38:56 -06:00
Todd C. Miller
94eb14c214
Add error recovery for unexpected tokens after include/includedir.
2020-08-15 11:29:46 -06:00
Todd C. Miller
8a97150f56
Define YYERROR_VERBOSE for bison and rename COMMENT -> '\n'
...
This results in better error messages when there is a parse error
2020-08-10 13:59:31 -06:00
Todd C. Miller
5f5f28ac7c
Require that a @include line end with a newline or EOF.
...
We now parse the entire line before reading the include file. This
is less surprising behavior and results in better error messages.
2020-08-07 14:22:24 -06:00
Todd C. Miller
3235e4353c
Display more specific parser error messages when possible.
2020-08-07 14:20:45 -06: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
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
0cf2e09e0c
Apply spelling fixes.
...
Fixes from PR #30 (ka7) and Bug #925 (fossies.org codespell)
2020-05-06 09:27:43 -06:00
Todd C. Miller
ea8445e364
Allow the ALL keyword to be specified with a digest list.
2020-03-11 11:19:37 -06:00
Todd C. Miller
4eca443246
Allow a list of digests to be specified for a command.
2020-03-11 11:17:52 -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
679cd38238
Plug memory leak on malloc failure.
2019-08-30 10:38:07 -06:00
Todd C. Miller
e99082e05b
Fix special handling of ipa_hostname that was lost in sudo 1.8.24.
...
We now include the long and short hostname in sudo parser container.
2019-08-15 14:20:12 -06:00
Todd C. Miller
1e1ef61902
Add SPDX-License-Identifier to files.
2019-04-29 07:21:51 -06:00
Todd C. Miller
1e6e048180
Rename FOLLOW and NOFOLLOW tokens FOLLOWLNK and NOFOLLOWLNK.
...
Fixes a namespace collision on Solaris when bison is used.
2019-02-12 12:02:02 -07: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
70d519c8ad
o Move userspecs, defaults and aliases into a new struct sudoers_parse_tree.
...
o The parse tree is now passed to the alias, match and defaults functions.
o The nss API has been changed so that the nss parse() function returns
a pointer to a struct sudoers_parse_tree which will be filled in
by the getdefs() and query() functions.
2018-07-26 15:12:33 -06:00
Todd C. Miller
154a5f59a9
Move digest code into libutil
2018-05-24 21:04:07 -06:00
Todd C. Miller
f38317269d
Add free_userspecs() and free_default() and use them instead of
...
looping over the lists and calling free_userspec() and free_default().
2018-05-15 16:35:07 -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
38ff661621
Fix a user after free crash as well as a memory leak when filtering
...
Defaults.
2018-04-13 10:49:05 -06:00
Todd C. Miller
821e8a07da
Silence a false positive from the clang static analyzer.
2018-03-21 14:55:17 -06:00
Todd C. Miller
bc5e2d06a7
Add free_default() to free a struct defaults pointer so we have a
...
single place where we free the defaults. A pointer to the previous
Default's binding may be passed in to avoid freeing an already free
binding.
2018-03-21 12:11:19 -06:00
Todd C. Miller
910f288948
fix compilation on Solaris
2018-03-10 20:16:20 -07:00
Todd C. Miller
5c36f9dec3
Initial support for adding comments that will be emitted when
...
sudoers is formatted. Currently adds a comment for the source
sudoRole when converting from ldif -> sudoers.
2018-03-04 07:03:43 -07:00
Todd C. Miller
3226f7e28b
Move common bits of ldap to sudoers conversion into ldap_common.c
...
and use it in sssd.c.
2018-02-09 18:21:40 -07:00
Todd C. Miller
4e2402a8e4
Convert ldap results into a sudoers userspec so we can use the "sudo
...
-l" output functions in parse.c.
2018-02-09 18:21:01 -07:00
Todd C. Miller
5cca4b6906
Refactor member freeing code into free_member().
...
Refactor userspec freeing code into free_userspec().
2018-02-05 13:33:29 -07:00
Todd C. Miller
b161ebe62d
Remove duplicate options %type
2018-01-17 09:52:09 -07:00
Todd C. Miller
48fba3c2cc
update my email to Todd.Miller@sudo.ws
2017-12-03 17:53:40 -07:00