-
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
Add sd-export VMs and basic export flow #259
Changes from 8 commits
08ec1cd
1c7d174
388351a
7bd80e9
db3ab2f
f1bbcb8
ff41a9c
7f524f3
67cffb8
2e80b32
dd01287
fe1d41a
efc1ede
dbe00eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
[flake8] | ||
ignore: W605 | ||
max-line-length = 99 |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: set syntax=yaml ts=2 sw=2 sts=2 et : | ||
|
||
## | ||
# sd-export-files | ||
# ======== | ||
# | ||
# Moves files into place on sd-export | ||
# | ||
## | ||
include: | ||
- fpf-apt-test-repo | ||
|
||
sd-export-template-install-cryptsetup: | ||
pkg.installed: | ||
- pkgs: | ||
- cryptsetup | ||
|
||
sd-export-send-to-usb-script: | ||
file.managed: | ||
- name: /usr/bin/send-to-usb | ||
- source: salt://sd/sd-export/send-to-usb | ||
- user: root | ||
- group: root | ||
- mode: 755 | ||
- makedirs: True | ||
|
||
sd-export-desktop-file: | ||
file.managed: | ||
- name: /usr/share/applications/send-to-usb.desktop | ||
- source: salt://sd/sd-export/send-to-usb.desktop | ||
- user: root | ||
- group: root | ||
- mode: 644 | ||
- makedirs: True | ||
cmd.run: | ||
- name: sudo update-desktop-database /usr/share/applications | ||
- require: | ||
- file: sd-export-desktop-file | ||
|
||
sd-export-file-format: | ||
file.managed: | ||
- name: /usr/share/mime/packages/application-x-sd-export.xml | ||
- source: salt://sd/sd-export/application-x-sd-export.xml | ||
- user: root | ||
- group: root | ||
- mode: 644 | ||
- makedirs: True | ||
cmd.run: | ||
- name: sudo update-mime-database /usr/share/mime | ||
- require: | ||
- file: sd-export-file-format | ||
- file: sd-export-desktop-file |
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: | ||
sd-export-template: | ||
- sd-export-files |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: set syntax=yaml ts=2 sw=2 sts=2 et : | ||
|
||
# | ||
# Installs 'sd-export' AppVM, to persistently store SD data | ||
# This VM has no network configured. | ||
## | ||
include: | ||
- sd-workstation-template | ||
|
||
sd-export-template: | ||
qvm.vm: | ||
- name: sd-export-template | ||
- clone: | ||
- source: securedrop-workstation | ||
- label: red | ||
- tags: | ||
- add: | ||
- sd-workstation | ||
- require: | ||
- sls: sd-workstation-template | ||
|
||
sd-export-usb-dvm: | ||
qvm.vm: | ||
- name: sd-export-usb-dvm | ||
- present: | ||
- template: sd-export-template | ||
- label: red | ||
- prefs: | ||
- netvm: "" | ||
- template_for_dispvms: True | ||
- tags: | ||
- add: | ||
- sd-workstation | ||
- require: | ||
- qvm: sd-export-template | ||
|
||
# Ensure the Qubes menu is populated with relevant app entries, | ||
# so that Nautilus/Files can be started via GUI interactions. | ||
sd-export-template-sync-appmenus: | ||
cmd.run: | ||
- name: > | ||
qvm-start --skip-if-running sd-export-template && | ||
qvm-sync-appmenus sd-export-template | ||
- require: | ||
- qvm: sd-export-template | ||
- onchanges: | ||
- qvm: sd-export-template | ||
|
||
{% import_json "sd/config.json" as d %} | ||
|
||
# Here we must create as the salt stack does not appear to allow us to create | ||
# VMs with the class DispVM and attach the usb device specified in the config | ||
# permanently to this VM | ||
create-named-sd-export-dispvm-and-permanently-attach: | ||
cmd.run: | ||
- name: > | ||
qvm-kill sd-export-usb || true; | ||
qvm-remove --force sd-export-usb || true; | ||
qvm-create --class DispVM --template sd-export-usb-dvm --label red sd-export-usb; | ||
qvm-usb attach --persistent sd-export-usb {{ d.usb.device }} || true; | ||
qvm-tags sd-export-usb add sd-workstation |
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-export |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ set -u | |
set -o pipefail | ||
|
||
|
||
# When adding new VMs, ensure the template is listed *after* the AppVMs that | ||
# use it. | ||
declare -a sd_workstation_vm_names=( | ||
sd-gpg | ||
sd-proxy | ||
|
@@ -16,6 +18,9 @@ declare -a sd_workstation_vm_names=( | |
sd-whonix | ||
sd-svs-disp | ||
sd-svs-disp-template | ||
sd-export-usb-dvm | ||
sd-export-usb | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's prefer
And the relevant config lines referring to these VMs should be updated, as well. Discussion in the motivating ticket (#84) indicates that we may want to consolidate all export functionality into a single stateless VM. Given the disparate config needs (such as net/no-net) between just USB export and e.g. Onionshare, let's plan to name explicitly from the start, and consolidate if and only if we identify a sound method of doing so. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've renamed sd-export-dvm to sd-export-usb-dvm. I think this makes sense, we want a DispVM template AppVM to not have network access. In an attempt to minimize the total amount of templates, I think it might make sense to use the same template for USB exports and other exports(networked, OnionShare exports), as to reduce the time to upgrade templates (which is already quite long, as each template must be updated independently). Since we will likely be creating a AppVM/DispVM template for network-specific exports, I think it might make sense for them to share templates. I don't feel strongly about sharing the template, happy to break up the template further if you think it's warranted. |
||
sd-export-template | ||
) | ||
|
||
for vm in "${sd_workstation_vm_names[@]}" ; do | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info"> | ||
<mime-type type="application/x-sd-export"> | ||
<comment>Archive for transfering files from the SecureDrop workstation to an external USB device.</comment> | ||
<glob pattern="*.sd-export"/> | ||
</mime-type> | ||
</mime-info> |
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.
It's a shame to force removal of the VM on every provisioning run. A quick glance at the qvm docs seems to confirm we don't have a Salt-managed method for this, but perhaps we could wrangle it with the Python API. Fine as-is, for now, we'll want to switch wholesale to the Python API for VM creation if necessary (#159).
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.
Here's a patch to improve the error handling somewhat on this rather forceful one-liner, by breaking it up:
Since I encountered problems during initial review, I'm not appending this commit, to make sure we've working from the same branch as we debug.