From 5cfd0f82a052e9cfb28e3f4e06da264fda22ab06 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 17 Jun 2015 23:18:43 -0400 Subject: [PATCH] moved away from generic function for become --- lib/ansible/plugins/connections/__init__.py | 56 --------------------- 1 file changed, 56 deletions(-) diff --git a/lib/ansible/plugins/connections/__init__.py b/lib/ansible/plugins/connections/__init__.py index 01a3496b5c6..629c90d8d7e 100644 --- a/lib/ansible/plugins/connections/__init__.py +++ b/lib/ansible/plugins/connections/__init__.py @@ -142,59 +142,3 @@ class ConnectionBase(with_metaclass(ABCMeta, object)): if incorrect_password in output: raise AnsibleError('Incorrect %s password' % self._connection_info.become_method) - def handle_become_password(self, p, stdin): - ''' - Several cases are handled for privileges with password - * NOPASSWD (tty & no-tty): detect success_key on stdout - * without NOPASSWD: - * detect prompt on stdout (tty) - * detect prompt on stderr (no-tty) - ''' - - out = '' - err = '' - - debug("Handling privilege escalation password prompt.") - - if self._connection_info.become and self._connection_info.become_pass: - - fcntl.fcntl(p.stdout, fcntl.F_SETFL, fcntl.fcntl(p.stdout, fcntl.F_GETFL) | os.O_NONBLOCK) - fcntl.fcntl(p.stderr, fcntl.F_SETFL, fcntl.fcntl(p.stderr, fcntl.F_GETFL) | os.O_NONBLOCK) - - become_output = '' - become_errput = '' - while True: - debug('Waiting for Privilege Escalation input') - if self.check_become_success(become_output) or \ - self.check_password_prompt(become_output): - break - - rfd, wfd, efd = select.select([p.stdout, p.stderr], [], [p.stdout], self._connection_info.timeout) - if p.stderr in rfd: - chunk = p.stderr.read() - if not chunk: - raise AnsibleError('Connection closed waiting for privilege escalation password prompt: %s ' % become_output) - become_errput += chunk - - self.check_incorrect_password(become_errput) - - if p.stdout in rfd: - chunk = p.stdout.read() - if not chunk: - raise AnsibleError('Connection closed waiting for privilege escalation password prompt: %s ' % become_output) - become_output += chunk - - if not rfd: - # timeout. wrap up process communication - stdout, stderr = p.communicate() - raise AnsibleError('Connection error waiting for privilege escalation password prompt: %s' % become_output) - - if not self.check_become_success(become_output): - debug("Sending privilege escalation password.") - stdin.write(self._connection_info.become_pass + '\n') - else: - out += become_output - err += become_errput - - return out, err -