From: Debian Qt/KDE Maintainers Date: Fri, 25 Oct 2024 09:40:08 +0000 (+0300) Subject: OpenFile portal: do not use O_PATH fds X-Git-Tag: archive/raspbian/5.15.15+dfsg-2+rpi1^2~21 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=44a52de2fba9a5d5a467d26cc4ca79e83224cb5e;p=qtbase-opensource-src.git OpenFile portal: do not use O_PATH fds Origin: upstream, https://code.qt.io/cgit/qt/qtbase.git/commit/?id=03cbcba7b2b0e42a Last-Update: 2023-05-13 Using O_PATH requires correctly specifying whether the fd is writable or not. Stating that the fd is writable without it actually being writable results into rejection on xdg-desktop-portal side. Other implementations like xdg-open or gtk have also moved away from O_PATH fds so this will make a matching implementation and avoid possible rejections from xdp. Gbp-Pq: Name dont_use_O_PATH.diff --- diff --git a/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/src/platformsupport/services/genericunix/qgenericunixservices.cpp index f0d1722c9..2a645b752 100644 --- a/src/platformsupport/services/genericunix/qgenericunixservices.cpp +++ b/src/platformsupport/services/genericunix/qgenericunixservices.cpp @@ -205,8 +205,7 @@ static inline QDBusMessage xdgDesktopPortalOpenFile(const QUrl &url) // handle_token (s) - A string that will be used as the last element of the @handle. // writable (b) - Whether to allow the chosen application to write to the file. -#ifdef O_PATH - const int fd = qt_safe_open(QFile::encodeName(url.toLocalFile()), O_PATH); + const int fd = qt_safe_open(QFile::encodeName(url.toLocalFile()), O_RDONLY); if (fd != -1) { QDBusMessage message = QDBusMessage::createMethodCall(QLatin1String("org.freedesktop.portal.Desktop"), QLatin1String("/org/freedesktop/portal/desktop"), @@ -216,16 +215,13 @@ static inline QDBusMessage xdgDesktopPortalOpenFile(const QUrl &url) QDBusUnixFileDescriptor descriptor; descriptor.giveFileDescriptor(fd); - const QVariantMap options = {{QLatin1String("writable"), true}}; + const QVariantMap options = {}; // FIXME parent_window_id message << QString() << QVariant::fromValue(descriptor) << options; return QDBusConnection::sessionBus().call(message); } -#else - Q_UNUSED(url) -#endif return QDBusMessage::createError(QDBusError::InternalError, qt_error_string()); }