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

Improve template distribution mechanism #2534

Closed
andrewdavidwong opened this issue Dec 23, 2016 · 4 comments
Closed

Improve template distribution mechanism #2534

andrewdavidwong opened this issue Dec 23, 2016 · 4 comments
Assignees
Labels
C: core C: templates P: minor Priority: minor. The lowest priority, below "default." release notes This issue should be mentioned in the release notes.
Milestone

Comments

@andrewdavidwong
Copy link
Member

andrewdavidwong commented Dec 23, 2016

Create a tool to manage installed templates. It should support:

  • listing available templates, including new versions of installed templates (but clearly mark which are installed and which are not)
  • download new templates, or updated version of installed template (again, with clear distinction of those modes, to not accidentally override already installed template)
  • install downloaded template - either as a new template, or override existing one
  • should also cover qubes-dom0-update combined --action=upgrade --action=reinstall command #4518 aka override template X with its latest version (regardless if it's the same version as currently installed or not)
  • all downloaded packages should have signature checked before analyzing their content
  • listing templates should also have machine-readable output format (may be separate option), so it would be easier to build new GUI around it
  • the tool should not assume running in dom0 - it should be possible to run it also from MgmtVM with appropriate Admin API access (it's true about all the qvm-* tools, so as long the new tool use only that, it should be fine)
  • (optional) select storage pool to use for installing template into

Template packages should not be recorded in rpm database of dom0 for multiple reasons:

  • rpm (and yum/dnf) would try to update those packages automatically, which in most cases leads to data loss
  • rpm independently keep track of template files, which makes removing, renaming and other such actions complicated (this is why right now qvm-remove refuse to remove rpm-installed templates)

Additionally, processing rpm package should be safe for dom0 in sense that no template-provided scripts are executed in dom0. It should be safe to install arbitrary template package regardless of its origin, without risking dom0 compromise. Template package should only influence template itself (its root img and possibly selected settings).

The tool should use "updatevm" to access network repository, where needed.

There is already qvm-template-postprocess tool that given directory with root.img and default menu entries list (whitelisted-appmenus.list) import it into qubes (create appropriate TemplateVM, import root.img into appropriate pool, setup menu entries etc). The tool may be adjusted as part of this task, but the main work is about providing input to that tool.

Based on discussion on IRC and below, it should be ok to stick with yum/dnf repository as distribution method, but create separate tool to extract template rpm packages. That tool should ignore any rpm scripts inside and unexpected files, to satisfy "safe to install arbitrary template package" requirement.
Parts of qubes-dom0-update tool may be useful, but that's not requirement.


Background:
On 2016-12-23 02:49, Marek Marczykowski-Górecki wrote:

On Thu, Dec 22, 2016 at 11:56:13PM -0800, Andrew David Wong wrote:

On 2016-12-22 07:33, J. Eppler wrote:

  1. How can I search for qubes-templates in dom0 rpm repository? The qubes-dom0-update tool excludes all templates from a search.

$ sudo qubes-dom0-update --action=search qubes-template

This will pass through the terminal output from the UpdateVM, so even
though templates are excluded in the dom0 dnf command, you'll still get
the search results (in red text by default).

Remember that you won't see community templates unless you enable their repo:

$ sudo qubes-dom0-update --enablerepo=qubes-templates-community --action=search qubes-template

Reading red text is not a really good solution from an usability perspective. What are the reasons to exclude templates from a search in the first place?

Actually, after further testing, I've found that this doesn't work. Even with --enablerepo=qubes-templates-community, I'm only getting the Fedora and Arch templates in search results (not Whonix or Debian). Without --enablerepo=qubes-templates-community, I only get the Fedora templates in the search results. So, this method doesn't work. Moreover, the results are inconsistent, since Debian is in the official templates-itl repo, whereas Arch is in the templates-community repo.

Marek, any idea what's going on here?

Already installed templates are excluded from every qubes-dom0-update
operation. Mostly to not accidentally upgrade such package - which would
override all the changes made inside (including installed packages,
applied updates etc). Currently the only exception is "reinstall"
action, with one specific template given as an argument. There is a plan
to extend this to some other actions:
#2527

But in general, we need some better mechanism to distribute templates,
this is one of the reasons...

@andrewdavidwong andrewdavidwong added C: core enhancement P: minor Priority: minor. The lowest priority, below "default." labels Dec 23, 2016
@andrewdavidwong andrewdavidwong added this to the Far in the future milestone Dec 23, 2016
@Jeeppler
Copy link

Guix is a functional transactional package manager and it can be installed besides any existing package manger on Linux. Guix is self contained and focuses on reproducible builds. I think Guix could be used, slightly modified (chroot in disposable vm), to manage template packages.

@marmarek
Copy link
Member

marmarek commented Dec 4, 2018

Some better description - requirements:

template package format

  • a container for root.img
  • compressed
  • integrity protected (signature)
  • possibly a minimal metadata (description, version, preferred virt_mode, some other settings?)

repository format

  • a repository for packages above
  • searchable/listable
  • understands different versions of the same package (optional)
  • integrity protected (signature)

tools

  • builder-side:
    • generate template package and repository offline, then upload to mirrors as static files
  • client-side:
    • download repository metadata (info about templates) without downloading actual packages
    • download selected template
    • verify signature
    • extract root.img and possibly other metadata, then create actual TemplateVM using Admin API

The above is just a brain dump, nothing set in stone. We prefer an existing format with tools meeting as much as possible the above points. While tooling could be adjusted, IMO we shouldn't really change the format itself.

One possibility to consider is something based on OVF. Pros include being well adopted standard, but on the cons side it's quite complex (if going this way, we'd definitely need to use DispVM for actual package extraction).

