58 Commits

Author SHA1 Message Date
Todd C. Miller
f67a7e623e Sprinkle some more const in defaults.c. 2023-12-15 15:05:02 -07:00
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
1c13b8a628 Add support for "plugin" defaults type. 2023-09-24 16:28:36 -06:00
Todd C. Miller
b8f2680cf0 Make flag in union sudo_defs_val bool to match how it is used.
Adjust find_path()'s ignore_dot function argument to match.
2023-09-13 14:59:29 -06:00
Todd C. Miller
2440174954 Make struct sudoers_context private to sudoers.c.
We now pass a pointer to the context where necessary.  There are a
few cases where we need to request the context from sudoers via
sudoers_get_context() for the plugin API functions.  If the plugin
API was able to pass around a closure pointer this would not be
necessary.
2023-08-21 09:21:49 -06:00
Todd C. Miller
a38b714667 sudoers plugin: silence most -Wconversion warnings. 2023-07-07 15:07:04 -06:00
Todd C. Miller
1f19a6b72b Pass around const struct sudoers_parse_tree pointers where possible. 2023-03-17 13:31:36 -06:00
Todd C. Miller
ce387a6849 Split log_{input,output} into log_{stdin,ttyin} and log_{ttyout,stdout,stderr}
If log_input is set, log_{stdin,ttyin} will be set as well.
If log_output is set, log_{stdout,stderr,ttyout} will be set as well.
This provides more fine-grained control over I/O logging and makes it
possible to disable logging piped or redirected intput or output.
2022-09-20 14:35:12 -06:00
Todd C. Miller
13672f28df Make sudo pass -Wwrite-strings 2022-06-28 16:33:15 -06:00
Todd C. Miller
65e5b89f1d Pass file, line and column to sudoers defaults callbacks. 2022-03-10 13:35:58 -07:00
Todd C. Miller
c58a080dd5 Add a flag to avoid splitting list entries on white space. 2022-01-28 08:52:41 -07:00
Todd C. Miller
0efe280037 Add a new sudoers settings log_passwords and passprompt_regex.
When logging terminal input, if log_passwords is disabled and any
of the regular expressions in the passprompt_regex list are found
in the terminal output, terminal input will be replaced with '*'
characters until a newline or carriage return is found in the input
or an output character is received.
2022-01-28 08:52:41 -07:00
Todd C. Miller
86f123cd9d Pass the operator to the Defaults callback too.
That way we can tell what to do in callbacks for lists.
2022-01-28 08:52:41 -07:00
Todd C. Miller
28cfe868ec Mark is_early_default(), run_early_defaults(), set_early_default() static.
They are not used outside of defaults.c.
2022-01-18 13:40:59 -07:00
Todd C. Miller
f279df5e18 Add basic support for setting resource limits in sudoers.
The default for rlimit_core is "0,0"
Resource limits are passed back to the front-end in command_info[]
when set.
2021-11-08 17:46:19 -07:00
Todd C. Miller
132936f8f0 Make it possible to call the sudoers policy check function multiple times.
We need to reset the Defaults values to their original state.
2021-08-09 15:50:25 -06:00
Todd C. Miller
82f5592d67 T_TIMEOUT is not a bitwise flag so doesn't need to be a power of 2. 2021-06-02 07:21:40 -06:00
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
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
1e1ef61902 Add SPDX-License-Identifier to files. 2019-04-29 07:21:51 -06:00
Todd C. Miller
c0a12d9d95 Be sure to include sudo_queue.h where needed instead of relying on other headers. 2019-02-19 08:31:08 -07:00
Todd C. Miller
171686c422 update_defaults() needs to be able to take a defaults_list for
the ldap/sssd backends which support per-role defaults.
2018-08-02 14:06:36 -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
f9be3a48a2 Simplify the nss interface such that each sudoers provider fills
in a per-nss list of userspecs and defaults instead of using separate
lookup and list functions.  This makes it possible to have a single
implementation of the code for sudoers lookup and listing.
2018-05-14 09:05:03 -06:00
Todd C. Miller
4c0c225062 Store passwd_timeout and timestamp_timeout as a struct timespec
instead of as a float.  Remove timeout argument to auth_getpass()
as it was never used.
2018-01-22 12:18:48 -07:00
Todd C. Miller
48fba3c2cc update my email to Todd.Miller@sudo.ws 2017-12-03 17:53:40 -07:00
Todd C. Miller
3980f1531b Add support for command timeouts in sudoers. After the timeout,
the command will be terminated.
2017-02-14 15:56:34 -07:00
Todd C. Miller
79ca752802 Go back to parsing Defaults entries in update_defaults instead of
as sudoers is read.  Otherwise, we cannot properly support early
defaults like sudoers_locale.
2016-11-09 16:00:12 -07:00
Todd C. Miller
df8404dbd4 Instead of parsing sudoers Defaults twice, parse once while reading
sudoers and then just set the parsed value in update_defaults().
2016-11-06 18:59:49 -07:00
Todd C. Miller
3c28810feb no longer need struct defaults forward referebce 2016-11-03 10:15:18 -06:00
Todd C. Miller
75e29f163e Add file:linenumber prefix to all Defaults warnings so we can see
them when running sudo too.  For LDAP/SSSD we print the sudoRole
instead of the file name and omit the line number.
2016-11-02 17:07:32 -06:00
Todd C. Miller
8a48085184 Instead of checking Defaults values after the fact, check them at
sudoers parse time.  This makes it possible to display the file and
line number with the problem and for visudo to go right to the
error.
2016-11-01 14:22:32 -06:00
Todd C. Miller
9d94ee11c0 Avoid passing around struct defaults when it is not needed. As a
result, we no longer need to include gram.h in the LDAP and SSSD
backends.
2016-08-08 20:09:59 -06:00
Todd C. Miller
0bf2d9b162 Instead of deferring setting early defaults until we have traversed
the entire defaults list, just defer running the callbacks.  Otherwise,
if the last early default setting we see has a bad value we won't
set any defaults of that type even if there was an earlier one that
was valid.
2016-08-08 17:04:20 -06:00
Todd C. Miller
16551031f9 Add support for early defaults to the ldap and sssd backends. 2016-07-27 14:20:17 -06:00
Todd C. Miller
256ca993b9 Update defaults in visudo after sudoers has been edited so we pick
up locale changes.  The init_defaults() function will now re-init
the sudoers locale.
2016-07-22 10:41:56 -06:00
Todd C. Miller
5e9173df7a Make strings const in functions that set defaults as they are
not modified.
2016-07-19 14:55:27 -06:00
Todd C. Miller
9b42640ef5 Change defaults callbacks to take a union sudo_defs_val * instead
of a char *.
2016-07-18 12:11:25 -06:00
Todd C. Miller
d004b02fc6 Use non-exiting allocatings in the sudoers plugin. 2015-06-17 06:49:59 -06: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
9b7dfa7522 Remove calls to log_fatal() in I/O log functions and just pass an
error back to the caller.
2014-04-04 15:30:12 -06:00
Todd C. Miller
ef2cff1d33 Now that we have proper number parsing functions we should store
T_UINT defaults values as unsigned int, not int.
2013-12-11 14:43:04 -07:00
Todd C. Miller
3e4f5c5848 Don't use int where we really mean enum def_tuple. When this code
was written it was assumed that we may have multiple tuple types.
However, that hasn't happened and probably never will.
2013-12-11 14:31:50 -07:00
Todd C. Miller
f85106ea67 Use SLIST and STAILQ macros instead of doing headless singly linked
lists manually.  As a bonus we now use a tail queue for ldap.c and
sudoreplay.c.
2013-10-22 09:08:09 -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
7aeadbd5b3 Add new check_defaults() function to check (but not update) the
Defaults entries.  Visudo can now use this instead of update_defaults
to check all the defaults regardless instead of just the global
Defaults entries.
2012-08-14 10:45:55 -04:00
Todd C. Miller
f6fdc909b4 The "op" parameter to set_default() must be int, not bool since it is
set to '+' or '-' for list add and subtract.
2012-02-21 05:13:13 -05:00
Todd C. Miller
21a2f95821 Use stdbool.h instead of rolling our own TRUE/FALSE macros. 2011-12-02 11:27:33 -05:00