Skip to content

Commit

Permalink
Improve admin workstation updater GUI error handling
Browse files Browse the repository at this point in the history
Increase the time it will wait for tailsconfig to run.

Don't say the admin password was wrong on tailsconfig
timeout. Instead, look for sudo in the output to determine if an
incorrect password was given.

Add a new message explaining that tailsconfig took too long, and don't
say "Exiting upgrade" when an incorrect admin password was given, as
the updater is not exiting, and in fact we're telling the admin to try
again.

Make sure the failure reason was cleared on each attempt.
  • Loading branch information
rmol committed Mar 20, 2020
1 parent 4e75864 commit 734c07b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
11 changes: 7 additions & 4 deletions journalist_gui/journalist_gui/SecureDropUpdater.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,26 +128,29 @@ def run(self):
tailsconfig_command = ("/home/amnesia/Persistent/"
"securedrop/securedrop-admin "
"tailsconfig")
self.failure_reason = ""
try:
child = pexpect.spawn(tailsconfig_command)
child.expect('SUDO password:')
self.output += child.before.decode('utf-8')
child.sendline(self.sudo_password)
child.expect(pexpect.EOF)
child.expect(pexpect.EOF, timeout=120)
self.output += child.before.decode('utf-8')
child.close()

# For Tailsconfig to be considered a success, we expect no
# failures in the Ansible output.
if child.exitstatus:
self.update_success = False
self.failure_reason = strings.tailsconfig_failed_generic_reason # noqa
if "[sudo via ansible" in self.output:
self.failure_reason = strings.tailsconfig_failed_sudo_password
else:
self.failure_reason = strings.tailsconfig_failed_generic_reason
else:
self.update_success = True
except pexpect.exceptions.TIMEOUT:
self.update_success = False
self.failure_reason = strings.tailsconfig_failed_sudo_password

self.failure_reason = strings.tailsconfig_failed_timeout
except subprocess.CalledProcessError:
self.update_success = False
self.failure_reason = strings.tailsconfig_failed_generic_reason
Expand Down
7 changes: 5 additions & 2 deletions journalist_gui/journalist_gui/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@
"Contact your SecureDrop administrator "
"or [email protected] immediately.")
tailsconfig_failed_sudo_password = ('Administrator password incorrect. '
'Exiting upgrade - '
'click Update Now to try again.')
'Click Update Now to try again.')
tailsconfig_failed_generic_reason = ("Tails workstation configuration failed. "
"Contact your administrator. "
"If you are an administrator, contact "
"[email protected].")
tailsconfig_failed_timeout = ("Tails workstation configuration took too long. "
"Contact your administrator. "
"If you are an administrator, contact "
"[email protected].")
install_update_button = 'Update Now'
install_later_button = 'Update Later'
sudo_password_text = ("Enter the Tails Administrator password you "
Expand Down

0 comments on commit 734c07b

Please sign in to comment.