SUDOREPLAY(8)

๐Ÿ“ฆ version 1.9.17p2, in ubuntu questing, ubuntu resolute, ubuntu stonking

๐Ÿ’– sudoreplay ๐Ÿ’– (manual section 8: replay sudo session logs)

โœจ NAME โœจ

sudoreplay ๐ŸŽ€ replay sudo session logs

๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

sudoreplay [-FhnRS] [-d dir] [-f filter] [-m num] [-s num] ID[@offset]
sudoreplay [-h] [-d dir] -l [search expression]

๐ŸŒธ DESCRIPTION ๐ŸŒธ

okay so sudoreplay is the app that lets you replay or list the output logs sudo makes. when you're replaying, it can play the session back in real-time, or you can speed it up or slow it down with your command line options. so iconic ๐Ÿ”ฅ

the ID should be either a six character combo of digits and upper case letters, like โ€œ0100A5โ€, or a path name. the ID can also have an optional @offset suffix if you want to start replaying from a specific spot. the offset is a number of seconds since the session started, and it can have a decimal fraction. bestie, that's giving precision ๐Ÿงš

path names can be relative to the I/O log directory /var/log/sudo-io (unless you override it with the -d option), or fully qualified, which means they start with a / character. when a command runs through sudo with log_output turned on in the sudoers file, a TSID=ID string gets logged via syslog(3) or into the sudo log file. you can also figure out the ID using sudoreplay's list mode ๐Ÿ’…

in list mode, sudoreplay can hunt down the ID of a session based on stuff like the user, the tty, or the command that was run. main character energy ๐Ÿ‘‘

in replay mode, if standard input and output are connected to a terminal and you didn't pass -n, sudoreplay goes interactive ๐Ÿซถ in interactive mode it tries to resize your terminal to match the session and writes straight to the terminal (heads up, not every terminal supports this ๐Ÿ’€). it also keeps an eye on the keyboard and reacts to these keys:

  • \n or \r โ€” skip to the next replay event. super useful when there are long pauses ๐Ÿ˜ญ
  • ' ' (space) โ€” pause the output. press any key to resume โœจ
  • < โ€” cut the playback speed in half ๐Ÿ™ˆ
  • > โ€” double the playback speed ๐Ÿ”ฅ

you can interrupt the session with control-C. when it's finished, the terminal goes back to its original size if it got changed during playback. ngl that's very considerate of it ๐ŸŒˆ

๐ŸŽ€ OPTIONS ๐ŸŽ€

  • -d dir, --directory=dir โ€” store session logs in dir instead of the default, /var/log/sudo-io ๐Ÿ“
  • -f filter, --filter=filter โ€” pick which I/O type(s) to show. by default you get the command's standard output, standard error, and tty output. the filter is a comma-separated list made of one or more of these: stdin, stdout, stderr, ttyin, and ttyout ๐Ÿ’œ
  • -F, --follow โ€” turns on โ€œfollow modeโ€ ๐Ÿฆ‹ when you're replaying, sudoreplay ignores end-of-file and keeps going until the log is complete, kind of like tail -f. this is how you watch a session that's still happening live. an I/O log file counts as complete once the write bits get cleared on the session's timing file. heads up: sudo versions before 1.9.1 don't clear the write bits when they finish, so follow mode won't know when to stop with those ๐Ÿ™ˆ
  • -h, --help โ€” shows a short help message on standard output and exits ๐Ÿงš
  • -l, --list [search expression] โ€” turns on โ€œlist modeโ€ ๐Ÿ“‹ in this mode, sudoreplay lists the available sessions in a format similar to the sudo log file format, sorted by file name (or sequence number). any control characters in the log data get formatted in octal with a leading # character. so a horizontal tab shows up as #011 and an embedded carriage return shows up as #015. space characters in the command name and arguments get octal formatting too, so it's all very encoded ๐Ÿ’€

if you add a search expression, it restricts which IDs get displayed. an expression is built from these predicates:

  • command pattern โ€” true if the command run matches the POSIX extended regular expression pattern ๐Ÿ’…
  • cwd directory โ€” true if the command was run with the specified current working directory ๐ŸŒธ
  • fromdate date โ€” true if the command was run on or after date. see โ€œDate and time formatโ€ for the supported date and time formats โฐ
  • group runas_group โ€” true if the command was run with the specified runas_group. unless a runas_group was explicitly given when sudo ran, this field is empty in the log ๐Ÿซ 
  • host hostname โ€” true if the command was run on the specified hostname ๐ŸŒˆ
  • runas runas_user โ€” true if the command was run as the specified runas_user. by default sudo runs commands as the root user ๐Ÿ‘‘
  • todate date โ€” true if the command was run on or prior to date. see โ€œDate and time formatโ€ for the supported formats ๐Ÿ“
  • tty tty name โ€” true if the command was run on the specified terminal device. write the tty name without the /dev/ prefix, so tty01 instead of /dev/tty01 ๐ŸŽ€
  • user user name โ€” true if the ID matches a command run by user name ๐Ÿ’–

predicates can be abbreviated to the shortest unique string โœจ

