diff options
author | Jan Grulich <jgrulich@redhat.com> | 2023-05-02 11:19:29 +0200 |
---|---|---|
committer | Jan Grulich <jgrulich@redhat.com> | 2023-05-03 07:22:52 +0200 |
commit | 03cbcba7b2b0e42a04033a008c7fac87595e7f35 (patch) | |
tree | 9b77f0fc05f5add59fc16f686ceb28b38a845a81 | |
parent | 02cac26ef568355dbcab2fb204abdbac6c0580fb (diff) |
OpenFile portal: do not use O_PATH fds
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.
Fixes: QTBUG-113143
Pick-to: 6.5 5.15
Change-Id: Icc171752d73ee091282b7c655f71da3cb59179b1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r-- | src/gui/platform/unix/qgenericunixservices.cpp | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/gui/platform/unix/qgenericunixservices.cpp b/src/gui/platform/unix/qgenericunixservices.cpp index e834ad1f07..34d9c37e24 100644 --- a/src/gui/platform/unix/qgenericunixservices.cpp +++ b/src/gui/platform/unix/qgenericunixservices.cpp @@ -177,8 +177,7 @@ static inline QDBusMessage xdgDesktopPortalOpenFile(const QUrl &url, const QStri // 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("org.freedesktop.portal.Desktop"_L1, "/org/freedesktop/portal/desktop"_L1, @@ -188,7 +187,7 @@ static inline QDBusMessage xdgDesktopPortalOpenFile(const QUrl &url, const QStri QDBusUnixFileDescriptor descriptor; descriptor.giveFileDescriptor(fd); - QVariantMap options = { { "writable"_L1, true } }; + QVariantMap options = {}; if (!xdgActivationToken.isEmpty()) { options.insert("activation_token"_L1, xdgActivationToken); @@ -198,11 +197,6 @@ static inline QDBusMessage xdgDesktopPortalOpenFile(const QUrl &url, const QStri return QDBusConnection::sessionBus().call(message); } -#else - Q_UNUSED(url); - Q_UNUSED(parentWindow) - Q_UNUSED(xdgActivationToken) -#endif return QDBusMessage::createError(QDBusError::InternalError, qt_error_string()); } |