Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repair auto-updates on Tails < 4.19 workstations #6110

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import sys
import subprocess

from shutil import copyfile
import tempfile
from shutil import copyfile, copyfileobj


# check for root
Expand Down Expand Up @@ -148,3 +149,70 @@
if b'Update needed' in output or os.path.exists(flag_location):
# Start the SecureDrop updater GUI.
subprocess.Popen(['python3', path_gui_updater], env=env)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zenmonkeykstop observed this morning that the invocation of the SecureDrop updater here, before the new logic that follows checks for a Tails upgrade, means that we will be able to update this logic in a future SecureDrop release in the event that it breaks under a future Tails version. (That's a mouthful, but I hope it's a clear statement of the solution to a risk we've worried about!)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and it's also my hope that we can remove this entire section after a reasonable timeframe (I've suggested Jan 2022 in the comments)


# Check for Tails < 4.19 and apply a fix to the auto-updater.
# See https://tails.boum.org/news/version_4.18/
# (Suggested removal: 2022/01)
tails_4_min_version = 19
needs_update = False
tails_current_version = None

with open('/etc/os-release') as file:
for line in file:
try:
k, v = line.strip().split("=")
if k == "TAILS_VERSION_ID":
tails_current_version = v.strip("\"").split(".")
except ValueError:
continue

if tails_current_version:
try:
needs_update = (len(tails_current_version) >= 2 and
int(tails_current_version[1]) < tails_4_min_version)

except (TypeError, ValueError):
sys.exit(0) # Don't break tailsconfig trying to fix this

if needs_update:
cert_name = 'isrg-root-x1-cross-signed.pem'
pem_file = tempfile.NamedTemporaryFile(delete=True)
cfm marked this conversation as resolved.
Show resolved Hide resolved

try:
subprocess.call(['torsocks', 'curl', '--silent',
'https://tails.boum.org/' + cert_name],
stdout=pem_file, env=env)

# Verify against /etc/ssl/certs/DST_Root_CA_X3.pem, which cross-signs
# the new LetsEncrypt cert but is expiring
verify_proc = subprocess.check_output(['openssl', 'verify',
'-no_check_time', '-no-CApath',
'-CAfile',
'/etc/ssl/certs/DST_Root_CA_X3.pem',
pem_file.name],
universal_newlines=True, env=env)

if 'OK' in verify_proc:
cfm marked this conversation as resolved.
Show resolved Hide resolved

# Updating the cert chain requires sudo privileges
os.setresgid(0, 0, -1)
os.setresuid(0, 0, -1)

with open('/usr/local/etc/ssl/certs/tails.boum.org-CA.pem', 'a') as chain:
pem_file.seek(0)
copyfileobj(pem_file, chain)

# As amnesia user, start updater GUI
os.setresgid(amnesia_gid, amnesia_gid, -1)
os.setresuid(amnesia_uid, amnesia_uid, -1)
restart_proc = subprocess.call(['systemctl', '--user', 'restart',
'tails-upgrade-frontend'], env=env)

except subprocess.CalledProcessError:
sys.exit(0) # Don't break tailsconfig trying to fix this

except IOError:
sys.exit(0)

finally:
pem_file.close()