Bug 812972

Summary: disable auto-mount of devices when USB auto share is enabled and active
Product: Red Hat Enterprise Linux 6 Reporter: David Jaša <djasa>
Component: spice-gtkAssignee: Default Assignee for SPICE Bugs <rh-spice-bugs>
Status: CLOSED WONTFIX QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.3CC: cfergeau, cwei, dblechte, desktop-qa-list, hdegoede, jwu, marcandre.lureau, mclasen, mjenner, mkrcmari, mzhan, rbalakri, tpelka, zpeng
Target Milestone: rc   
Target Release: 6.8   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 922714 (view as bug list) Environment:
Last Closed: 2015-10-22 12:26:46 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 844075, 844076    
Bug Blocks: 808057, 922714    

Description David Jaša 2012-04-16 17:10:00 UTC
Description of problem:
disable auto-mount of devices when USB auto share is enabled and active in order to prevent any corruption that might be caused by concurrent raw access to the device

Version-Release number of selected component (if applicable):
virt-viewer-0.5.2-4.el6.x86_64

How reproducible:
always

Steps to Reproduce:
1. connect with virt-viewer to VM that features USB sharing
2. ensure that virt-viewer has both keyboard and mouse focus
3. plug in the device
  
Actual results:
* virt-viewer asks for root password to get sharing privileges if necessary
* virt-viewer forwards the device
* gnome components auto mount the device in client

Expected results:
gnome in client mounts the device only if virt-viewer releases it (i.e. if user refuses to forward it to the guest or if he "ejects" it in the guest)

Additional info:
similar issue when working with gparted: 
https://bugzilla.gnome.org/show_bug.cgi?id=324220

Comment 3 Hans de Goede 2012-04-17 20:14:34 UTC
I think this is a reasonable request, but I wonder if there is an API to suspend automounting in gnome / hal / udisks (does RHEL-6 have udisks?). I guess David Zeuthen probably knows, adding him to the CC. David?

Comment 4 David Zeuthen 2012-04-17 22:05:31 UTC
(In reply to comment #3)
> I think this is a reasonable request, but I wonder if there is an API to
> suspend automounting in gnome / hal / udisks (does RHEL-6 have udisks?). I
> guess David Zeuthen probably knows, adding him to the CC. David?

RHEL6 has udisks 1.x and the D-Bus API there is

 http://hal.freedesktop.org/docs/udisks/UDisks.html#UDisks.Inhibit

You can also use the udisks(1) command for this (the --inhibit option), see

 http://hal.freedesktop.org/docs/udisks/udisks.1.html

Hope this helps.

Comment 5 Hans de Goede 2012-06-11 13:35:59 UTC
This should be done in spice-gtk, changing component.

Comment 6 Hans de Goede 2012-06-11 13:47:05 UTC
HI,

(In reply to comment #4)
> (In reply to comment #3)
> > I think this is a reasonable request, but I wonder if there is an API to
> > suspend automounting in gnome / hal / udisks (does RHEL-6 have udisks?). I
> > guess David Zeuthen probably knows, adding him to the CC. David?
> 
> RHEL6 has udisks 1.x and the D-Bus API there is
> 
>  http://hal.freedesktop.org/docs/udisks/UDisks.html#UDisks.Inhibit
> 
> You can also use the udisks(1) command for this (the --inhibit option), see
> 
>  http://hal.freedesktop.org/docs/udisks/udisks.1.html

Hmm, this seems to require root rights, and we want to inhibit it from the spice-client process which runs as normal user. Is there a way to just stop automounting for one user?

Regards,

Hans

Comment 7 David Zeuthen 2012-06-11 13:58:13 UTC
(In reply to comment #6)
> HI,
> 
> (In reply to comment #4)
> > (In reply to comment #3)
> > > I think this is a reasonable request, but I wonder if there is an API to
> > > suspend automounting in gnome / hal / udisks (does RHEL-6 have udisks?). I
> > > guess David Zeuthen probably knows, adding him to the CC. David?
> > 
> > RHEL6 has udisks 1.x and the D-Bus API there is
> > 
> >  http://hal.freedesktop.org/docs/udisks/UDisks.html#UDisks.Inhibit
> > 
> > You can also use the udisks(1) command for this (the --inhibit option), see
> > 
> >  http://hal.freedesktop.org/docs/udisks/udisks.1.html
> 
> Hmm, this seems to require root rights, and we want to inhibit it from the
> spice-client process which runs as normal user. Is there a way to just stop
> automounting for one user?

Not that I can easily think of - if you need this, the best would be to add an inhibitor interface to the automounter (for GNOME 3, it's in the Shell nowadays I think)... which is messy because you'd need all the desktops to implement it.

Best is probably to just unmount all the partitions on the device (including tearing down LUKS) if opening fails? Sure, it's not the "right" or "correct" solution but it may be a lot easier and robust than adding inbitors frameworks.

[1] : just running the umount(8) command is fine and preferred as it is the most portable solution (works on both RHEL6 and F17/RHEL7)

Comment 8 Hans de Goede 2012-06-22 06:36:52 UTC
(In reply to comment #7)
> > Hmm, this seems to require root rights, and we want to inhibit it from the
> > spice-client process which runs as normal user. Is there a way to just stop
> > automounting for one user?
> 
> Not that I can easily think of - if you need this, the best would be to add
> an inhibitor interface to the automounter (for GNOME 3, it's in the Shell
> nowadays I think)... which is messy because you'd need all the desktops to
> implement it.
>
> Best is probably to just unmount all the partitions on the device (including
> tearing down LUKS) if opening fails? Sure, it's not the "right" or "correct"
> solution but it may be a lot easier and robust than adding inbitors
> frameworks.

For those reading along here, after much discussions through other channels we've decided to go with the "add an inhibitor interface to the desktop automounter" solution, for the following reasons:

1) udisks inhibit is global (not per seat / session), udisks inhibit requires root rights and udisk2 does not have an inhibit interface, so doing this at the udisks level is not an option

2) The problem we're trying to fix is a race between automount and auto-usbredir, unmounting partitions first is not going to help, since the may get mounted until after the unmount code runs and before the device redir code detach the usb-storage driver. With that said unmounting partitions first is a good idea for the manual usbredir case and I've put it on my to-do list.

Comment 12 Hans de Goede 2012-07-28 15:59:18 UTC
In order to do this for 6.4, we not only need spice-gtk support, but we also need to have automount-inhibit support added to gnome-session and nautilus. I've filed 2 new bugs for tracking this, gnome-session bug 844075 and nautilus bug 844076, all 3 bugs need to be fixed for this to be actually fixed, and even then it will only be fixed for spice-gtk running under gnome.

Comment 22 Marc-Andre Lureau 2014-03-12 14:07:19 UTC
taking the bug, since we need an assignee, and I will update spice-gtk

Comment 23 Christophe Fergeau 2014-04-29 15:09:15 UTC
gnome-session bug 844075 and nautilus bug 844076 are still in NEW.

Comment 28 David Blechter 2015-10-22 12:26:46 UTC
closing this bug in rhel 6.x. No customer impact, and the solution is already in rhel 7