you can combine predicates with the and, or, and ! operators, and group them with ( and ). parentheses usually need escaping from the shell. the and operator is optional, since adjacent predicates have an implied and unless you separate them with an or ๐Ÿง 

  • -m max_wait, --max-wait max_wait โ€” sets an upper bound on how long to wait between key presses or output data ๐Ÿฆ‹ by default, sudoreplay copies the delays between key presses or program output exactly. that can be super tedious when the session has long pauses, so with -m it caps those pauses at max_wait seconds. the value can be a floating point number, like 2.5. a max_wait of zero or less removes the pauses entirely ๐Ÿซถ
  • -n, --non-interactive โ€” no asking for user input and no attempts to resize the terminal ๐Ÿ™… the session gets written to standard output instead of straight to the user's terminal
  • -R, --no-resize โ€” don't try to resize the terminal to match the session's terminal size ๐Ÿ’…
  • -S, --suspend-wait โ€” wait while the command was suspended โณ by default, sudoreplay skips the time between when the command got suspended and when it resumed. if you pass -S, it waits through that gap instead ๐ŸŒ™
  • -s speed_factor, --speed speed_factor โ€” changes how many seconds sudoreplay waits between key presses or program output. use it to slow things down or speed them up ๐Ÿš€ for example, a speed_factor of 2 makes the output twice as fast, while a speed_factor of .5 makes it twice as slow ๐Ÿข
  • -V, --version โ€” prints sudoreplay's version number and exits ๐Ÿ”ข

๐Ÿ“ FILES ๐Ÿ“

okay bestie, these are the files sudoreplay cares about ๐Ÿ—‚๏ธโœจ

  • /etc/sudo.conf โ€” the config for sudo's debugging framework ๐Ÿ”ง
  • /var/log/sudo-io โ€” the default I/O log directory ๐Ÿ“‚๐Ÿ’–
  • /var/log/sudo-io/00/00/01/log โ€” example session log info ๐Ÿ“
  • /var/log/sudo-io/00/00/01/log.json โ€” example session log info, but in JSON format ๐Ÿงพ
  • /var/log/sudo-io/00/00/01/stdin โ€” an example session standard input log โŒจ๏ธ
  • /var/log/sudo-io/00/00/01/stdout โ€” an example session standard output log ๐Ÿ–จ๏ธ
  • /var/log/sudo-io/00/00/01/stderr โ€” an example session standard error log ๐Ÿšจ
  • /var/log/sudo-io/00/00/01/ttyin โ€” an example session tty input file ๐ŸŽน
  • /var/log/sudo-io/00/00/01/ttyout โ€” an example session tty output file ๐Ÿ“บ
  • /var/log/sudo-io/00/00/01/timing โ€” an example session timing file โฑ๏ธ
heads up ๐Ÿ™ˆ the stdin, stdout and stderr files will be empty unless sudo was used as part of a pipeline for a particular command. so if you're wondering why they look sad and blank, that's why ๐Ÿ’€

๐ŸŽ€ EXAMPLES ๐ŸŽ€

okay, the examples are where it all clicks ๐Ÿ’… let's go!

List sessions run by user millert:

# sudoreplay -l user millert

List sessions run by user bob with a command containing the string vi:

# sudoreplay -l user bob command vi

List sessions run by user jeff that match a regular expression:

# sudoreplay -l user jeff command '/bin/[a-z]*sh'

List sessions run by jeff or bob on the console:

# sudoreplay -l ( user jeff or user bob ) tty console

๐Ÿฆ‹ SEE ALSO ๐Ÿฆ‹

if you want more lore, go check out these bestie ๐Ÿ“š๐Ÿซถ

script(1), sudo.conf(5), sudo(8)


๐Ÿ‘‘ AUTHORS ๐Ÿ‘‘

so a lot of people have worked on sudo over the years ๐ŸŒˆ but this version is mostly the work of:

Todd C. Miller ๐Ÿ’–

for an exhaustive list of everyone who has contributed, check out the CONTRIBUTORS.md file in the sudo distribution, or https://www.sudo.ws/about/contributors/ โœจ


๐Ÿ™ˆ BUGS ๐Ÿ™ˆ

if you think you've found a bug in sudoreplay, you have two options: file a bug report in the sudo bug database at https://bugzilla.sudo.ws/, or open an issue at https://github.com/sudo-project/sudo/issues. ๐Ÿ›

prefer email? you can send messages to the sudo-workers mailing list at https://www.sudo.ws/mailman/listinfo/sudo-workers (public), or to <sudo@sudo.ws> (private) ๐Ÿ’Œ

bestie, pls pls pls ๐Ÿฅบ do not report security vulnerabilities through public GitHub issues, Bugzilla or mailing lists. instead, email them to <Todd.Miller@sudo.ws>. you can encrypt your message with PGP if you want, using the key found at https://www.sudo.ws/dist/PGPKEYS. security stuff stays safe that way ๐Ÿ”๐Ÿ’€

๐Ÿซง SUPPORT ๐Ÿซง

limited free support is available through the sudo-users mailing list. check https://www.sudo.ws/mailman/listinfo/sudo-users to subscribe or to search the archives ๐Ÿ“ฌโœจ


โš–๏ธ DISCLAIMER โš–๏ธ

sudoreplay is provided โ€œAS ISโ€ ๐Ÿซ  and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. for complete details, see the LICENSE.md file distributed with sudo, or https://www.sudo.ws/about/license/ ๐Ÿ“œ


bestie that's the whole page!! ๐ŸŽ€ we did it, you're officially a sudoreplay girlie now ๐Ÿ’…๐ŸŒธ the release info at the bottom is sudo 1.9.17p2 from January 16, 2023, and the man page itself is SUDOREPLAY(8) ๐Ÿงš๐Ÿ’œ

๐Ÿ“ฆ where this page comes from