Another option is to stick with rpm+yum/dnf as package and repository format, but do not really install those packages (in terms of rpm database in dom0), but only extract root.img from there.

@marmarek
Copy link
Member

Another option is to stick with rpm+yum/dnf as package and repository format, but do not really install those packages (in terms of rpm database in dom0), but only extract root.img from there.

After some discussion, this looks to be a good idea.

@adrelanos
Copy link
Member

Maybe it should be possible to be able to update (some of?) the metadata but without requiring to upgrade to the actual template image?

@marmarek marmarek modified the milestones: TBD, Release 4.1 Jan 29, 2021
@marmarek marmarek added the release notes This issue should be mentioned in the release notes. label Jan 29, 2021
marmarek added a commit to WillyPillow/qubes-core-admin-client that referenced this issue Feb 18, 2021
RPM API is confusing and it's easy to get it wrong when verifying
package signatures.
Call 'rpmkeys --checksig' which is more rebust here - RPM authors should
know how to use their API.

QubesOS/qubes-issues#2534
marmarek added a commit to WillyPillow/qubes-core-admin-client that referenced this issue Feb 18, 2021
Avoid risk of conflicting downloads to the same directory, reusing
partial downloads, leaving broken files etc. Move template package out
of temporary directory only after its verified.

QubesOS/qubes-issues#2534
marmarek added a commit to WillyPillow/qubes-core-admin-client that referenced this issue Feb 18, 2021
marmarek added a commit to WillyPillow/qubes-core-admin-client that referenced this issue Feb 18, 2021
- rename parser_gen to get_parser - for consistency with other tools
- clarify 'storage pool'
- move '-' to the end in regex characters list

QubesOS/qubes-issues#2534
marmarek added a commit to WillyPillow/qubes-core-admin-client that referenced this issue Feb 18, 2021
- validate if IP has correct syntax
- print warning if value is invalid

QubesOS/qubes-issues#2534
marmarek added a commit to WillyPillow/qubes-core-admin-client that referenced this issue Feb 18, 2021
Use fcntl.flock() instead of just file existence check, so it won't fail
on a stale lock file. While at it, move locking to a function decorator,
to de-clutter the install function a bit. This will allow reducing
indentation level, but don't do it yet, to make the patch readable.

Move lock testing into a separate test, and remove it from install
tests.

QubesOS/qubes-issues#2534
marmarek added a commit to marmarek/qubes-mgmt-salt-dom0-virtual-machines that referenced this issue Sep 16, 2021
Templates are no longer recorded in rpmdb, so pkg.installed doesn't work
anymore

QubesOS/qubes-issues#2534
marmarek added a commit to marmarek/qubes-mgmt-salt-dom0-qvm that referenced this issue Sep 16, 2021
pkg.installed doesn't work anymore, because templates are not recorded
in rpmdb. Use proper qvm-template tool.

QubesOS/qubes-issues#2534
marmarek added a commit to marmarek/qubes-mgmt-salt-dom0-virtual-machines that referenced this issue Sep 16, 2021
Templates are no longer recorded in rpmdb, so pkg.installed doesn't work
anymore

QubesOS/qubes-issues#2534
marmarek added a commit to marmarek/qubes-core-admin-linux that referenced this issue Oct 2, 2021
qvm-template is now a canonical tool to management. Redirect all
requests related to templates to appropriate qvm-template command

QubesOS/qubes-issues#2534
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: core C: templates P: minor Priority: minor. The lowest priority, below "default." release notes This issue should be mentioned in the release notes.
Projects
None yet
Development

No branches or pull requests

5 participants