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

provide an easy command line tool for copying between vm and dom0 #1324

Closed
adrelanos opened this Issue Oct 11, 2015 · 26 comments

Comments

Projects
None yet
10 participants
@adrelanos
Member

adrelanos commented Oct 11, 2015

(At the Tor summer dev meeting,) @bnvk, @mfc and I agreed that the instructions from https://www.qubes-os.org/en/doc/copy-to-dom0/, i.e. the command qvm-run --pass-io <src_domain> 'cat /path/to/file_in_src_domain' > /path/to/file_name_in_dom0 and philosophy we intentionally do not provide a convenient tool for copying files between VMs and Dom0 should be replaced with something more usable.

In my opinion, making even the command line difficult to use (even advanced users have to look up that syntax), adds extra difficulty to debugging issues (where dom0 logs need to be shared).

@marmarek

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek Oct 11, 2015

Member

On Sun, Oct 11, 2015 at 01:49:22PM -0700, Patrick Schleizer wrote:

(At the Tor summer dev meeting,) @bnvk, @mfc and I agreed that the instructions from https://www.qubes-os.org/en/doc/copy-to-dom0/, i.e. the command qvm-run --pass-io <src_domain> 'cat /path/to/file_in_src_domain' > /path/to/file_name_in_dom0 and philosophy we intentionally do not provide a convenient tool for copying files between VMs and Dom0 should be replaced with something more usable.

In my opinion, making even the command line difficult to use (even advanced users have to look up that syntax), adds extra difficulty to debugging issues (where dom0 logs need to be shared).

