-
Notifications
You must be signed in to change notification settings - Fork 46
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
Automatically update dom0 and VM configs over time #172
Merged
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
161918a
Configures automatic updates to VMs via dom0
99660b5
Writes configs for dom0 via salt
9a5535f
Adds clarifying comments to the update script
532a0ae
Expands securedrop-update script
5e9075c
Tweak securedrop-update script
emkll b4106c9
Fix flake8
emkll ded9423
Cleans up notifications in dom0 update logic
2ee0d93
Tests for apt packages up to date
4c75e27
Adds dist_upgrade to pkg.upgrade command
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: set syntax=yaml ts=2 sw=2 sts=2 et : | ||
|
||
## | ||
# Installs dom0 config scripts specific to tracking updates | ||
# over time. These scripts should be ported to an RPM package. | ||
## | ||
|
||
|
||
# Copy script to system location so admins can run ad-hoc | ||
dom0-update-securedrop-script: | ||
file.managed: | ||
- name: /usr/bin/securedrop-update | ||
- source: salt://securedrop-update | ||
- user: root | ||
- group: root | ||
- mode: 755 | ||
|
||
# Symlink update script into cron, for single point of update | ||
dom0-update-securedrop-script-cron: | ||
file.symlink: | ||
- name: /etc/cron.daily/securedrop-update-cron | ||
- target: /usr/bin/securedrop-update | ||
|
||
# Create directory for storing SecureDrop-specific icons | ||
dom0-securedrop-icons-directory: | ||
file.directory: | ||
- name: /usr/share/securedrop/icons | ||
- user: root | ||
- group: root | ||
- mode: 755 | ||
- makedirs: True | ||
|
||
# Copy SecureDrop icon for use in GUI feedback. It's also present in | ||
# the Salt directory, but the permissions on that dir don't permit | ||
# normal user reads. | ||
dom0-securedrop-icon: | ||
file.managed: | ||
- name: /usr/share/securedrop/icons/sd-logo.png | ||
- source: salt://sd/sd-journalist/logo-small.png | ||
- user: root | ||
- group: root | ||
- mode: 644 | ||
# Dependency on parent dir should be explicitly declared, | ||
# but the require syntax below was throwing an error that the | ||
# referenced task was "not available". | ||
# require: | ||
# - dom0-securedrop-icons-directory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: set syntax=yaml ts=2 sw=2 sts=2 et : | ||
|
||
base: | ||
dom0: | ||
- sd-dom0-files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: set syntax=yaml ts=2 sw=2 sts=2 et : | ||
|
||
# "Placeholder" config to trigger TemplateVM boots, | ||
# so upgrades can be applied automatically via cron. | ||
base: | ||
qubes:type:template: | ||
- match: pillar | ||
- topd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/bash | ||
# Utility for dom- to ensure all updates are regularly installed | ||
set -e | ||
set -u | ||
|
||
# Number of VMs to update in parallel. Default is 4, | ||
# which can be memory-intensive. | ||
SECUREDROP_MAX_CONCURRENCY=2 | ||
|
||
|
||
# Ensure elevated privileges | ||
if [[ "$EUID" -ne 0 ]]; then | ||
echo "Script must be run as root! Exiting..." | ||
exit 1 | ||
fi | ||
|
||
# Display GUI feedback about update process | ||
function securedrop-update-feedback() { | ||
# Unpack msg as arg1 | ||
local msg="$1" | ||
shift | ||
|
||
# Running `notify-send` as root doesn't work, must be normal user. | ||
# Setting 60s expire time (in ms) since it's a long-running cmd. | ||
local qubes_user | ||
qubes_user="$(id -nu 1000)" | ||
su "$qubes_user" -c "notify-send \ | ||
--app-name 'SecureDrop Workstation' \ | ||
--icon /usr/share/securedrop/icons/sd-logo.png \ | ||
--expire-time 60000 \ | ||
'SecureDrop: $msg'" | ||
} | ||
|
||
# `qubesctl pkg.upgrade` will automatically update dom0 packages, as well, | ||
# but we *first* want the freshest RPMs from dom0, *then* we'll want to | ||
# update the VMs themselves. | ||
|
||
securedrop-update-feedback "Updating application..." | ||
qubesctl \ | ||
--max-concurrency "$SECUREDROP_MAX_CONCURRENCY" \ | ||
pkg.upgrade refresh=true | ||
|
||
emkll marked this conversation as resolved.
Show resolved
Hide resolved
|
||
securedrop-update-feedback "Updating VM configuration..." | ||
qubesctl \ | ||
--max-concurrency "$SECUREDROP_MAX_CONCURRENCY" \ | ||
state.highstate | ||
|
||
# Here would be a good place for state.highstate, to re-apply the VM configs. | ||
# Let's first make sure the package upgrade logic is stable, we can circle | ||
# back to enforce the Salt configs regularly. | ||
|
||
securedrop-update-feedback \ | ||
"Updates installed. Please reboot the workstation \ | ||
to ensure the latest security fixes are applied." |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry, I think I wasn't clear. My previous comment was about the ordering only, not which actions are performed. If you want to update templates, you still need
--templates
. If you want to apply configuration to other vms (non-templates), then you need--all
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would explain the behavior I'm seeing locally, @marmarek; many thanks for your guidance here!