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

960 Commits

Author SHA1 Message Date
Rose
5fad16bda2 Properly check against errors against fwrite
fwrite is not the same as write; you have to explicitly compare against the length to detect errors, and sometimes number of items is mistaken for length.
2025-06-17 20:29:12 -06:00
Rose
a925829e60 Restrict-qualify a few methods that are listed as such 2025-06-04 11:12:18 -06:00
Todd C. Miller
77fe6ae51e Use TCSAFLUSH not TCSADRAIN when disabling echo
A long time ago this was changed from TCSAFLUSH to TCSADRAIN due
to some systems having problems with TCSAFLUSH.  That should no
longer be a concern.  Using TCSAFLUSH ensures that password input
that has been received by the kernel, but not yet read by sudo,
will be discarded and not echoed.
2025-05-22 08:44:04 -06: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
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
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
a3cd820d21 Move LOGIN_NAME_MAX compat define to login_max.c 2025-01-15 08:57:22 -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
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
3d85f2e98f Add some casts to quiet -Wconversion 2024-11-17 13:01:10 -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
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
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
Rose
e9e0096a19 Restrict-qualify glob and its functions
glob is restrict-qualified in the standard
2024-08-13 13:01:28 -06:00
Rose
82eac2b413 Restrict-qualify sudo_hexchar_v1
sudo_hexchar_v1 requires an array of at least size-2, and is not aliased.
2024-08-13 12:54:43 -06:00
Rose
cba5d2a5c9 Use static declaration for array sizes to uuid functions 2024-08-13 12:21:03 -06:00
Rose
e7483ae8e9 Restrict-qualify stat_multiarch 2024-08-13 09:47:57 -06:00
Rose
f96e6d1340 Use the full definition of the emulated function that is missing 2024-08-12 13:12:38 -06:00
Rose
787a64f514 Use restrict to optimize sudo_uuid_to_string_v1 2024-08-12 13:10:37 -06:00
Rose
36cea6e5fd sudo_uuid_to_string_v1's first argument should be const
uuid is not modified.
2024-08-12 09:20:05 -06:00
Todd C. Miller
4e1c587535 Set need_comma when closing an array or object.
This fixes an issue where an empty array or object would not have
a comma after it.  GitHub issue #381
2024-06-07 10:54:32 -06:00
Todd C. Miller
27963e39f3 Pass "make spell" with updated codespell. 2024-04-29 09:19:52 -06:00
Todd C. Miller
b6175b78ad Remove EVLOG_JSON, callers must use EVLOG_JSON_COMPACT or EVLOG_JSON_PRETTY 2024-03-09 11:42:07 -07:00
Todd C. Miller
46e31a74d7 Add "json_pretty" log format, currently the same as "json".
In a future version, "json" will be an alias for "json_compact"
instead.  GitHub issue #357.
2024-03-09 10:59:54 -07:00
Todd C. Miller
1debad3bec Add json_compact log type for compact/minified JSON.
The "json_compact" log type logs one event per line in compact/minified
JSON format.  GitHub issue #357.
2024-03-08 16:31:39 -07:00
Todd C. Miller
81acb2bd7b Regenerate dependencies 2024-02-21 13:17:54 -07:00
Todd C. Miller
3944ab1fbe Use $(CPP) instead if $(CC) -E when buiding .i files from .c. 2024-02-21 12:31:50 -07:00
Todd C. Miller
9b073f3124 Using $< in a non-suffix rule context is a GNU make extension. 2024-02-21 13:01:14 -07:00
Yann E. MORIN
6ec958f27e lib/utils: detect failure to generate signals list and names
Currently, we generate the signal list and names by running cpp on our
header, and piping the result into sed.

However, when cpp fails [0], we do not catch that failure, as the error
code of the LHS of a pipe is lost, with the pipe returning the RHS-most
return code.

Fix that by introducing two new intermediate rules, each to generate the
preprocessed .i files, and use those as dependencies and input to the
rule that generates the headers. Those two .i files will be cleaned up
by the existing *.i glob.

[0] a failure happens on recent hosts, due to inconsistency with
time64_t and large-file support (lines elided and wrapped for
readability):

    /usr/bin/cpp [...] ./sys_signame.h \
    | /usr/bin/sed -e '1,/^int sudo_end_of_headers;/d' -e '/^#/d' > mksigname.h
    In file included from /usr/include/features.h:394,
                     from /usr/include/sys/types.h:25,
                     from ./sys_signame.h:4:
    /usr/include/features-time64.h:26:5: error: #error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
       26 | #   error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
          |     ^~~~~
    /usr/bin/gcc [...] ./mksigname.c -o mksigname
    In file included from /usr/include/features.h:394,
                     from /usr/include/bits/libc-header-start.h:33,
                     from /usr/include/stdlib.h:26,
                     from ./mksigname.c:27:
    /usr/include/features-time64.h:26:5: error: #error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
       26 | #   error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64"
          |     ^~~~~
    make[2]: *** [Makefile:263: mksigname] Error 1

In that case, we were lucky that the subsequent gcc call also failed,
and for the same reason. That time64_t and lfs issue should be fixed (at
least investigated), but that does not mean we should not be more robust
when parsing the header either.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2024-02-18 07:17:58 -07:00
Todd C. Miller
eb4506f434 Update embedded copy of zlib to version 1.3.1. 2024-01-23 09:16:22 -07:00
Rose
725d3fdc20 Prefer putchar over fputc where possible
putchar is easier to understand than fputc and printf and does less work than those two do.
2024-01-13 15:24:43 -07:00
Todd C. Miller
00452471b1 Add check for sysconf(_SC_PAGESIZE) failure. 2024-01-01 11:03:01 -07:00
Todd C. Miller
63f2c54b86 Add missing checks for strdup() failure. 2023-12-21 16:55:08 -07:00
Todd C. Miller
10fd66ac99 closefrom_nodebug: skip fds < 0
This can only happen if lowfd < 0, which is never the case.
Quiets a static analyzer warning.
2023-12-18 13:32:53 -07:00
Todd C. Miller
1e03cbd0b4 sudo_term_is_raw: only try to lock the fd if it is a tty
This moves sudo_isatty() to libsudo_util so sudo_term_is_raw() can
use it.  Fixes GitHub issue #335
2023-12-09 12:54:56 -07:00
Todd C. Miller
24f443981f If sysconf(_SC_HOST_NAME_MAX) returns 0, just use 255.
This should not actually be possible.
2023-12-04 09:24:30 -07:00
THE-Spellchecker
5eba4b48cf Typographical and Grammatical fixes 2023-11-28 15:00:04 -07:00
Todd C. Miller
55db829087 No need to include sys/param.h here. 2023-11-26 09:28:40 -07:00
Todd C. Miller
be911b77dd Avoid using the u_int type, which is not portable. 2023-11-26 08:24:26 -07:00
Todd C. Miller
b9275b7eab Rename submit_time -> event_time in struct eventlog. 2023-11-23 09:08:04 -05:00
Todd C. Miller
a6ac589cc1 sudo_term_restore: don't check c_cflag on systems with TCSASOFT.
If TCSASOFT is present, tcsetattr() will ignore c_cflag.
Fixes a bug where sudo_term_restore() would refuse to change
the terminal settings back if the PARENB control flag was set.
GitHub issue #326.
2023-11-08 16:58:02 -07:00
Todd C. Miller
097bec06bd sudo_conf_debug_files: special handling of DSO members for AIX
When matching debug files for AIX-style DSOs like sudoers.a(sudoers.so)
we want to match on the full name, the name without the member and
on the member itself.  This makes it possible to use the existing
examples in the sudo.conf fiile on AIX.
2023-11-03 11:29:20 -06:00
Todd C. Miller
3bbc7c8f85 Store submitenv in eventlog and pass it to sudo_logsrvd. 2023-10-22 08:36:44 -06:00
Todd C. Miller
726b646b48 struct eventlog: rename argv/env to runargv/runenv.
This matches the JSON logs.
2023-10-21 19:15:46 -06:00
Todd C. Miller
8486976b9e iolog_swapids: short circuit if effective ids match iolog ids. 2023-10-19 16:22:42 -06:00
Todd C. Miller
09a4264372 logsrvd: display error string in message if iolog_mkpath() fails 2023-10-19 14:39:13 -06:00