2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-22 01:49:11 +00:00

3934 Commits

Author SHA1 Message Date
Todd C. Miller
82ebb1eaa9 log_failure: only display "command not found" if running a command
If the user is not allowed to run a command, we try to give them a
more useful message than "Sorry, user foo may not run sudo on bar."
However, this should only be done when running, not listing, a
command.  Otherwise, it would be possible for a user with no sudo
privileges to use "sudo -l /path/to/some/command" to determine
whether an executable exists in a directory that they do not have
search access to.
2025-05-06 15:15:11 -06:00
Todd C. Miller
111fd83fb8 Use constant-time string compare for plain text password check.
Avoid potential password guessing based on timing attacks on
the strcmp() function.  Reported by Quarkslab.
2025-04-30 15:24:50 -06:00
Todd C. Miller
a294a8be00 check_user: refactor the "running as self" check into its own function 2025-04-30 13:54:36 -06:00
Todd C. Miller
28837b2af1 check_user: restrict the special case for running as the invoking user
The intent is to allow the user to run a command or edit a file as
themself without entering a password.  It should not apply to listing
a command via "sudo -l command".
2025-04-30 11:07:37 -06:00
Todd C. Miller
ce0ec8ddca Free existing contents of struct eventlog before overwriting.
In the unlikely event that there are duplicate keys in info_msgs,
free the old string before overwriting with the new one.
2025-03-31 20:11:34 -06:00
Todd C. Miller
fce45b2767 Make ignore_dot the default
Add --disable-ignore-dot to disable it and deprecate --with-ignore-dot.
2025-03-08 17:59:32 -07:00
Todd C. Miller
b0d94331c0 No longer need to define NSIG for cppcheck.
There is now a configure check that defines it as needed.
2025-02-11 08:42:57 -07:00
Todd C. Miller
43f16c1d24 regen 2025-02-08 09:12:34 -07:00
Todd C. Miller
a27b989c9c Check for negative return value of read, write and lseek instead of -1
The return values are used in ways that assume they are positive.
In practice, it is not possible to have a negative return value
other than -1 due to the size of the buffers being read from or
written to.  Also add overflow checks when updating the buffer len.
Quiets several coverity warnings.
2025-01-16 19:46:15 -07:00
Todd C. Miller
a3cd820d21 Move LOGIN_NAME_MAX compat define to login_max.c 2025-01-15 08:57:22 -07:00
Todd C. Miller
e3753309fe copy_string: use an end pointer to quiet a coverity warning
Instead of modifying the len parameter and using it for bounds
checking, compute the end of the source string and bound check on
that instead.  Also simplify the code slightly and enable debugging.
2025-01-15 08:45:59 -07:00
Todd C. Miller
af4634a1c1 expand_include: initialize dst_size to 1 to quiet coverity warning
This could only be an issue if the sudoers file was an empty string,
which is not possible.
2025-01-15 08:45:02 -07:00
Todd C. Miller
34a3c84de1 digest_matches: don't initialize digest_len to -1
This was done to quiet a coverity warning but newer coverity now
warns about this instead.
2025-01-15 08:44:23 -07:00
Todd C. Miller
405070d482 Add sudo_login_name_max() and sudo_host_name_max()
These convenience functions cache the value and handle any potenial
errors from sysconf().
2025-01-15 08:42:30 -07:00
Todd C. Miller
01b1410d61 Format T_TIMESPEC as "%d.%d" instead of "%.1f"
This fixes the display of the timeout values in the "sudo -V" output
on systems without a C99-compliant snprintf().  The snprintf()
replacement sudo ships with does not support floating point.
2025-01-11 14:38:16 -07:00
vayers
7c121ff834 Replace tab with space
A line in the sudoers file contains a tab where a space seems to be more
appropriate.
2025-01-11 14:11:56 -07:00
Todd C. Miller
4dbb07c19b The "ALL" command should not override a previous NOSETENV tag in a rule.
Command tags are inherited from previous Cmnds in a Cmnd_Spec_List.
There is a special case of the SETENV tag for the "ALL" command,
where SETENV is implied if no explicit SETENV or NOSETENV tag is
specified.  The code to inherit the SETENV tag didn't take into
account that an implied value for SETENV should also be overridden
by an explicit SETENV or NOSETENV tag in the previous Cmnd in the
Cmnd_Spec_List.
2024-12-20 18:02:43 -07:00
Todd C. Miller
de3b179a03 Don't need to undef _POSIX_HOST_NAME_MAX, it is not used. 2024-12-01 10:00:30 -07:00
Todd C. Miller
d5028a00c0 Use NODEV macro instead of explicit (dev_t)-1.
Also fix an assignment of dev_t to -1 that should be NODEV.
Bug #1074.
2024-11-28 11:26:00 -07:00
Todd C. Miller
f8987fc0bb Work around a bug in UBSan that is causing CI failures.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116834
2024-11-18 11:05:48 -07:00
Todd C. Miller
da20ccec08 Avoid multiple calls to sysonf() via the MAX macro.
The expansion of MAX would result in multiple calls to sysconf().
It is less error-prone to store the result of sysconf() in a long.
2024-11-17 09:46:38 -07:00
Todd C. Miller
3d85f2e98f Add some casts to quiet -Wconversion 2024-11-17 13:01:10 -07:00
Todd C. Miller
9613ef9445 Cast hook functions to sudo_hook_fn_t to fix C23 compile error.
The sudo plugin API defines sudo_hook_fn_t as a function with
unspecified arguments.  This is no longer supported in C23 so use
a variadic function for sudo_hook_fn_t instead.  Moving to a union
may be a better long-term fix.  GitHub issue #420.
2024-11-16 11:33:21 -07:00
Todd C. Miller
9c63ff0e1b Pass NULL, not false, to sudoers_format_default_line(). 2024-11-16 11:21:39 -07:00
Todd C. Miller
0f41cd717f pam_get_item() takes a void ** arg, not const void **, on Solaris 2024-11-11 20:08:13 -07:00
Todd C. Miller
116115229a Do not send mail for "sudo -nv" or "sudo -nl"
This avoids sending mail for users running "sudo -nv" or "sudo -nl"
even when mail_badpass or mail_always are enabled.  We already avoid
logging in that case but mailing was not disabled when that change
was made.  Bug #1072.
2024-10-29 09:05:09 -06:00
Todd C. Miller
17aa7688c9 sudo_pam_verify: move PAM_USER after getpass_error check
Move it into the PAM_SUCCESS case of the switch *pam_status switch.
2024-10-05 16:49:39 -06:00
Todd C. Miller
52c73b8f51 Fix indentation 2024-10-05 14:32:26 -06:00
Marco Trevisan (Treviño)
a68e821ef9 plugins/pam: Check the user didn't change during PAM transaction
PAM modules can change the user during their execution, in such case,
sudo would still use the user that has been provided giving potentially
access to another user with the credentials of another one.

