static int stack_top;
extern void *emalloc __P((size_t));
+extern void *emalloc2 __P((size_t, size_t));
extern void *erealloc __P((void *, size_t));
extern void efree __P((void *));
extern time_t get_date __P((char *));
static int list_sessions __P((int, char **, const char *, const char *, const char *));
static int parse_expr __P((struct search_node **, char **));
+static void check_input __P((int, double *));
static void delay __P((double));
static void usage __P((void));
int argc;
char **argv;
{
- int ch, plen, listonly = 0;
+ int ch, plen, ttyfd, interactive = 0, listonly = 0;
const char *id, *user = NULL, *pattern = NULL, *tty = NULL;
char path[PATH_MAX], buf[LINE_MAX], *cp, *ep;
FILE *tfile, *sfile, *lfile;
sigaction_t sa;
- double seconds;
unsigned long nbytes;
size_t len, nread;
ssize_t nwritten;
+ double seconds;
double speed = 1.0;
double max_wait = 0;
double to_wait;
sa.sa_handler = SIG_IGN;
(void) sigaction(SIGTSTP, &sa, NULL);
(void) sigaction(SIGQUIT, &sa, NULL);
- term_cbreak(STDOUT_FILENO);
+
+ ttyfd = open(_PATH_TTY, O_RDWR|O_NOCTTY, 0);
+ if (ttyfd != -1) {
+ term_cbreak(ttyfd);
+ interactive = isatty(STDOUT_FILENO);
+ }
/*
* Timing file consists of line of the format: "%f %d\n"
if (errno == ERANGE && nbytes == ULONG_MAX)
error(1, "invalid timing file byte count: %s", cp);
+ if (interactive)
+ check_input(ttyfd, &speed);
+
/* Adjust delay using speed factor and clamp to max_wait */
to_wait = seconds / speed;
if (max_wait && to_wait > max_wait)
return(0);
}
+/*
+ * Check input for ' ', '<', '>'
+ * pause, slow, fast
+ */
+static void
+check_input(ttyfd, speed)
+ int ttyfd;
+ double *speed;
+{
+ fd_set *fdsr;
+ int flags, nready;
+ struct timeval tv;
+ char ch;
+ ssize_t n;
+
+ fdsr = (fd_set *)emalloc2(howmany(ttyfd + 1, NFDBITS), sizeof(fd_mask));
+ FD_SET(ttyfd, fdsr);
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+
+ nready = select(ttyfd + 1, fdsr, NULL, NULL, &tv);
+ if (nready == 1) {
+ flags = fcntl(ttyfd, F_GETFL, 0);
+ if (flags != -1)
+ (void) fcntl(ttyfd, F_SETFL, flags | O_NONBLOCK);
+ do {
+ n = read(ttyfd, &ch, 1);
+ if (n == 1) {
+ switch (ch) {
+ case ' ':
+ /* wait for another character */
+ if (flags != -1)
+ (void) fcntl(ttyfd, F_SETFL, flags);
+ n = read(ttyfd, &ch, 1);
+ if (flags != -1)
+ (void) fcntl(ttyfd, F_SETFL, flags | O_NONBLOCK);
+ break;
+ case '<':
+ *speed /= 2;
+ break;
+ case '>':
+ *speed *= 2;
+ break;
+ }
+ }
+ } while (n == 1);
+ if (flags != -1)
+ (void) fcntl(ttyfd, F_SETFL, flags);
+ }
+ free(fdsr);
+}
+
static void
usage()
{
In list mode, s\bsu\bud\bdo\bor\bre\bep\bpl\bla\bay\by can be used to find the ID of a session based
on a number of criteria such as the user, tty or command run.
+ In replay mode, if the standard output has not been redirected,
+ s\bsu\bud\bdo\bor\bre\bep\bpl\bla\bay\by will act on the following keys:
+
+ ' ' (space)
+ Pause output; press any key to resume.
+
+ '<' Reduce the playback speed by one half.
+
+ '>' Double the playback speed.
+
O\bOP\bPT\bTI\bIO\bON\bNS\bS
s\bsu\bud\bdo\bor\bre\bep\bpl\bla\bay\by accepts the following command line options:
Evaluates to true if the command was run with the
specified current working directory.
- fromdate _\bd_\ba_\bt_\be
- Evaluates to true if the command was run on or
- after _\bd_\ba_\bt_\be. See "Date and time format" for a
- description of supported date and time formats.
-
- group _\br_\bu_\bn_\ba_\bs_\b__\bg_\br_\bo_\bu_\bp
- Evaluates to true if the command was run with the
- specified _\br_\bu_\bn_\ba_\bs_\b__\bg_\br_\bo_\bu_\bp. Note that unless a
- _\br_\bu_\bn_\ba_\bs_\b__\bg_\br_\bo_\bu_\bp was explicitly specified when s\bsu\bud\bdo\bo was
- run this field will be empty in the log.
-1.7.2 September 19, 2009 1
+1.7.2 October 6, 2009 1
SUDOREPLAY(1m) MAINTENANCE COMMANDS SUDOREPLAY(1m)
+ fromdate _\bd_\ba_\bt_\be
+ Evaluates to true if the command was run on or
+ after _\bd_\ba_\bt_\be. See "Date and time format" for a
+ description of supported date and time formats.
+
+ group _\br_\bu_\bn_\ba_\bs_\b__\bg_\br_\bo_\bu_\bp
+ Evaluates to true if the command was run with the
+ specified _\br_\bu_\bn_\ba_\bs_\b__\bg_\br_\bo_\bu_\bp. Note that unless a
+ _\br_\bu_\bn_\ba_\bs_\b__\bg_\br_\bo_\bu_\bp was explicitly specified when s\bsu\bud\bdo\bo was
+ run this field will be empty in the log.
+
runas _\br_\bu_\bn_\ba_\bs_\b__\bu_\bs_\be_\br
Evaluates to true if the command was run as the
specified _\br_\bu_\bn_\ba_\bs_\b__\bu_\bs_\be_\br. Note that s\bsu\bud\bdo\bo runs commands
seconds it will wait between key presses or program output.
This can be used to slow down or speed up the display. For
example, a _\bs_\bp_\be_\be_\bd_\b__\bf_\ba_\bc_\bt_\bo_\br of _\b2 would make the output twice as
- fast whereas a _\bs_\bp_\be_\be_\bd_\b__\bf_\ba_\bc_\bt_\bo_\br of <.5> would make the output
- twice as slow.
-
- -V The -\b-V\bV (version) option causes s\bsu\bud\bdo\bor\bre\bep\bpl\bla\bay\by to print its
- version number and exit.
- D\bDa\bat\bte\be a\ban\bnd\bd t\bti\bim\bme\be f\bfo\bor\brm\bma\bat\bt
- The time and date may be specified multiple ways, common formats
- include:
+1.7.2 October 6, 2009 2
-1.7.2 September 19, 2009 2
+SUDOREPLAY(1m) MAINTENANCE COMMANDS SUDOREPLAY(1m)
+ fast whereas a _\bs_\bp_\be_\be_\bd_\b__\bf_\ba_\bc_\bt_\bo_\br of <.5> would make the output
+ twice as slow.
-SUDOREPLAY(1m) MAINTENANCE COMMANDS SUDOREPLAY(1m)
+ -V The -\b-V\bV (version) option causes s\bsu\bud\bdo\bor\bre\bep\bpl\bla\bay\by to print its
+ version number and exit.
+ D\bDa\bat\bte\be a\ban\bnd\bd t\bti\bim\bme\be f\bfo\bor\brm\bma\bat\bt
+ The time and date may be specified multiple ways, common formats
+ include:
HH:MM:SS am MM/DD/CCYY timezone
24 hour time may be used in place of am/pm.
10:01 am 9/17/2009
10:01 am, September 17, 2009.
- 10:01 am
- 10:01 am on the current day.
-
- 10 10:00 am on the current day.
- 9/17/2009
- 00:00 am, September 17, 2009.
+1.7.2 October 6, 2009 3
-1.7.2 September 19, 2009 3
-
+SUDOREPLAY(1m) MAINTENANCE COMMANDS SUDOREPLAY(1m)
+ 10:01 am
+ 10:01 am on the current day.
-SUDOREPLAY(1m) MAINTENANCE COMMANDS SUDOREPLAY(1m)
+ 10 10:00 am on the current day.
+ 9/17/2009
+ 00:00 am, September 17, 2009.
10:01 am Sep 17, 2009
10:01 am, September 17, 2009.
http://www.sudo.ws/mailman/listinfo/sudo-users to subscribe or search
the archives.
+
+
+1.7.2 October 6, 2009 4
+
+
+
+
+
+SUDOREPLAY(1m) MAINTENANCE COMMANDS SUDOREPLAY(1m)
+
+
D\bDI\bIS\bSC\bCL\bLA\bAI\bIM\bME\bER\bR
s\bsu\bud\bdo\bor\bre\bep\bpl\bla\bay\by is provided ``AS IS'' and any express or implied warranties,
including, but not limited to, the implied warranties of
-1.7.2 September 19, 2009 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1.7.2 October 6, 2009 5
.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $Sudo$
-.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05)
+.\" Automatically generated by Pod::Man 2.22 (Pod::Simple 3.07)
.\"
.\" Standard preamble:
.\" ========================================================================
-.de Sh \" Subsection heading
-.br
-.if t .Sp
-.ne 5
-.PP
-\fB\\$1\fR
-.PP
-..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
.el .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
-.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
+.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.ie \nF \{\
.\" ========================================================================
.\"
.IX Title "SUDOREPLAY @mansectsu@"
-.TH SUDOREPLAY @mansectsu@ "September 19, 2009" "1.7.2" "MAINTENANCE COMMANDS"
+.TH SUDOREPLAY @mansectsu@ "October 6, 2009" "1.7.2" "MAINTENANCE COMMANDS"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.PP
In list mode, \fBsudoreplay\fR can be used to find the \s-1ID\s0 of a session
based on a number of criteria such as the user, tty or command run.
+.PP
+In replay mode, if the standard output has not been redirected,
+\&\fBsudoreplay\fR will act on the following keys:
+.IP "' ' (space)" 8
+.IX Item "' ' (space)"
+Pause output; press any key to resume.
+.IP "'<'" 8
+Reduce the playback speed by one half.
+.IP "'>'" 8
+Double the playback speed.
.SH "OPTIONS"
.IX Header "OPTIONS"
\&\fBsudoreplay\fR accepts the following command line options:
.IX Item "-V"
The \fB\-V\fR (version) option causes \fBsudoreplay\fR to print its version number
and exit.
-.Sh "Date and time format"
+.SS "Date and time format"
.IX Subsection "Date and time format"
The time and date may be specified multiple ways, common formats include:
.IP "\s-1HH:MM:SS\s0 am \s-1MM/DD/CCYY\s0 timezone" 8
In list mode, B<sudoreplay> can be used to find the ID of a session
based on a number of criteria such as the user, tty or command run.
+In replay mode, if the standard output has not been redirected,
+B<sudoreplay> will act on the following keys:
+
+=over 8
+
+=item ' ' (space)
+
+Pause output; press any key to resume.
+
+=item '<'
+
+Reduce the playback speed by one half.
+
+=item '>'
+
+Double the playback speed.
+
+=back
+
=head1 OPTIONS
B<sudoreplay> accepts the following command line options: