From cdd0862e43702f53552374f24666f9f8b33e86f7 Mon Sep 17 00:00:00 2001 From: Gavin Frazar Date: Sun, 6 Oct 2024 11:33:29 -0700 Subject: [PATCH 1/2] fix tsh logout flags --- tool/tsh/common/tsh.go | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/tool/tsh/common/tsh.go b/tool/tsh/common/tsh.go index a3f8013ecc055..d22200ef3efbe 100644 --- a/tool/tsh/common/tsh.go +++ b/tool/tsh/common/tsh.go @@ -1430,9 +1430,6 @@ func Run(ctx context.Context, args []string, opts ...CliOption) error { case login.FullCommand(): err = onLogin(&cf) case logout.FullCommand(): - if err := refuseArgs(logout.FullCommand(), args); err != nil { - return trace.Wrap(err) - } err = onLogout(&cf) case show.FullCommand(): err = onShow(&cf) @@ -4346,19 +4343,6 @@ func parseCertificateCompatibilityFlag(compatibility string, certificateFormat s } } -// refuseArgs helper makes sure that 'args' (list of CLI arguments) -// does not contain anything other than command -func refuseArgs(command string, args []string) error { - for _, arg := range args { - if arg == command || strings.HasPrefix(arg, "-") { - continue - } else { - return trace.BadParameter("unexpected argument: %s", arg) - } - } - return nil -} - // flattenIdentity reads an identity file and flattens it into a tsh profile on disk. func flattenIdentity(cf *CLIConf) error { // Save the identity file path for later From ff0de026c8de3cc4e1399404d979e8376ea65c0b Mon Sep 17 00:00:00 2001 From: Gavin Frazar Date: Mon, 7 Oct 2024 11:06:11 -0700 Subject: [PATCH 2/2] reword logout error message --- tool/tsh/common/tsh.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tool/tsh/common/tsh.go b/tool/tsh/common/tsh.go index d22200ef3efbe..73e13cc60747b 100644 --- a/tool/tsh/common/tsh.go +++ b/tool/tsh/common/tsh.go @@ -2192,9 +2192,10 @@ func onLogout(cf *CLIConf) error { } fmt.Printf("Logged out all users from all proxies.\n") - default: - fmt.Printf("Specify --proxy and --user to remove keys for specific user ") - fmt.Printf("from a proxy or neither to log out all users from all proxies.\n") + case proxyHost != "" && cf.Username == "": + fmt.Printf("Specify --user to log out a specific user from %q or remove the --proxy flag to log out all users from all proxies.\n", proxyHost) + case proxyHost == "" && cf.Username != "": + fmt.Printf("Specify --proxy to log out user %q from a specific proxy or remove the --user flag to log out all users from all proxies.\n", cf.Username) } return nil }