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

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.12.8, 5.13.2, 5.14.2, 5.15.0 Beta4
    • QPA: X11/XCB
    • None
    • Linux/X11

    Description

      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

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jamesh James Henstridge
              Votes:
              4 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated: