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>
This commit is contained in:
parent
02cac26ef5
commit
03cbcba7b2
@ -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());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user