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

[xenial] Updated release-upgrades Prompt for Trusty, Xenial as appropriate #4116

Merged
merged 5 commits into from
Feb 15, 2019
Merged
Show file tree
Hide file tree
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
49 changes: 45 additions & 4 deletions install_files/securedrop-config/DEBIAN/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,51 @@
set -e
set -x

disable_upgrade_prompt() {
# Disable do-release-upgrade notification
sed -i 's/Prompt=.*/Prompt=never/' /etc/update-manager/release-upgrades || true
update_release_available_script() {
# The script /etc/cron.weekly/update-notifier-common runs the command
# /usr/lib/ubuntu-release-upgrader/release-upgrade-motd which runs the command
# /usr/lib/ubuntu-release-upgrader/check-new-release whose output is written to the "stamp" file
# /var/lib/ubuntu-release-upgrader/release-upgrade-available which is picked up by OSSEC.
#
# To prevent the OSSEC alerts from from telling the user to run 'do-release-upgrade' which
# may break their system, we update both the script and the existing "stamp" file.

for file in /usr/lib/ubuntu-release-upgrader/check-new-release /var/lib/ubuntu-release-upgrader/release-upgrade-available; do
if [ -f $file ]; then
sed -i "s|Run 'do-release-upgrade' to upgrade to it\\.|Visit https://securedrop.org/xenial-upgrade for more information|" "$file"
fi
done

# remove the file in case it's empty
rm -f /var/lib/ubuntu-release-upgrader/release-upgrade-available
# force re-run the update script to trigger an OSSEC alert
/usr/lib/ubuntu-release-upgrader/check-new-release -q > /var/lib/ubuntu-release-upgrader/release-upgrade-available &
}

revert_update_release_available_script() {
for file in /usr/lib/ubuntu-release-upgrader/check-new-release /var/lib/ubuntu-release-upgrader/release-upgrade-available; do
if [ -f $file ]; then
sed -i "s|Visit https://securedrop\\.org/xenial-upgrade for more information|Run 'do-release-upgrade' to upgrade to it.|" "$file"
fi
done
}

# Issue #4104
# Set Prompt=never on Xenial
# Set Prompt=lts on Trusty
update_release_prompt() {
set -e
upgrade_config='/etc/update-manager/release-upgrades'

if [ "$(lsb_release -sc)" = trusty ]; then
sed -i 's/Prompt=.*/Prompt=lts/' "$upgrade_config"
update_release_available_script
else
sed -i 's/Prompt=.*/Prompt=never/' "$upgrade_config"
revert_update_release_available_script
fi
}

remove_2fa_tty_req() {
# The goal here is to remove legacy 2FA req on TTY logins
# Lets prevent this from bombing out the install though if it fails
Expand Down Expand Up @@ -70,7 +111,7 @@ case "$1" in

manage_tor_repo_config
remove_2fa_tty_req
disable_upgrade_prompt
update_release_prompt

# Remove cron-apt action should occur after security upgrades to avoid breaking
# automatic upgrades (see issue #4003)
Expand Down
27 changes: 27 additions & 0 deletions molecule/testinfra/staging/common/test_release_upgrades.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
def test_release_manager_upgrade_channel(host):
"""
Ensures that the `do-release-upgrade` command will honor
upgrades from Trusty to Xenial, but not suggest upgrades
from Xenial to Bionic (which is untested and unsupported.)
"""
expected_channels = {
"trusty": "lts",
"xenial": "never",
}

config_path = "/etc/update-manager/release-upgrades"
assert host.file(config_path).is_file

raw_output = host.check_output("grep '^Prompt' {}".format(config_path))
_, channel = raw_output.split("=")

expected_channel = expected_channels[host.system_info.codename]
assert channel == expected_channel


def test_do_release_upgrade_is_installed(host):
"""
Ensure the `do-release-upgrade` command is present on target systems,
so that instance Admins can upgrade from Trusty to Xenial.
"""
assert host.exists("do-release-upgrade")