Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-83939

QGenericUnixServices::openDocument / xdgDesktopPortalOpenFile uses wrong fd mode, breaking snaps

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3: Somewhat important P3: Somewhat important
    • 6.6
    • 5.12.8, 5.13.2, 5.14.2, 5.15.0 Beta4
    • QPA: X11/XCB
    • None
    • Linux/X11
    • 03cbcba7b2b0e42a04033a008c7fac87595e7f35(dev)

      The xdgDesktopPortalOpenFile helper called by QGenericUnixServices::openDocument passes an O_PATH file descriptor to the xdg-desktop-portal D-Bus API:

      https://github.com/qt/qtbase/blob/5.13/src/platformsupport/services/genericunix/qgenericunixservices.cpp#L202

      This fails for Snap packaged applications, but works for Flatpaks due to some backward compatibility code.

      Instead, it should pass an O_RDONLY file descriptor to prove that the application has read access to the file it wants opened (since you can open O_PATH file descriptors for files you can't read), which will work for both Flatpaks and Snaps.  This is what the GLib code calling this interface does:

      https://gitlab.gnome.org/GNOME/glib/-/blob/2.64.2/gio/gopenuriportal.c#L107

      This problem was originally reported on the Snapcraft forum here:

      https://forum.snapcraft.io/t/xdg-open-or-gvfs-open-qdesktopservices-openurl-file-somelocation-file-txt-wont-open-the-file/16824?u=jamesh

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            jgrulich Jan Grulich
            jamesh James Henstridge
            Votes:
            4 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes