From b1a5a4a0a3c9008d51411d986d3463fc01e101ec Mon Sep 17 00:00:00 2001 From: Jose Castillo Date: Fri, 15 Nov 2024 22:15:11 +0000 Subject: [PATCH] [collect] Fix exception when using collect with batch and password Using --batch --password together in sos-collect leads to an error: Unable to open remote session: unsupported operand type(s) for +: 'bool' and 'str' This commit adds a check for both options running at the same time and if so, prints a message and exits. Also, the commit changes the man page to reflect this restriction. Related: #3839 Signed-off-by: Jose Castillo --- man/en/sos-collect.1 | 3 +-- sos/collector/__init__.py | 8 ++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/man/en/sos-collect.1 b/man/en/sos-collect.1 index ba083f3724..e3100bfc86 100644 --- a/man/en/sos-collect.1 +++ b/man/en/sos-collect.1 @@ -74,8 +74,7 @@ This does NOT enable all sos collect options. Become the root user on the remote node when connecting as a non-root user. .TP \fB\-\-batch\fR -Run in non-interactive mode. This will skip prompts for user input, with the -exception of a prompt for the SSH password. +Run in non-interactive mode. This will skip prompts for user input. .TP \fB\-\-all\-logs\fR Report option. Collects all logs regardless of size. diff --git a/sos/collector/__init__.py b/sos/collector/__init__.py index 5eeba25702..d66b0ec547 100644 --- a/sos/collector/__init__.py +++ b/sos/collector/__init__.py @@ -1194,6 +1194,14 @@ def execute(self): self.intro() + if self.opts.batch and self.opts.password: + self.exit( + "\nsos-collector was called with incompatible options --batch " + "and --password.\nIf you need to use --password," + " please omit batch mode.\n", + 1 + ) + self.configure_sos_cmd() self.prep() self.display_nodes()