aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2020-04-16 13:08:41 -0400
committerJake Hunsaker <jhunsake@redhat.com>2020-04-22 10:58:15 -0400
commit41918a1598e66823c890e5422b8ebd543495b5d0 (patch)
tree4c865c7b3888ee21b6f315749b8492e5091a8596
parent5170c44b85b16a53504bd48ca150173955123910 (diff)
downloadsos-41918a1598e66823c890e5422b8ebd543495b5d0.tar.gz
[sosnode] Fix conflicts between password-per-node and sudo options
Under specific circumstances, we previously could end up prompting for SSH passwords for nodes that would then be overridden by --password-per-node, which in turn could potentially cause issues for use cases where sudo was used both locally and remotely where the sudo passwords differed (as indicated by password-per-node). Adjust prompting and setting of the sudo passwords so that we prompt the user the correct (minimal) amount of times, and the correct passwords are used for sudo usage (when needed). Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r--sos/collector/__init__.py7
-rw-r--r--sos/collector/sosnode.py2
2 files changed, 6 insertions, 3 deletions
diff --git a/sos/collector/__init__.py b/sos/collector/__init__.py
index 26b146cc..e8757621 100644
--- a/sos/collector/__init__.py
+++ b/sos/collector/__init__.py
@@ -591,8 +591,9 @@ class SoSCollector(SoSComponent):
'nodes unless the --password option is provided.\n')
self.ui_log.info(self._fmt_msg(msg))
- if ((self.opts.password or self.opts.password_per_node) and not
- self.opts.batch):
+ if ((self.opts.password or (self.opts.password_per_node and
+ self.opts.master))
+ and not self.opts.batch):
self.log_debug('password specified, not using SSH keys')
msg = ('Provide the SSH password for user %s: '
% self.opts.ssh_user)
@@ -600,7 +601,7 @@ class SoSCollector(SoSComponent):
if ((self.commons['need_sudo'] and not self.opts.nopasswd_sudo)
and not self.opts.batch):
- if not self.opts.password:
+ if not self.opts.password and not self.opts.password_per_node:
self.log_debug('non-root user specified, will request '
'sudo password')
msg = ('A non-root user has been provided. Provide sudo '
diff --git a/sos/collector/sosnode.py b/sos/collector/sosnode.py
index 398db303..4fef90a8 100644
--- a/sos/collector/sosnode.py
+++ b/sos/collector/sosnode.py
@@ -37,6 +37,8 @@ class SosNode():
self.cluster = None
self.hostname = None
self._password = password or self.opts.password
+ if not self.opts.nopasswd_sudo and not self.opts.sudo_pw:
+ self.opts.sudo_pw = self._password
# override local sudo from any other source
if local_sudo:
self.opts.sudo_pw = local_sudo