So prevent this to happen, by ensuring that the final PAM user is
matching the one which started the transaction
2024-10-05 11:09:36 -06:00
Célestin Matte
05b5de538b Fix typo in sudoer file comment 2024-09-28 16:52:20 -06:00
Rose
77672d83c4 Put restrict qualifers in strvec_join function pointer 2024-09-21 14:08:13 -06:00
Andy Fiddaman
131e7e2de0 Allow --secure-path-value=no
This adds support for --with-secure-path-value=no to allow packagers
to ship the sudoers configuration file with the secure path
line commented out if required.
2024-09-21 14:03:24 -06:00
Todd C. Miller
0cbddb6939 alias_error: display the file and line info for the duplicate alias
Having the file and line of the previous alias definition should
make it easier to fix duplicate alias errors.
2024-09-13 11:56:09 -06:00
Ferdinand Bachmann
ce36f01def Add pam_silent setting to sudoers example config 2024-09-09 19:54:46 -06:00
Todd C. Miller
22b320645c Fix the date written used by the exit record in sudo-format log files
The change to always get the current time when building a struct
evlog in sudoers broke the data and time written for exit records.
This only affected file-based logs, not syslog.  GitHub issue #405.
2024-09-06 13:05:47 -06:00
Todd C. Miller
4751a4d2dd Make a ttydev parse error non-fatal for now
This is new for sudo 1.9.16 so we don't want to break sudo if there
ends up being a bug in formatting dev_t from the front-end.
2024-08-15 09:31:48 -06:00
Todd C. Miller
827fa8b76d Use sudo_strtonum() instead of strtoull().
Fixes building on systems that lack strtoull().  While dev_t is
unsigned on most systems, we can still use sudo_strtonum() here as
long as we allow the full range of values [LLONG_MIN,LLONG_MAX].
We don't use strtoul() here since some 32-bit systems have 64-bit
dev_t.
2024-08-13 12:43:10 -06:00
Todd C. Miller
e3fd614e7e Sync base64_encode and base64_decode prototypes with parse.h. 2024-08-13 08:09:24 -06:00
Rose Silicon
60b6f30022 Restrict-qualify dst in base64_decode
Definition restrict qualifies but not declaration in header.
2024-08-13 08:07:07 -06:00
Rose
818aae38ce Add restrict qualifiers to base64_decode and base64_encode 2024-08-12 10:54:45 -06:00
Rose
85d08e96bd Restrict-qualify iolog_path_escapes like we do with check_iolog_path
Also add it to the function pointer definition to act as a hint to use restrict in the various copy functions.
2024-08-12 10:15:21 -06:00
Todd C. Miller
1381a69f59 Use FD_CLOEXEC instead of just 1 2024-08-02 19:48:41 -06:00
Todd C. Miller
cb2457410a Updated translations from translationproject.org 2024-07-27 10:17:59 -06:00
Todd C. Miller
b2af245b31 Updated translations from translationproject.org 2024-06-25 20:08:49 -06:00
Todd C. Miller
e0e24456bc Enable secure_path in default sudoers file.
It is still disabled by default in the sudo binary.
2024-06-10 20:37:05 -06:00
Todd C. Miller
1db1453556 Preserve SUDO_EDITOR, EDITOR, and VISUAL for visudo. 2024-06-10 08:17:17 -06:00
Todd C. Miller
14a8d9c09a Update .pot files for 1.9.16 2024-06-08 09:07:07 -06:00
Todd C. Miller
e9d65e67aa Treat unresolvable User_Alias/Host_Alias as non-aliases in JSON output.
This matches the behavior of the sudoers parser.  There is no way
to tell for sure if an upper case word is an alias or a user or
host name.  An unresolvable command alias is never a command since
it doesn't start with a '/'.  GitHub issue #381
2024-06-07 10:54:35 -06:00
Todd C. Miller
7c74a971d9 Allow the path in Chdir_Spec | Chroot_Spec to be double-quoted.
The other values of an Option_Spec could already be quoted but path
names are treated specially.
2024-05-26 14:37:50 -06:00
Robert Manner
ba29f54d97 logsrvd,plugins/sudoers: add debug log on TLS verification error 2024-05-17 17:18:32 -06:00