157 import time
158 start = time.time()
159 TIMEOUT = self.runner.timeout*2
160 while True:
161 rfd, wfd, efd = select.select(rpipes, [], rpipes, 1)
162
163 # fail early if the sudo/su password is wrong
164 if self.runner.sudo and sudoable:
165 if self.runner.sudo_pass:
166 incorrect_password = gettext.dgettext(
167 "sudo", "Sorry, try again.")
168 if stdout.endswith("%s\r\n%s" % (incorrect_password,
169 prompt)):
170 raise errors.AnsibleError('Incorrect sudo password')
171
172 if stdout.endswith(prompt):
173 raise errors.AnsibleError('Missing sudo password')
174
176 incorrect_password = gettext.dgettext(
177 "su", "Sorry")
178 if stdout.endswith("%s\r\n%s" % (incorrect_password, prompt)):
179 raise errors.AnsibleError('Incorrect su password')
180
181 end = time.time()
182 if TIMEOUT <= (end - start):
183 raise errors.AnsibleError('Read ssh stdin timeout')