From 9eeedb470f03f7753d202aa5fe54df5d10c0691c Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 27 Aug 2019 13:40:38 -0600 Subject: [PATCH] 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. --- doc/sudoreplay.man.in | 17 +++++++++++++---- doc/sudoreplay.mdoc.in | 17 +++++++++++++---- plugins/sudoers/sudoreplay.c | 11 +++++++---- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/doc/sudoreplay.man.in b/doc/sudoreplay.man.in index bb6726f92..bfc1197a0 100644 --- a/doc/sudoreplay.man.in +++ b/doc/sudoreplay.man.in @@ -2,7 +2,7 @@ .\" .\" SPDX-License-Identifier: ISC .\" -.\" Copyright (c) 2009-2018 Todd C. Miller +.\" Copyright (c) 2009-2019 Todd C. Miller .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above @@ -16,7 +16,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.TH "SUDOREPLAY" "@mansectsu@" "October 6, 2018" "Sudo @PACKAGE_VERSION@" "System Manager's Manual" +.TH "SUDOREPLAY" "@mansectsu@" "August 27, 2019" "Sudo @PACKAGE_VERSION@" "System Manager's Manual" .nh .if n .ad l .SH "NAME" @@ -51,11 +51,20 @@ The should either be a six character sequence of digits and upper case letters, e.g., \fR0100A5\fR, -or a pattern matching the +a pattern matching the \fIiolog_file\fR option in the \fIsudoers\fR -file. +file, or a path name. +Path names may be relative to the +\fIiolog_dir\fR +option in the +\fIsudoers\fR +file (unless overridden by the +\fB\-d\fR +option) or fully qualified, beginning with a +\(oq/\(cq +character. When a command is run via \fBsudo\fR with diff --git a/doc/sudoreplay.mdoc.in b/doc/sudoreplay.mdoc.in index 2642e82bd..45376cd5b 100644 --- a/doc/sudoreplay.mdoc.in +++ b/doc/sudoreplay.mdoc.in @@ -1,7 +1,7 @@ .\" .\" SPDX-License-Identifier: ISC .\" -.\" Copyright (c) 2009-2018 Todd C. Miller +.\" Copyright (c) 2009-2019 Todd C. Miller .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd October 6, 2018 +.Dd August 27, 2019 .Dt SUDOREPLAY @mansectsu@ .Os Sudo @PACKAGE_VERSION@ .Sh NAME @@ -49,11 +49,20 @@ The should either be a six character sequence of digits and upper case letters, e.g., .Li 0100A5 , -or a pattern matching the +a pattern matching the .Em iolog_file option in the .Em sudoers -file. +file, or a path name. +Path names may be relative to the +.Em iolog_dir +option in the +.Em sudoers +file (unless overridden by the +.Fl d +option) or fully qualified, beginning with a +.Ql / +character. When a command is run via .Nm sudo with diff --git a/plugins/sudoers/sudoreplay.c b/plugins/sudoers/sudoreplay.c index f4bf89012..5c2e0d233 100644 --- a/plugins/sudoers/sudoreplay.c +++ b/plugins/sudoers/sudoreplay.c @@ -320,12 +320,15 @@ main(int argc, char *argv[]) if (plen < 0 || plen >= ssizeof(path)) sudo_fatalx(U_("%s/%.2s/%.2s/%.2s/timing: %s"), session_dir, id, &id[2], &id[4], strerror(ENAMETOOLONG)); + } else if (id[0] == '/') { + plen = snprintf(path, sizeof(path), "%s/timing", id); + if (plen < 0 || plen >= ssizeof(path)) + sudo_fatalx(U_("%s/timing: %s"), id, strerror(ENAMETOOLONG)); } else { - plen = snprintf(path, sizeof(path), "%s/%s/timing", - session_dir, id); + plen = snprintf(path, sizeof(path), "%s/%s/timing", session_dir, id); if (plen < 0 || plen >= ssizeof(path)) - sudo_fatalx(U_("%s/%s/timing: %s"), session_dir, - id, strerror(ENAMETOOLONG)); + sudo_fatalx(U_("%s/%s/timing: %s"), session_dir, id, + strerror(ENAMETOOLONG)); } plen -= 7; -- 2.50.1