0

As a regular user I can see my mounted camera with gio mount,

user@localhost $ gio mount -l
Volume(0): NIKON DSC D3200
  Type: GProxyVolume (GProxyVolumeMonitorGPhoto2)
  Mount(0): NIKON DSC D3200 -> gphoto2://%5Busb%3A002,007%5D/
    Type: GProxyShadowMount (GProxyVolumeMonitorGPhoto2)
Mount(1): NIKON DSC D3200 -> gphoto2://%5Busb%3A002,007%5D/
  Type: GDaemonMount

But switching to root, it becomes invisible

root@localhost $ gio mount -l
Volume(0): Filesystem root
  Type: GUnixVolume
  Mount(0): Filesystem root -> file:///
    Type: GUnixMount

So running script as root, I cannot unmount camera with the following command,

gio mount -s gphoto2
phoxd
  • 1,546
  • 3
  • 12
  • 26

1 Answers1

1

This is because GIO uses a different backend for enumerating mounts when running as root, because the GVFS daemons which provide (for example) gphoto2 support run in a user session (on the D-Bus session bus) rather than system-wide. So root can’t talk to them.

Run your script as non-root, or you’ll have to do some plumbing to give your script explicit access to your D-Bus session bus (but then it’ll only work when your user session is active).

You shouldn’t need root privileges to list or unmount GIO mounts: permission for that is controlled by polkit, and you should get an authorisation prompt for it if it’s not allowed by default.

Philip Withnall
  • 5,293
  • 14
  • 28
  • Why if I switch to normal user, GIO does not detect change? ```sudo -i -u user bash << EOF > whoami > gio mount -l > EOF user Volume(0): Filesystem root Type: GUnixVolume Mount(0): Filesystem root -> file:/// Type: GUnixMount ``` – phoxd Feb 27 '20 at 18:37
  • 1
    If you’re starting a user session via `sudo`, the D-Bus session bus is probably not getting started. – Philip Withnall Feb 28 '20 at 09:27
  • Thanks! I needed to `export $(dbus-launch)` to launch D-Bus; now `gio` picks up gphoto2 camera. But how would I connect to the logged-in user's D-Bus session? – phoxd Feb 28 '20 at 19:49
  • Run your process as the user, rather than as root. Why are you trying to run it as root? – Philip Withnall Feb 29 '20 at 19:47