225 Commits

Author SHA1 Message Date
Todd C. Miller
d17e28ad61 setup_terminal: fix an editing error introduced in 1.9.15. 2023-12-07 07:27:06 -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
4833ac0f01 Avoid passing sudo_term_is_raw() -1 for the fd.
Coverity CID 330472
Coverity CID 330468
2023-11-02 14:17:51 -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
Rose
e095069d2a Prefer fputs over fprintf where possible
fprintf does extra work and meant for formatting strings.
2023-10-15 10:28:57 -06: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
c6987aa26e Cast int to size_t before adding instead of casting the result.
Quiets PVS-Studio warning V1028.
2023-08-21 12:50:31 -06:00
Todd C. Miller
625653de08 sudo_term_raw: change the isig argument into a flags field
There are current two flags: SUDO_TERM_ISIG (enable terminal signals)
and SUDO_TERM_OFLAG (preserve output flags).
2023-07-14 13:12:51 -06:00
Todd C. Miller
a38b714667 sudoers plugin: silence most -Wconversion warnings. 2023-07-07 15:07:04 -06:00
Todd C. Miller
2848dddd87 Rename print_usage() to display_usage() 2023-07-04 19:48:41 -06:00
Rose
22079c3072 Avoid compiler casting warnings Part 2
This saves instructions that are related to casting as well as compiler warnings.
2023-06-29 13:10:27 -04:00
Rose
e54ba33ea0 Avoid compiler casting warnings by assigning to the same type where possible
This saves instructions that are related to casting as well as compiler warnings.
2023-06-28 17:25:26 -04:00
Todd C. Miller
cc22cca34f Add an fd argument to sudo_get_ttysize() instead of always using stderr.
For sudoreplay we open /dev/tty, so use that instead of stderr when
determining the terminal size.
2023-04-16 15:45:19 -06:00
Todd C. Miller
2d9c0d9034 Add eventlog_store_sudo() and use it in sudoreplay.
This replaces the custom log formatting used by "sudoreplay -l".
2023-01-22 15:27:53 -07:00
Todd C. Miller
334daf92b3 Escape control characters in log messages and "sudoreplay -l" output.
The log message contains user-controlled strings that could include
things like terminal control characters.  Space characters in the
command path are now also escaped.

Command line arguments that contain spaces are surrounded with
single quotes and any literal single quote or backslash characters
are escaped with a backslash.  This makes it possible to distinguish
multiple command line arguments from a single argument that contains
spaces.

Issue found by Matthieu Barjole and Victor Cutillas of Synacktiv
(https://synacktiv.com).
2023-01-18 08:21:34 -07:00
Todd C. Miller
1f58e5a8e0 Fix IS_IDLOG macro, it was testing the wrong byte for the NUL.
This causes the macro to evaluate to false even for valid TSIDs.
2023-01-09 13:03:55 -07:00
Todd C. Miller
e707ffe58b Place C23 attributes before keywords in function declarations.
In practice this means we must use "sudo_noreturn static foo(void)"
instead of "static sudo_noreturn foo(void)".
2022-12-01 12:54:53 -07:00
Todd C. Miller
304726a215 Move gcc-style __attribute__ macros to config.h.in
Renamed __malloc -> sudo_malloclike, __printflike -> sudo_printflike,
__printf0like -> sudo_printf0like.
Add sudo_noreturn instead of __attribute__((__noreturn__)).
We do not use stdnoreturn.h since it has been deprecated in C23
in favor of the [[noreturn]] attribute.
2022-09-07 07:48:31 -06:00
Todd C. Miller
13672f28df Make sudo pass -Wwrite-strings 2022-06-28 16:33:15 -06:00
Todd C. Miller
7c17f84a35 Add helper function to compile a regex that supports (?i). 2022-02-11 12:01:31 -07:00
Todd C. Miller
4e4b506f22 Sync "sudo -l" output with normal sudo log format.
It now prints runchroot and runcwd (falling back on cwd).
As a result, submithost is now printed first, matching sudo.
Also avoid printing NULL pointers and skip entries that don't have
at least command, submituser and runuser set.
2021-10-01 10:33:55 -06:00
Todd C. Miller
70aef0eb2d sudo_debug_register: add minfd argument to specify lowest fd number
Use this in sudo_intercept.so to avoid allocating a low-numbered
fd which the shell reserves for use by scripts.
2021-08-26 09:57:24 -06:00
Todd C. Miller
695f4bea05 Add support for an optional offset when parsing the ID to replay.
The offset is a suffix in the form of @sec[.nanosec]
2021-08-13 16:00:00 -06:00
Todd C. Miller
db72498257 Use struct eventlog in place of struct iolog_info. 2020-10-26 15:31:41 -06:00
Todd C. Miller
961a4afe67 Fix some warnings from pvs-studio 2020-08-12 13:45:09 -06:00
Todd C. Miller
cbad17a994 Move inclusion of compat headers up with the system headers.
Now that sudo_dso_public is defined in config.h we don't need sudo_compat.h
before including the compat headers.
2020-08-12 10:07:07 -06:00
Todd C. Miller
985af422d2 Rename __dso_public -> sudo_dso_public and move to config.h. 2020-08-12 09:57:42 -06:00
Todd C. Miller
076d0376db We no longer need to include sudo_gettext.h before sudo_compat.h 2020-08-12 09:50:35 -06:00
Todd C. Miller
03ad96e445 Use the fallthrough attribute instead of /* FALLTHROUGH */ comments. 2020-08-01 13:10:50 -06:00
Todd C. Miller
452be1a4c5 Add a follow option (-F) to support replaying a live session.
By default, sudoreplay will exit when it reaches the end of the
timing file.  With the -F option, it will keep going until the
timing file is finished and its write bit is cleared.
2020-05-18 14:27:47 -06:00
Todd C. Miller
446ae3f507 Include string.h unconditionally and only use strings.h for strn?casecmp()
In the pre-POSIX days BSD had strings.h, not string.h.
Now strings.h is only used for non-ANSI string functions.
2020-05-18 07:59:24 -06:00
Todd C. Miller
dd88460800 We no longer need to include headers we don't use for sudo*.h files.
Previously we needed to include headers required by the various
sudo*h files.  Now those files are more self-sufficient and we
should only include headers needed by code in the various .c files.
2020-05-18 06:47:04 -06:00
Todd C. Miller
fbf25112e6 Remove duplicate inclusion of time.h 2020-05-11 08:46:58 -06:00
Todd C. Miller
056173e572 Parse I/O JSON info file in JSON if present.
The JSON version includes more information than the original "log"
file in the I/O log dir.
2020-03-29 05:05:08 -06:00
Todd C. Miller
ea9b711a70 Write an extended I/O info log in JSON format.
This will be used by sudoreplay if it exists to get more information
about the command being replayed.
2020-03-29 05:05:08 -06:00
Todd C. Miller
a644c1d1d2 iolog_parse_loginfo() now opens the log file itself. 2020-03-29 05:05:08 -06:00
Todd C. Miller
ac61b5655d Use EXIT_SUCCESS and EXIT_FAILURE more consistently. 2020-02-08 12:43:00 -07:00
Todd C. Miller
486ee2b71f debug_decl and debug_decl_vars now require a semicolon at the end. 2019-12-22 08:48:16 -07:00
Todd C. Miller
bf3b93f080 Use sudo_ev_pending() instead of the deprecated sudo_ev_timeleft(). 2019-12-07 08:42:09 -07:00
Todd C. Miller
56c21243d7 Add iolog_ prefix to exported functions in iolog_util.c 2019-10-24 20:04:33 -06:00
Todd C. Miller
b58ecb7e6d Move read_timing_record() into libsudo_iolog 2019-10-24 20:04:32 -06:00
Todd C. Miller
282263c113 Use openat(2) when opening files in the I/O log directory. 2019-10-24 20:04:31 -06:00
Todd C. Miller
059b55ce72 Refactor code in sudoers that creates I/O log files to share with logsrvd. 2019-10-24 20:04:31 -06:00
Todd C. Miller
4dacf81082 Refactor I/O log code so it can be shared between sudoers and logsrvd 2019-10-24 20:04:29 -06:00
Todd C. Miller
9eeedb470f If the sudoreplay ID option is a fully-qualified path, use it directly.
Previously, one had to use the -d option to override the I/O log directory.
2019-08-27 13:40:38 -06:00
Todd C. Miller
2087f6354c Use fputs(), not printf() for plain strings. 2019-08-20 12:43:40 -06:00
Todd C. Miller
9d8f374397 Add ssizeof macro that returns ssize_t.
We can use this instead of casting the result of size_t to int.
Also change checks for snprintf() returning <=0 to <0.
2019-06-25 09:45:10 -06:00
Todd C. Miller
1e1ef61902 Add SPDX-License-Identifier to files. 2019-04-29 07:21:51 -06:00
Todd C. Miller
985600e7f0 Minor snprintf() usage tweaks:
1) don't assume snprintf() returns -1 on error, check for <0
2) when comparing return value of sizeof(foo), cast the sizeof, not the len
3) cast return value to void in cases where snprintf cannot fail
2019-01-20 07:49:48 -07:00
Todd C. Miller
72050203bc Add -n and -R options to help; reported by Radovan Sroka 2018-12-11 09:17:15 -07:00