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

12989 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
9c98d0f4a5 Regenerate man format manuals 2025-04-28 12:26:52 -06:00
Todd C. Miller
b876e3bbf3 Sync "Path intercept" comment with default sudo.conf and man page 2025-04-28 12:25:43 -06:00
peppapig450
d173674c2f Fix typo and update Protocol Buffers URL in sudo_logsrv.proto man page
- Remove duplicate "The" in description of log_id field.
- Update outdated Protocol Buffers link from https://developers.google.com/protocol-buffers/ to https://protobuf.dev, the new canonical URL.

Signed-off-by: peppapig450 <peppapig450@pm.me>
2025-04-28 12:12:06 -06:00
peppapig450
334e23183d Fix minor grammar errors in sudoers.ldap man page
Signed-off-by: peppapig450 <peppapig450@pm.me>
2025-04-28 12:12:06 -06:00
peppapig450
aa5d4b2b40 Fix typo: 'Please not report' → 'Please do not report' in documentation
Signed-off-by: peppapig450 <peppapig450@pm.me>
2025-04-28 12:12:06 -06:00
peppapig450
2f4d6bfe25 Fix minor grammar and spelling issues in sudo.conf man page
Signed-off-by: peppapig450 <peppapig450@pm.me>
2025-04-28 12:12:06 -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
e8695d536c Use a pointer to end of buffer instead of tracking space left.
Fixes a problem in feedback mode where an initial backspace would
reduce the effective buffer size.  GitHub issue #439
2025-03-31 09:09:57 -06:00
Todd C. Miller
627ae4b09c Ignore scripts/check_man 2025-03-09 10:42:17 -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
ff3c2185f1 Dash/hyphen related style fixes from check_man. 2025-02-27 19:37:48 -07:00
Todd C. Miller
eae70b05cf Add hyphen/dash checks 2025-02-27 19:33:18 -07:00
Todd C. Miller
c2e77b7133 Add check_man script to check for man page warnings. 2025-02-27 08:21:22 -07:00
Todd C. Miller
38c0bdd7ad Sync sudo.DEBUG descriptions with comments in sudo_debug.h. 2025-02-26 19:12:23 -07:00
Todd C. Miller
cf1b87c71d Sync sed scripts that add back troff conditionals.
The sudo manuals contain conditional to avoid describing system-specific
behavior on systems that don't support it.  When we convert from
mdoc to man format we lose those conditionals, these sed scripts
add them back.  Changes to the mdoc files can prevent the regexps
from matching so they need to be updated periodically.
2025-02-23 09:33:06 -07:00
Todd C. Miller
4d331e6026 Fix some style warnings from "mandoc -Tlint" 2025-02-22 15:41:22 -07:00
Todd C. Miller
3ba525a348 Style fixes from Bjarni Ingi Gislason. 2025-02-22 15:31:21 -07:00
Todd C. Miller
b04386f631 Most Defaults entries are applied in order.
The exceptions are command-specific Defaults (which cannot be applied
until the command's path is resolved) and a small number of "early"
defaults that affect other entries.
2025-02-14 09:29:37 -07:00
Todd C. Miller
1bdead1bb4 Only use system includes for mksiglist and mksigname.
These are standalone programs that run on the host system
(which may differ from the target system) so we should not
include config.h and sudo_compat.h.
2025-02-11 09:08:04 -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
1032030f85 Split the code to fill an exec closure into two functions.
This lets us initialize the exec closure early and fill in the
events later.  It also makes things consistent with the exec_pty
version.
2025-02-10 19:40:26 -07:00
Todd C. Miller
a4a999b5eb Run groff with warnings enabled for "make lint". 2025-02-10 19:40:26 -07:00
Todd C. Miller
257a078a85 Prefer POSIX getpgrp() to getpgid(0).
We use getpgrp() in most place so prefer it for consistency
with the rest of the code base.
2025-02-10 08:42:09 -07:00
Todd C. Miller
8feff96d37 regen 2025-02-10 08:42:09 -07:00
Todd C. Miller
d3293c528a Make DIAGNOSTICS descriptions indent consistent with sudo.mdoc.in. 2025-02-10 08:42:09 -07:00
Todd C. Miller
dc0f16dbc4 Avoid using ".It Li foo ..." in sudo manuals.
The .Li macro is deprecated and makes no difference on terminal
devices.  Also avoid using items greater than 80 characters which
will wrap incorrectly.  Bug #1075.
2025-02-09 14:36:10 -07:00
Todd C. Miller
aad69105d8 Fix warnings from groff -mandoc -t -K utf8 -rF0 -rHY=0 -ww -b -z
Specify list offset and width in ens where applicable.
Shorten the ttyname description in sudo_logsrv.proto.mdoc.in.
Bug #1075.
2025-02-09 14:36:09 -07:00
Todd C. Miller
a9e1120791 Only package parent directories that match a non-default prefix
For example, if sudo is installed into /opt/sudo we only want to
package directories under /opt and not /var.
2025-02-08 10:24:11 -07:00
Todd C. Miller
43f16c1d24 regen 2025-02-08 09:12:34 -07:00
Todd C. Miller
4bb4c6a154 Add lib/util/login_max.c 2025-02-08 09:12:16 -07:00
Todd C. Miller
0be9f0f947 Initialize exec closure before calling sudo_fatal_callback_register()
The pty_cleanup() function, which may be called via fatal()/fatalx(),
expects that ec->details is set.  If there is a fatal error after
the cleanup hook is registered but before the exec closure it filled
in, pty_cleanup() would dereference a NULL pointer.
Reported by Bjorn Baron.
2025-01-21 19:35:43 -07:00
Mateusz Piotrowski
6fc816d90b Fix a typo in the description of exec_pty() 2025-01-17 12:03:49 -07:00
Todd C. Miller
a5bca1b94c Quiet a -Wconversion warning. 2025-01-16 20:04:41 -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
6df96785ff Switch to upload-sarif v3 2025-01-16 11:12:46 -07:00
Todd C. Miller
7cc0a0cc45 Update codeql GitHub actions to a non-deprecated version. 2025-01-16 10:20:16 -07:00
Todd C. Miller
c5b86f06e8 Use upload-artifact@v4, v3 is deprecated. 2025-01-16 09:50:24 -07:00
Todd C. Miller
fd3ff3a0bd Check the controlling tty to determine if a tty belongs to the user.
Previously, we compared the terminal device number returned by
get_process_ttyname() with that of stdin, stdout and stderr.  This
causes problems on Linux if the user is logged in on the console,
which is a virtual device that may correspond to one of several
different terminal devices.  In this specific case, there is a
mismatch between the controlling terminal listed in /proc/self/stat
(which corresponds to the underlying terminal device) and the device
number of stdin, stdout and stderr (which is that of /dev/console).
2025-01-16 09:25:58 -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
0fdbb6e2ee Check for sysconf() negative return value instead of -1
Quiets a coverity warning.
2025-01-15 08:44:19 -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
7c075c100d Add an OFF_T_MAX define
This will be used for integer overflow checks when copying files.
2025-01-15 08:39:36 -07:00
Todd C. Miller
30729312c2 Update copyright year 2025-01-15 08:38:58 -07:00