fix: use wl-copy for clipboard writes on native Wayland sessions#12536
fix: use wl-copy for clipboard writes on native Wayland sessions#12536jb0421 wants to merge 2 commits into
Conversation
On Wayland the ownCloud daemon has no compositor surface and never receives keyboard focus, so QClipboard::setText() is silently dropped by the compositor when COPY_PRIVATE_LINK is handled. Detect a native Wayland session via WAYLAND_DISPLAY and delegate the clipboard write to wl-copy(1), which does not require a compositor surface. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
|
|
Interesting approach indeed ..... requires wl-copy to be installed .... also needs to be ltested with the appimage - I guess we would need wl-copy to be packaged into the app image ... |
|
@DeepDiver1975 Should I create a new PR with |
feel free to give it a shot - thank you |
5d10c84 to
4e5e57e
Compare
On Wayland, look for wl-copy next to the application binary first (covers self-contained builds like AppImage), then fall back to PATH. Add BUNDLE_WL_COPY cmake option to install wl-copy alongside the client binary during packaging. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
4e5e57e to
b99fc81
Compare
|
@DeepDiver1975 Now it bundles |
dj4oC
left a comment
There was a problem hiding this comment.
Adds a Wayland-specific clipboard write path (spawns wl-copy) for "Copy private link to clipboard" instead of always using QApplication::clipboard().
Findings
Security: Medium β falls back to a bare "wl-copy" resolved via $PATH when no bundled binary is found next to the app; a writable-earlier-in-PATH binary could be planted and executed with the private-link URL as an argument. Prefer a fixed system path (e.g. /usr/bin/wl-copy) or an explicit allow-list instead of trusting ambient PATH. Argument injection via URLs starting with - is a low-severity edge case (a -- separator would be cheap defense-in-depth). QProcess::startDetached is called with an argv list (not a shell string), which correctly avoids shell/command injection.
Stability: Concern β the branch triggers on any non-empty WAYLAND_DISPLAY, including XWayland-forced sessions (QT_QPA_PLATFORM=xcb) where the old QApplication::clipboard() path already worked; those users lose a previously-working path with no fallback. wl-copy also requires the wlr-data-control-unstable-v1 protocol, which GNOME/Mutter does not implement β on GNOME Wayland this silently no-ops, with no error surfaced to the user. Recommend falling back to QApplication::clipboard() when wl-copy isn't found or fails, rather than silently dropping the copy.
Performance: Clean β one stat() + a detached, non-blocking process spawn per user click; no UI-thread blocking, no hot loop.
Coverage: Minor gap β the binary-resolution logic is pure/testable but inlined in copyUrlToClipboard; no test added. Not blocking given this is UI/clipboard glue rather than sync logic.
Cross-platform check
Clean β change is scoped behind qgetenv("WAYLAND_DISPLAY") and if(UNIX AND NOT APPLE) in CMake; Windows/macOS unaffected.
Verdict
Changes requested
π€ Automated review by Claude Code (security Β· stability Β· performance Β· coverage)
Generated by Claude Code
Summary
Fixes #12534
On native Wayland sessions,
QApplication::clipboard()->setText()is silentlydropped by the compositor when the ownCloud daemon has no focused surface β which
is always the case when the command arrives via the socket from a file manager
shell integration.
This change detects a native Wayland session via
WAYLAND_DISPLAYand delegatesthe clipboard write to
wl-copy(1), which uses the Wayland primary selectionprotocol and does not require a compositor surface.
Changes
copyUrlToClipboard(): fall back towl-copywhenWAYLAND_DISPLAYis set#include <QProcess>Testing
Tested manually on Ubuntu 24.04 LTS (GNOME Wayland, Nautilus 46.4) with a locally
built client:
Notes
wl-copyis provided by thewl-clipboardpackage, which is available on allmajor Linux distributions and is a common dependency for Wayland clipboard tools.
If
wl-copyis not installed,QProcess::startDetachedsilently fails and theclipboard write is lost β same behaviour as before this fix.
See also: owncloud/client-desktop-shell-integration-nautilus#11 (comment)