I think we should make a distinction here on the copy direction.

  • dom0 -> VM (logs etc) - ok (related #953)
  • VM -> dom0 - not so sure. This could easily lead to dom0 compromise for example when we talk about some shell script

Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

Member

marmarek commented Oct 11, 2015

On Sun, Oct 11, 2015 at 01:49:22PM -0700, Patrick Schleizer wrote:

(At the Tor summer dev meeting,) @bnvk, @mfc and I agreed that the instructions from https://www.qubes-os.org/en/doc/copy-to-dom0/, i.e. the command qvm-run --pass-io <src_domain> 'cat /path/to/file_in_src_domain' > /path/to/file_name_in_dom0 and philosophy we intentionally do not provide a convenient tool for copying files between VMs and Dom0 should be replaced with something more usable.

In my opinion, making even the command line difficult to use (even advanced users have to look up that syntax), adds extra difficulty to debugging issues (where dom0 logs need to be shared).

I think we should make a distinction here on the copy direction.

  • dom0 -> VM (logs etc) - ok (related #953)
  • VM -> dom0 - not so sure. This could easily lead to dom0 compromise for example when we talk about some shell script

Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

@bnvk

This comment has been minimized.

Show comment
Hide comment
@bnvk

bnvk Oct 11, 2015

  • dom0 -> VM (logs etc) - ok (related #953)

Yah, that would be a HUGE usability improvement, simply for taking screenshots. I rarely move things from VM -> dom0 but find myself constantly hindered by the other route!

bnvk commented Oct 11, 2015

  • dom0 -> VM (logs etc) - ok (related #953)

Yah, that would be a HUGE usability improvement, simply for taking screenshots. I rarely move things from VM -> dom0 but find myself constantly hindered by the other route!

@adrelanos

This comment has been minimized.

Show comment
Hide comment
@adrelanos

adrelanos Oct 12, 2015

Member
  • VM -> dom0 - not so sure. This could easily lead to dom0 compromise for example when we talk about some shell script

What about requiring some extra option like --insecure or something?

Member

adrelanos commented Oct 12, 2015

  • VM -> dom0 - not so sure. This could easily lead to dom0 compromise for example when we talk about some shell script

What about requiring some extra option like --insecure or something?

@mfc

This comment has been minimized.

Show comment
Hide comment
@mfc

mfc Oct 12, 2015

Member

what is the usecase for VM -> dom0? I don't know if that is necessary, and I agree it is a vector for compromise.

For dom0 -> VM the usecases are:

  • screenshots
  • logs
Member

mfc commented Oct 12, 2015

what is the usecase for VM -> dom0? I don't know if that is necessary, and I agree it is a vector for compromise.

For dom0 -> VM the usecases are:

  • screenshots
  • logs
@marmarek

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek Oct 12, 2015

Member

For dom0->VM IMHO the best option would be to just have qvm-copy-to-vm
tool, with the same syntax as VM counterpart.

Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

Member

marmarek commented Oct 12, 2015

For dom0->VM IMHO the best option would be to just have qvm-copy-to-vm
tool, with the same syntax as VM counterpart.

Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

@bnvk

This comment has been minimized.

Show comment
Hide comment
@bnvk

bnvk Oct 12, 2015

I agree with @marmarek idea of having the same qvm-copy-to-vm
and qvm-move-to-vm would be the best base scenario for dom0 ->
VM

bnvk commented Oct 12, 2015

I agree with @marmarek idea of having the same qvm-copy-to-vm
and qvm-move-to-vm would be the best base scenario for dom0 ->
VM

@rustybird

This comment has been minimized.

Show comment
Hide comment
@rustybird

rustybird Oct 30, 2015

@mfc:

what is the usecase for VM -> dom0?

Copying an SINIT blob to /boot for AEM would be one.

What do you think about this script: qvm-copy-from-vm [updated 2015-11-02 with --user=root instead of sudo, and --auto]

  • It's short and simple, only supports file arguments (no directories)
  • Safer than ad hoc qvm-run commands (where if the user forgets to redirect stderr to /dev/null, malicious stuff can leak into the dom0 terminal) [not true, I see that qvm-run always filters stderr for escape sequences, even if stdout is not a tty]
  • Supports arbitrary file names (no shell quoting issues)
  • Familiar syntax and behavior (files are saved to $HOME/QubesIncoming/srcvm, will not overwrite existing files)

@mfc:

what is the usecase for VM -> dom0?

Copying an SINIT blob to /boot for AEM would be one.

What do you think about this script: qvm-copy-from-vm [updated 2015-11-02 with --user=root instead of sudo, and --auto]

  • It's short and simple, only supports file arguments (no directories)
  • Safer than ad hoc qvm-run commands (where if the user forgets to redirect stderr to /dev/null, malicious stuff can leak into the dom0 terminal) [not true, I see that qvm-run always filters stderr for escape sequences, even if stdout is not a tty]
  • Supports arbitrary file names (no shell quoting issues)
  • Familiar syntax and behavior (files are saved to $HOME/QubesIncoming/srcvm, will not overwrite existing files)
@marmarek

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek Nov 3, 2015

Member

@rustybird qvm-copy-from-vm implementation looks good. Maybe it would be better to force some target directory, to not forget that some file came from a VM.
The question is whether we want to have such tool at all? @rootkovska @mfc

Member

marmarek commented Nov 3, 2015

@rustybird qvm-copy-from-vm implementation looks good. Maybe it would be better to force some target directory, to not forget that some file came from a VM.
The question is whether we want to have such tool at all? @rootkovska @mfc

@rustybird

This comment has been minimized.

Show comment
Hide comment
@rustybird

rustybird Nov 3, 2015

@marmarek:

Maybe it would be better to force some target directory, to not forget that some file came from a VM.

The files are already saved at ~/QubesIncoming/src_vmname:
https://gist.github.com/rustybird/625e018ed280c18b49f7#file-qvm-copy-from-vm-L11-L13

@marmarek:

Maybe it would be better to force some target directory, to not forget that some file came from a VM.

The files are already saved at ~/QubesIncoming/src_vmname:
https://gist.github.com/rustybird/625e018ed280c18b49f7#file-qvm-copy-from-vm-L11-L13

@rootkovska

This comment has been minimized.

Show comment
Hide comment
@rootkovska

rootkovska Nov 3, 2015

Member
  1. I agree we might extend qvm-{copy,move}-to-vm tools to also support copying of files from Dom0 to AppVMs.
  2. I'm not so convinced we should be supporting the other direction (VM -> Dom0). E.g. I don't think Dom0 should be used for preparing AEM sticks -- e.g. I use for that a one-time dedicated VM with USB controller assigned. Do we have other scenarios for legitimate VM -> Dom0 transfers?
Member

rootkovska commented Nov 3, 2015

  1. I agree we might extend qvm-{copy,move}-to-vm tools to also support copying of files from Dom0 to AppVMs.
  2. I'm not so convinced we should be supporting the other direction (VM -> Dom0). E.g. I don't think Dom0 should be used for preparing AEM sticks -- e.g. I use for that a one-time dedicated VM with USB controller assigned. Do we have other scenarios for legitimate VM -> Dom0 transfers?
@rustybird

This comment has been minimized.

Show comment
Hide comment
@rustybird

rustybird Nov 3, 2015

@rootkovska:

E.g. I don't think Dom0 should be used for preparing AEM sticks -- e.g. I use for that a one-time dedicated VM with USB controller assigned.

What about internal AEM devices (i.e. the system boot partition)? Especially now that AEM supports portable Qubes installations.

Do we have other scenarios for legitimate VM -> Dom0 transfers?

Occasionally, users are instructed to transfer a .rpm to dom0 and install it manually (after verification with rpm -K):

https://groups.google.com/forum/#!searchin/qubes-users/%22rpm$20k%22
https://groups.google.com/forum/#!searchin/qubes-devel/%22rpm$20k%22

@rootkovska:

E.g. I don't think Dom0 should be used for preparing AEM sticks -- e.g. I use for that a one-time dedicated VM with USB controller assigned.

What about internal AEM devices (i.e. the system boot partition)? Especially now that AEM supports portable Qubes installations.

Do we have other scenarios for legitimate VM -> Dom0 transfers?

Occasionally, users are instructed to transfer a .rpm to dom0 and install it manually (after verification with rpm -K):

https://groups.google.com/forum/#!searchin/qubes-users/%22rpm$20k%22
https://groups.google.com/forum/#!searchin/qubes-devel/%22rpm$20k%22

@rootkovska

This comment has been minimized.

Show comment
Hide comment
@rootkovska

rootkovska Nov 3, 2015

Member

If we concluded we absolutely needed a tool in Dom0 (for easier) transfer of files to Dom0, then I like the idea Patrick proposed with requiring an explicit --insecure switch (even if the tool was only for transferring files to Dom0 and had no other purpose).

Member

rootkovska commented Nov 3, 2015

If we concluded we absolutely needed a tool in Dom0 (for easier) transfer of files to Dom0, then I like the idea Patrick proposed with requiring an explicit --insecure switch (even if the tool was only for transferring files to Dom0 and had no other purpose).

@adrelanos

This comment has been minimized.

Show comment
Hide comment
@adrelanos

adrelanos Nov 3, 2015

Member

Joanna Rutkowska:

If we concluded we absolutely needed a tool in Dom0 (for easier)
transfer of files to Dom0, then I like the idea Patrick proposed with
requiring an explicit --insecure switch (even if the tool was only
for transferring files to Dom0 and had no other purpose).

But now I am disagreeing with my earlier self. :)

Minor point... I was wondering how it would work out on a mailing
list... Users are told then to use the tool for copying between vm and
dom0 and adding the --insecure switch. Then we'd get follow up questions
and need to explain "oh, in this case, that's okay'. Not a huge issue,
also not great.

@bnvk any idea?

'--i-know' perhaps? :)

Anyhow. Let's not get lost in this. I'll go with whatever you judge best.

Member

adrelanos commented Nov 3, 2015

Joanna Rutkowska:

If we concluded we absolutely needed a tool in Dom0 (for easier)
transfer of files to Dom0, then I like the idea Patrick proposed with
requiring an explicit --insecure switch (even if the tool was only
for transferring files to Dom0 and had no other purpose).

But now I am disagreeing with my earlier self. :)

Minor point... I was wondering how it would work out on a mailing
list... Users are told then to use the tool for copying between vm and
dom0 and adding the --insecure switch. Then we'd get follow up questions
and need to explain "oh, in this case, that's okay'. Not a huge issue,
also not great.

@bnvk any idea?

'--i-know' perhaps? :)

Anyhow. Let's not get lost in this. I'll go with whatever you judge best.

marmarek added a commit to QubesOS/qubes-linux-utils that referenced this issue Nov 3, 2015

qrexec-lib: add qfile packing functions to libqubes-rpc-filecopy
This is counterpart of 5774c78 "qfile-agent: move data handling code to
libqubes-rpc-filecopy" in core-agent-linux. The main purpose is to
easily reuse the code in dom0 qvm-copy-to-vm tool.

QubesOS/qubes-issues#1324

marmarek added a commit to QubesOS/qubes-core-agent-linux that referenced this issue Nov 3, 2015

qfile-agent: move data handling code to libqubes-rpc-filecopy
This makes the qfile packing code reusable, for example for some dom0
tool. Now qfile-agent.c is only an interface for underlying library.

QubesOS/qubes-issues#1324
@rootkovska

This comment has been minimized.

Show comment
Hide comment
@rootkovska

rootkovska Nov 4, 2015

Member

But, AFAIU, all these cases when the user is asked to copy rpms to Dom0 are some special cases related to special testing/development only. I think it would be fine to require passing of --insecure then. But then again, I also think in such a case it should be just enough to expect the user to use qvm-run -p....

To summarize this threat: I think there is value in implementing a Dom0->VM tool (running in Dom0 and named like the AppVM tools, i.e. qvm-{copy,move}-to-vm, and placing the files into ~/QubesIncoming/dom0) for logs and screenshots mostly. I would not rush to implement any tool for the other direction at this point.

BTW, we should also make sure the user is not able to create a VM named "{D,d}om0" :)

Member

rootkovska commented Nov 4, 2015

But, AFAIU, all these cases when the user is asked to copy rpms to Dom0 are some special cases related to special testing/development only. I think it would be fine to require passing of --insecure then. But then again, I also think in such a case it should be just enough to expect the user to use qvm-run -p....

To summarize this threat: I think there is value in implementing a Dom0->VM tool (running in Dom0 and named like the AppVM tools, i.e. qvm-{copy,move}-to-vm, and placing the files into ~/QubesIncoming/dom0) for logs and screenshots mostly. I would not rush to implement any tool for the other direction at this point.

BTW, we should also make sure the user is not able to create a VM named "{D,d}om0" :)

@rustybird

This comment has been minimized.

Show comment
Hide comment
@rustybird

rustybird Nov 4, 2015

The latest gist revision has --insecure, FWIW

The latest gist revision has --insecure, FWIW

@woju

This comment has been minimized.

Show comment
Hide comment
@woju

woju Nov 4, 2015

Member

On Wed, Nov 04, 2015 at 03:26:00AM -0800, Rusty Bird wrote:

The latest gist revision has --insecure, FWIW

Another idea: for some operation (linking some basic tools to busybox
AFAIR) Gentoo required setting environmental variable
VERY_BRAVE_OR_VERY_STUPID=1

Member

woju commented Nov 4, 2015

On Wed, Nov 04, 2015 at 03:26:00AM -0800, Rusty Bird wrote:

The latest gist revision has --insecure, FWIW

Another idea: for some operation (linking some basic tools to busybox
AFAIR) Gentoo required setting environmental variable
VERY_BRAVE_OR_VERY_STUPID=1

@rustybird

This comment has been minimized.

Show comment
Hide comment
@rustybird

rustybird Nov 4, 2015

I don't have a strong opinion either way, but while we're collecting ideas:

  • Maybe a flaw with these kind of switches is they make it seem like the command itself is insecure, as opposed to handling the file afterwards. So a user might improvise a worse method, e.g. attaching a USB drive to the source VM and then to dom0.
  • They kind of imply that, in contrast, inter-VM copy is inherently secure. But of course handling the files in the destination VM afterwards brings the same danger, just in a more contained environment.

I don't have a strong opinion either way, but while we're collecting ideas:

  • Maybe a flaw with these kind of switches is they make it seem like the command itself is insecure, as opposed to handling the file afterwards. So a user might improvise a worse method, e.g. attaching a USB drive to the source VM and then to dom0.
  • They kind of imply that, in contrast, inter-VM copy is inherently secure. But of course handling the files in the destination VM afterwards brings the same danger, just in a more contained environment.
@adrelanos

This comment has been minimized.

Show comment
Hide comment
@adrelanos

adrelanos Nov 4, 2015

Member
Member

adrelanos commented Nov 4, 2015

@marmarek

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek Nov 11, 2015

Member

Command line tool for dom->VM is done.
It would be nice to have also GUI equivalent (which would prompt for target VM name). Then it would be trivial to plug it into screenshooting tools - appropriate .desktop file just needs to have MimeType=image/png;. It would look like:

[Desktop Entry]
Type=Application
Name=Save image to VM
Exec=qvm-move-to-vm-prompt %F
MimeType=image/png;
NoDisplay=true

I've tried to do some simple script for that, but failed on actual VM name prompt tool - kdialog --combobox should be enough, but it isn't available in Xfce install (and have a lot of KDE dependencies). zenity doesn't have such feature - only simple text entry

Member

marmarek commented Nov 11, 2015

Command line tool for dom->VM is done.
It would be nice to have also GUI equivalent (which would prompt for target VM name). Then it would be trivial to plug it into screenshooting tools - appropriate .desktop file just needs to have MimeType=image/png;. It would look like:

[Desktop Entry]
Type=Application
Name=Save image to VM
Exec=qvm-move-to-vm-prompt %F
MimeType=image/png;
NoDisplay=true

I've tried to do some simple script for that, but failed on actual VM name prompt tool - kdialog --combobox should be enough, but it isn't available in Xfce install (and have a lot of KDE dependencies). zenity doesn't have such feature - only simple text entry

marmarek added a commit to QubesOS/qubes-core-agent-linux that referenced this issue Nov 11, 2015

Bump qubes-utils version requirement
Those commits needs updated qubes-utils:
823954c qrexec: use #define for protocol-specified strings
5774c78 qfile-agent: move data handling code to libqubes-rpc-filecopy

QubesOS/qubes-issues#1324
QubesOS/qubes-issues#1392

marmarek added a commit to QubesOS/qubes-core-admin-linux that referenced this issue Nov 11, 2015

marmarek added a commit to QubesOS/qubes-core-admin-linux that referenced this issue Nov 11, 2015

Require new enough qubes-utils package for updated libqrexec-utils (a…
…gain)

It is required for additional file-copy functions, moved from
core-agent-linux (qfile-agent).

QubesOS/qubes-issues#1324
@rootkovska

This comment has been minimized.

Show comment
Hide comment
@rootkovska

rootkovska Nov 18, 2015

Member

BTW, I forgot about one important scenario about moving files from an AppVMqubes to dom0admin (admin what? admin qube?): namely setting up the wallpaper. Of course the proper way of doing that is to pipe this through our trusted image converter. I also remember we talked once about exposing a simple qrexec service (qubes.SetWallpaper) and a user-visible command in AppVMsqubes, e.g.:

qvm-set-system-wallpaper <filename>

Plus a trivial integration with Nautilus for the context menu.

Member

rootkovska commented Nov 18, 2015

BTW, I forgot about one important scenario about moving files from an AppVMqubes to dom0admin (admin what? admin qube?): namely setting up the wallpaper. Of course the proper way of doing that is to pipe this through our trusted image converter. I also remember we talked once about exposing a simple qrexec service (qubes.SetWallpaper) and a user-visible command in AppVMsqubes, e.g.:

qvm-set-system-wallpaper <filename>

Plus a trivial integration with Nautilus for the context menu.

@andrewdavidwong

This comment has been minimized.

Show comment
Hide comment
@andrewdavidwong

andrewdavidwong May 31, 2016

Member

BTW, I forgot about one important scenario about moving files from an AppVMqubes to dom0admin (admin what? admin qube?): namely setting up the wallpaper. Of course the proper way of doing that is to pipe this through our trusted image converter.

Why not simply display the wallpaper in a fullscreen qube, then take a screenshot from dom0?

Member

andrewdavidwong commented May 31, 2016

BTW, I forgot about one important scenario about moving files from an AppVMqubes to dom0admin (admin what? admin qube?): namely setting up the wallpaper. Of course the proper way of doing that is to pipe this through our trusted image converter.

Why not simply display the wallpaper in a fullscreen qube, then take a screenshot from dom0?

@marmarek

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek May 31, 2016

Member

Because it's tricky to display an image in fullscreen, especially in case of multi-monitor setup. Also it will (depending on image) reduce its resolution, so will be useless after changing dom0 resolution.

Member

marmarek commented May 31, 2016

Because it's tricky to display an image in fullscreen, especially in case of multi-monitor setup. Also it will (depending on image) reduce its resolution, so will be useless after changing dom0 resolution.

@andrewdavidwong

This comment has been minimized.

Show comment
Hide comment
@andrewdavidwong

andrewdavidwong May 31, 2016

Member

I have no problems displaying an image fullscreen on a single monitor, but yes, multiple monitors is tricky. (An easy solution to the resolution issue is simply to take the screenshot again at the new resolution.)

Edit: Actually, can't you use xrandr to temporarily artificially set the resolution of dom0 to be larger than your monitor's resolution, then take the screenshot at the full resolution of the source image?

Member

andrewdavidwong commented May 31, 2016

I have no problems displaying an image fullscreen on a single monitor, but yes, multiple monitors is tricky. (An easy solution to the resolution issue is simply to take the screenshot again at the new resolution.)

Edit: Actually, can't you use xrandr to temporarily artificially set the resolution of dom0 to be larger than your monitor's resolution, then take the screenshot at the full resolution of the source image?

andrewdavidwong added a commit that referenced this issue May 31, 2016

@evadogstar

This comment has been minimized.

Show comment
Hide comment
@evadogstar

evadogstar Jul 5, 2016

https://github.com/evadogstar/qvm-wallpaper-tool/

Maybe to start with something. Current version:
This tool convert image (only jpg and png for security reasons) at AppVM where image is located. Then image downloaded to dom0
Then converted again at dom0

Now without GUI and does not know how to set wallpapers at xfce & kde. Tried some code, but it does not work

qvm-wallpaper-tool <AppVM> /path/to/jpg/at/appvm

#215 link

evadogstar commented Jul 5, 2016

https://github.com/evadogstar/qvm-wallpaper-tool/

Maybe to start with something. Current version:
This tool convert image (only jpg and png for security reasons) at AppVM where image is located. Then image downloaded to dom0
Then converted again at dom0

Now without GUI and does not know how to set wallpapers at xfce & kde. Tried some code, but it does not work

qvm-wallpaper-tool <AppVM> /path/to/jpg/at/appvm

#215 link

@unman

This comment has been minimized.

Show comment
Hide comment
@unman

unman Apr 16, 2017

Member

@andrewdavidwong I would suggest that this can be closed, since there seems little appetite for qube to dom0 copying, (with exception of wallpaper and there is separate ticket for that), and there is now dom0 to qube tool.

Member

unman commented Apr 16, 2017

@andrewdavidwong I would suggest that this can be closed, since there seems little appetite for qube to dom0 copying, (with exception of wallpaper and there is separate ticket for that), and there is now dom0 to qube tool.

@evadogstar

This comment has been minimized.

Show comment
Hide comment
@evadogstar

evadogstar Apr 16, 2017

qvm-get-image now do the job
and close linked ticket #215

evadogstar commented Apr 16, 2017

qvm-get-image now do the job
and close linked ticket #215

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment