2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-29 13:28:10 +00:00

13161 Commits

Author SHA1 Message Date
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
Ignacy Gawędzki
5794e511da Fix getting ppid in get_process_ttyname for Linux.
The ppid field in /proc/self/stat is the fourth and not the third.
The latter is the process state (S, R, etc.).

Signed-off-by: Ignacy Gawędzki <ignacy.gawedzki@green-communications.fr>
2025-01-15 05:35:25 -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
103af8cb27 Newer macOS deprecates -force_flat_namespace for -flat_namespace
The linker warns about -force-flat_namespace and uses -flat_namespace
instead.  Check for -flat_namespace if -force-flat_namespace is not
found.
2025-01-04 10:31:50 -07:00
Todd C. Miller
46831d6ef2 build_pkgs: adapt to work with a git repo 2025-01-04 08:20:59 -07:00
Todd C. Miller
b52ef1fbbb Remove unused -b option 2025-01-04 07:45:07 -07:00
Todd C. Miller
355c82a1d5 Update to libtool 2.5.3 2025-01-03 17:38:29 -07:00
Todd C. Miller
e13163ce0a Add markdown mode for use with the sudo web site. 2025-01-01 15:07:57 -07:00
Todd C. Miller
a3c1cbd881 Use Text::Wrap::fill() for ChangeLog body, not wrap(). 2024-12-27 12:43:16 -07:00
Todd C. Miller
e670d2a85d Sort entries in the "SEE ALSO" section. 2024-12-20 18:02:54 -07:00
Todd C. Miller
516f72960a If sudo is run without a tty via ssh, suggest using "ssh -t"
The current warning message mentions using sudo's -S option but
this will cause the password to be echoed without a terminal.
In most cases, the user just needs to run ssh with the -t option.
2024-12-20 18:02:52 -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
3226c60e6a Quiet codespell 2.3.0 complaints. 2024-11-29 14:22:31 -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
015a0d7179 Added tag SUDO_1_9_16p2 for changeset 3c721fa0ff0c
--HG--
branch : 1.9
2024-11-25 08:36:38 -07:00
Todd C. Miller
172cbd968e Merge sudo 1.9.16p2 from tip.
--HG--
branch : 1.9
SUDO_1_9_16p2 v1.9.16p2
2024-11-25 08:36:28 -07:00
Todd C. Miller
73cbe4e7e1 Sudo 1.9.16p2 2024-11-25 08:34:04 -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
4c99e29bb3 Use NULL, not false, in the terminating entry of test_data[]. 2024-11-16 13:48:23 -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
b7efb8ab5b sudo_ttyname_dev: On Linux try to use /proc/self/fd/{0,1,2} if possible.
If one of std{in,out,err} matches the specified device, try to
resolve it to a path by using /proc/self/fd/{0,1,2}.  This avoids
searching all of /dev and works in a chroot where /proc is mounted
but /dev/pts is not.  GitHub issue #421.
2024-11-16 08:17:51 -07:00
Todd C. Miller
7e8f006888 get_process_ttyname: always return the terminal device if we find one.
If sudo cannot map the device number to a device file, set name to
the empty string.  The caller now checks for an empty name and only
passes the tty path to the plugin if it is non-empty.  This allows
sudo to run without warnings in a chroot() jail where the terminal
device files are not present.  GitHub issue #421.
2024-11-15 20:38:14 -07:00
Todd C. Miller
1fbc146676 Added tag SUDO_1_9_16p1 for changeset d6059bdf2a76
--HG--
branch : 1.9
2024-11-12 18:46:55 -07:00
Todd C. Miller
7b41190db6 Merge sudo 1.9.16p1 from tip.
--HG--
branch : 1.9
SUDO_1_9_16p1 v1.9.16p1
2024-11-12 09:04:24 -07:00
Todd C. Miller
abc0baffc4 Sudo 1.9.16p1 2024-11-12 08:56:50 -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
8b53757164 Shell-style substitution is not supported in env_file.
Also document that comments are supported.
2024-11-11 09:48:07 -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
9d49f861c8 Run igor on other docs too, not just man pages 2024-10-28 09:33:23 -06:00
Todd C. Miller
5180dd8021 Remove trailing whitespace 2024-10-28 09:23:42 -06:00